Archived

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

FenrirWolf

Specular mapping (aka gloss map)

Recommended Posts

Hmm, been trying to work this out on my own without bugging folks, but I'm stumped. So I'm asking for a little advice about DX9's fixed rendering pipeline. So, I have this spaceship: And as you can see, it's got specular hilights on it. Currently, they are calculated across the entire object on a per vertex, which makes it look very "plastic-y". I understand that gloss maps are used to enhance specular hilights by using multitexturing. From what I gather, you disable the built-in specular hilight calculation and then use a gloss map to change how an environment map is rendered across your object, so you get both a simulated reflection and specular variance at the same time. So I want to apply a gloss map to my environment map. I understand that I should take the env map, modulate it by the gloss map (that being a simple ramp of how much I want the env map to contribute) and then add the result to the base texture. But I'm not sure how to express this in the multitexture pipeline. How could I modulate the env map and the gloss map BEFORE they are added to the base texture? I can't do it after, because then my modulated map overwrites the base texture. I feel like I am missing something real obvious on this. PS: My goal is not to use vertex/pixel shaders here, but DX9's fixed pipeline. EDIT: This isn't vBulletin. --- http://www.gapingwolf.com [edited by - FenrirWolf on October 15, 2003 5:37:19 PM]

Share this post


Link to post
Share on other sites
Try using the TEMP value (look at the texture stage states, its in there):
Stage0 - GlossMap
Stage1 - Current * EnvMap = TEMP
Stage2 - BaseTexture * Diffuse
Stage3 - Current + TEMP

This will give you GlossMap*EnvMap + Diffuse*BaseTexture.

or you can try (without the TEMP register):

Stage0 - GlossMap
Stage1 - Current * EnvMap
Stage2 - Current + BaseTexture
Stage3 - Current * Diffuse

This will give you (GlossMap*EnvMap + BaseTexture)*Diffuse

Share this post


Link to post
Share on other sites
Hey, thanks. That points me in the right direction. My days of 3d modeling have screwed up my perception of how multitexturing really works. I was trying to use texture stages in terms of layers. So I was saying to myself, "But how do I overlay the env*gloss map on top of the base texture?" In other words, I was trying to do base+env*gloss, which is an entirely different formula!

I think I understand now why people say "think of it as math" when it comes to 3D blending operations...

Man, I feel stupid now.

---
http://www.gapingwolf.com

Share this post


Link to post
Share on other sites
Hey you can also add specular lighting in there too:

Stage0 - GlossMap * Specular
Stage1 - Current * EnvMap = TEMP
Stage2 - BaseTexture * Diffuse
Stage3 - Current + TEMP

This''ll give you:
GlossMap*Specular*EnvMap + Diffuse*BaseTexture

Share this post


Link to post
Share on other sites