# Specular lighting

Hello,

I have reached the point where I would like to add specular to my lighting equation. I’m just doing the simple dot3 diffuse lighting at the moment. I am using texture combiners and GF2. Questions:

Two pass approach on GF2?

Can be done with texture combiners?

I couldn’t work this out. Maybe put per vertex half angle vectors as primary fragment color and do N dot H? Then modulate by some specular percentage to determine how visible the highlighting is?? Then blending to add this result to diffuse? This leaves out how to exponentiate N dot H though. How??

Drop texture combiners and go with register combiners?

Final question: How do normalization cube maps relate to bumpmapping w/specular?

Thanks for the help.

Old GLman

PS. If you have to refer to me to Nvidia’s developer relations, thats ok . I would just like to understand it in english a bit better before I tackle those papers

You get N dot H in the first texture stage/combiner.

You use the second combiner to raise to a power of 2.

You use the final combiner to raise by another power of 2.

It’s not the highest power in the world, but it beats having to wash windows using only a strawberry and a baseball bat.

You can also pull stunts with the re-scaling of data on input/output, I think. A function that’s flat at 0 for inputs from 0.0 through 0.75, and then goes linear up to 1.0 at 1.0, is not technically a “raise to a power” function, but, hey, it looks an awful lot like one

You’re refering to register combiners correct? Right now I’m using texture_env_combine. If your saying go ahead to register combiners I’ll do that instead.

Thanks,

Old GLman

I don’t know how much you can get the texture_env_combine to do the same thing, but surely you could do this by setting up output_rgb=input_rgb*input_rgb? You could probably also use some scale-and-bias to multiply by 2 and subtract one and clamp on the input, which would give you a nice increase in power.

Last, render out with BlendFunc( GL_SRC_COLOR, GL_ONE ) which means output = input * input + previous, yielding an extra power of two.

I e, I believe it’s possible to do something like:

stage 0: do the dot product

stage 1: scale by 2, subtract 1, clamp to [0,1], raise to power of two

blend func: raise by another power of two, and add

Grr. I just checked up on the COMBINE parameters. You don’t have the clamping necessary in there to do the linear re-mapping trick. You’d have to go to register combiners for that.

jwatte,

I managed to get something goin.

Stage 0: dot product

Stage 1: Just scale. I tried raising to power of 2, but since I cant clamp there seems no point.

I scale and bias the eye tangent space vector then blend (ONE,ONE_MINUS_DST_COLOR).

It really helps define the light, buuut there seems to be no way to increase its specularity, if you know what I mean.

I think I can tweak it for semi decent results ( it looks not bad right now ), but it looks like register combiners are the way to go.

Thanks for your help,

Old GLman