Jump to content
  • Advertisement
Sign in to follow this  
Kest

Coloring with Normal Maps

This topic is 4816 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

I swear this is the last one :) My rendering engine allows objects to define a diffuse and ambient color. There is also a global directional light diffuse. The result is pretty much objectambient + ( objectdiffuse * lightdiffuse * brightness). I'm starting to realize now that once diffuse is used up in the vertex format to output data to the dot product 3 routine, no coloring at all is possible. Not light diffuse, not object ambience, and not object diffuse. Or at least it appears that way. This is how I have the texture stages lined up:
SetTextureState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
SetTextureState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
SetTextureState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

SetTextureState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
SetTextureState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
SetTextureState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
The dot product stage uses the diffuse color that my vertex shader outputs. I've tried making it rely on the specular color instead, but then diffuse is completely ignored - it has no effect on the color or lighting (which makes sense of course). Is there any way to sneak another D3DTA_DIFFUSE value in here somewhere if I replace the current with D3DTA_SPECULAR? If I'm doing something completely dumb, please point that out as well. Anyone know how to get color into this setup? Do I have to add another texture stage to do so? [Edited by - Kest on September 9, 2005 7:26:37 PM]

Share this post


Link to post
Share on other sites
Advertisement
I did a presentation that covers this subject at the 2002 gdc d3d tutorial day.

http://developer.nvidia.com/object/gdc_practicalperpixel.html

Share this post


Link to post
Share on other sites
Wow, I've learned a lot from that. Thanks much.

One thing that has me puzzled is this last but very important bit that you have at the end of the L.N + ambient routines:

Source Blend mode
SrcColor*SrcAlpha

I realize we want to mutliply the end result color and alpha. But I can't seem to figure out how to do that. I'm pretty tired, so it's very possible I'm asking very dumb questions.

Another part that I'm not completely sure about is where you set tfactor.a as the second alpha arg. You have tfactor.a (holding ambience, which I totally get), but D3DTA_TFACTOR needs set as the alpha operand, correct? As in Direct3D would only use the alpha part of the argument, since it's an alpha arg? Otherwise, I'm not sure how to set just the alpha component of t-factor.

Thanks again for your help. Any info regarding the source blend mode would be great :)

Share this post


Link to post
Share on other sites
I think I figured it out. You meant this setup, right?

SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );

It appears to be working. Very cool :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!