Jump to content
  • Advertisement
Sign in to follow this  
DrNecessiter

FixedFunction specular help

This topic is 4832 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'm having trouble understanding when/how the specular color is added to the final output color in the fixed function pipeline. I enable specular, use materials for the lighting sources and then do the following: TextureFactor = (my color) ColorOp[0] = SELECTARG1; ColorArg1[0] = TFACTOR; ColorOp[1] = DISABLE; I would think that this should FORCE the color to TextureFactor, without regard to any lighting at all. Sure enough, there is no diffuse lighting, but there ARE specular highlights. When does DX magically add the specular? Does this imply that the texture stages do not give you complete control over the color blending in fixed-function?

Share this post


Link to post
Share on other sites
Advertisement
When D3DRS_SPECULARENABLE is TRUE, specular from D3D fixed function vertex lighting is added after the multi-texture cascade (SetTextureStageState) but before frame buffer blending (D3DRS_SRCBLEND, D3DRS_DESTBLEND, D3DRS_ALPHABLENDENABLE).

You can set D3DRS_SPECULARENABLE to FALSE and apply vertex specular yourself in the multitexture cascade if desired (D3DTA_SPECULAR).


Of course, with shaders you're free to do any kind of lighting you want [smile]

Share this post


Link to post
Share on other sites
Oh, man... thanks so much. I thought I was going insane.

So, this also implies that the results of the interpolated specular value can not be used in a texture operation? Essentially I want to create a map to mask out non-shiny parts of an object. It seems I need to modulate specular and alpha to get this to work.

Any thoughts on doing fixed-function specular masks?

Share this post


Link to post
Share on other sites
You've probably thought of this, but you could just render with full specular and then render another pass on top of it with specular off and transparency in your texture... this is basically what I do to render the Earth, since you don't want specular highlights on the land but you do on the ocean. Render the ocean, then the land!

Share this post


Link to post
Share on other sites
Yeah, that works pretty well, but I was hoping to find a single-pass solution. Don't think it's possible now that I understand how the specular is applied.

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!