Archived

This topic is now archived and is closed to further replies.

critical

texture+light

Recommended Posts

i have a problem. i''m a direct3d n00b and i''m exploring the tutorials in the dx9 sdk ive redone all tuts for d3d graphics and if i code a program with lights ( pointlights, spots, or directional) it works. and if i do the same with the other tut about lighing it works too, but if i combine the two tuts the light went out and the scene is rendered normally as i would only use the code from the texturing tutorial... after some hours i''m frustrated and i need your (!!) help!! a friend of mine meaned i have to use pixel shaders for this but i don''t know if he is right... (HEEEELP !!!) yours Christoph (sorry for my bad english -> i''m german)

Share this post


Link to post
Share on other sites
I dont understand the problem.. you''re just trying to get fixed-function lighting (ie, no shaders) working with textures? That definitely doesnt need a pixel shader.

The chances are that the renderstates or texture blending states are wrong, and so the lighting isnt being used. Here are some of the states that you need set to combine diffuse lighting with texturing.

SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);

To set up the lighting, make sure you are calling both SetLight and LightEnable for each light in the scene.

And some misc render states..

SetRenderState(D3DRS_LIGHTING,TRUE);
SetRenderState( D3DRS_COLORVERTEX,TRUE);

If your vertices have a colour component then use this..

SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1);

otherwise..

SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE,D3DMCS_MATERIAL);

and remember to set up a material.

HTH,
Chris




Share this post


Link to post
Share on other sites
thanks for your fast reply. i''m at school now, but in the evening i''ll try it. thx a lot. i think this will work know because there are some more things then in my code!

yours
Christoph

Share this post


Link to post
Share on other sites