• Advertisement

Archived

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

probs with textures and lights

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hoi i try making a lovely scene, with a lovely texture. All is going well except i do not see any "amazing" lighting thingies. if i remove my SetTexture(blah) and run the lovely scene i see the amazing lighting stuff working perfectly, but without my BEAUTIFUL WOOD texture of course. :\ AHH! i feel inferior! what have i done wrong? May The Gzoo Be With You! ~Lord Gzoo

Share this post


Link to post
Share on other sites
Advertisement
HA KEN KEN?!?
not helping the lousy baboon that didn''t spend enough time with the texture tutorials so he can''t get anything with textures right and now he wants to suicide coz he really likes his BEAUTIFUL WOOD texture?!?!?

BLAH well i will move through all of the d3d part of my code and i''ll probably find something like the D3DFVF_TEX0 i used and wondered why i see no texture. HA!

May The Gzoo Be With You!
~Lord Gzoo

Share this post


Link to post
Share on other sites
quote:
Original post by Lord Gzoo
HA KEN KEN?!?
not helping the lousy baboon that didn''t spend enough time with the texture tutorials so he can''t get anything with textures right and now he wants to suicide coz he really likes his BEAUTIFUL WOOD texture?!?!?

BLAH well i will move through all of the d3d part of my code and i''ll probably find something like the D3DFVF_TEX0 i used and wondered why i see no texture. HA!

May The Gzoo Be With You!
~Lord Gzoo


Could you give us your render state? What values are you sending to SetRenderState?

If I had to guess, you are probably using something like D3DTOP_SELECTARG1 as your texture op.

You have to tell D3D how to blend your texture with your diffuse color in order to get correct lighting.

What version of D3D are you using? And what language (VB/C++/etc.)?

--TheMuuj

Share this post


Link to post
Share on other sites
ok i will do anything to get my beautiful wood texture with lights.

i use vc++ 6.0 with d3d 8.0

my vertex sturcture looks like THIS!
D3DXVECTOR3 Position;
D3DXVECTOR3 Normal;
FLOAT u, v;

and... here are my lovley texture stage states
lpd3dd->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
lpd3dd->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);

lpd3dd->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
lpd3dd->SetTextureStageState(0, D3DTSS_ALPHAARG1,D3DTA_TFACTOR);


and a basic blending thingy that looks like this:

lpd3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpd3dd->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
lpd3dd->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);


any other stuff i should post?
and sorry for screaming i just hate it when i look at my code for hours without writing anything only scrolling up and down...

May The Gzoo Be With You!
~Lord Gzoo

Share this post


Link to post
Share on other sites
quote:
Original post by Lord Gzoo
lpd3dd->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
lpd3dd->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);



Your ColorOp is set to SelectArg1, which only displays the color value in argument 1. Argument 1 is then set to the texture color, so your program is only rendering texture color.

Instead, you should set your ColorOp to something that uses two arguments.

It depends on what kind of lighting you are using, but this is probably what you want:

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


Now Direct3D will modulate (multiply) each color in the texture by the color of the diffuse lighting.

If you want something like specular lighting or bump mapping then it will be different.

Hope I was able to help. I haven't coded this part of my engine in months (it's all very abstracted at this point).

--TheMuuj

[edited by - themuuj on June 27, 2002 5:29:00 PM]

Share this post


Link to post
Share on other sites
cool, it works!

(isn''t that a name of a column at flipcode? mm...)

thanks a lot!

ok i need to understand something... because i have no vertex diffuse, d3d modulates the texture and the color of the material i am using...

right?

IT''s AMAZING!

May The Gzoo Be With You!
~Lord Gzoo

Share this post


Link to post
Share on other sites
quote:
Original post by Lord Gzoo
cool, it works!

(isn''t that a name of a column at flipcode? mm...)

thanks a lot!

ok i need to understand something... because i have no vertex diffuse, d3d modulates the texture and the color of the material i am using...

right?

IT''s AMAZING!

May The Gzoo Be With You!
~Lord Gzoo


I think (and correct me if I''m wrong), that Direct3D''s lighting engine generates the diffuse colors for you based on your light colors and your materials.

If you include diffuse colors in your vertices, then you have to do manual lighting. Sometimes, this is a good thing, if you want to apply your own lighting algorithm. But if you do this you can kiss the L part of hardware T&L goodbye (and probably the T, as you need to T before you can L). :-)

--TheMuuj

Share this post


Link to post
Share on other sites
Vertex shaders and pixel shaders. Then you can keep your custom lighting in hardware. Pre-calc all the values you need, throw them into the constants, and render away letting the shaders do the work in hardware.

-Zims

Share this post


Link to post
Share on other sites

  • Advertisement