Skip to main content
gamedev.net
🔒 Locked

diffuse, texture and light

Started by Locutus2 1 reply 750+ views
Original Post
Locutus2
Locutus2
Hi ! Just wondering how to setup the renderstates so my polygons take color from : 1: the diffuse color 2: if there is an texture present, the texture 3: if the polygon is hit by light, the light color [edit]the problem is when a polygon is outside the range or not hit by a light, the color is taken from the ambient color. I want the color to be a mix of the ambient and diffuse color.[/edit] this is my current renderstates: SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); SetRenderState(D3DRS_ALPHAREF, 1); SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD) ; SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE); SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT); SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE); SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE); SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_DIFFUSE); SetTextureStageState(0,D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(0,D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(0,D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR); SetTextureStageState(0,D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR); SetRenderState(D3DRS_LIGHTING, true); SetRenderState(D3DRS_AMBIENT,D3DCOLOR_XRGB(128,128,128)); Thanks! [edited by - Locutus2 on June 19, 2002 4:18:09 PM]
Joint-CEO, Solid Core EntertainmentDeveloping Roadclub
Dean Harding
Dean Harding
Before I answer your question, did you know that this message has topic_id=100000? That''s pretty special, I think

Anyway, if I understand your problem, you''re saying that when outside the range of a D3DLIGHT, you''re only getting the diffuse component? Well, that''s by design. I mean if you''re not being lit by any lights, then you should only have ambient lighting...

The only way around this would be to detect whether the object is out of range of any lights in your own code and change the render states/textures states accordingly.


codeka.com - Just click it.
Cipher2
Cipher2
I''m part of locutus project if you''re wondering =)
The thing is that when objects are only hit by ambient light the color is taken entirely from the ambient light not mixing with the diffuse color of the sprite.

If we have grey as ambient all things outside lights are grey.

Hope this clarifies.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.