texture+light

Started by
1 comment, last by critical 20 years, 3 months ago
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)
Advertisement
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




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

This topic is closed to new replies.

Advertisement