View Full Version : bump mapping specular exponent with ARB extensions

12-25-2003, 04:17 PM

I am doing bump mapping with ARB extensions only, one texture unit holds the bump map, one a colormap that is entirely white and one holds the normalization cube map. As input I use the half angle vector. plain simple and ordinary.

But I have no idea of how to fit a specular exponent into this (it does in fact not look very shiny at the moment), except of this:

but rendering n times in a loop doesn't seem like being a very usable solution, for performance reasons.

Is it possible at all, or do I *have* to go to RC oder even fragment programs?


12-25-2003, 08:43 PM
Try here:

You can look at the source code to see how they've done their lighting.

12-25-2003, 08:46 PM
thanks but what they say is basically "we use nine passes, so it is not really possible" http://www.opengl.org/discussion_boards/ubb/wink.gif.

I will look at the source code though..


[This message has been edited by JanHH (edited 12-25-2003).]

12-25-2003, 09:13 PM
Well, on low level hardware you could just use a lookup texture with the s-axis as dot(N,H) and t-axis as the shininess exponent. You don't get very good resolution though for high shininess exponents. Its going to take a lot of passes on GF1/2 level hardware no matter what way you do it. Even on higher level hardware, the lookup texture is a pretty good way to go.

Lots of people just go for a fixed shininess exponent, and vary the intensity of the specular component of the lighting equation instead by using a glossiness texture. Btw, I'm defining shininess & glossiness like this:

specular = gloss * max(dot(N,H), 0)^s

12-26-2003, 04:23 AM
about "low level hardware": It's in fact not that low (gf 4 ti), but as I when using a gloss map I will need two passes anyway (also if I'd use register combiners), I might as well use ARB extensions, so my program would run on ati cards as well.

I read about using a lookup texture for specular hightlights some times here, but I cannot really imagine how this should be done (have to do research and/or think work http://www.opengl.org/discussion_boards/ubb/wink.gif ). do you have any information/links?


12-26-2003, 09:50 AM
The concept of using a texture to do the specular light equation can be generalized. In general, its often useful to use a texture to encode a equation, because its faster than computing it directly in the shader.

If you have some function f(x,y), defined on ranges x in [x_0, x_1], and y in [y_0, y_1] you can encode this function in a texture. Basically you scale both the x-range & y-range so that they're 0-1 and encode x in the s-axis and y in the t-axis. You can also generalize this concept by using 1D, cubemap, and 3D textures. The normalization cubemap is simply an example of encoding a 3D function f(x,y,z)-> norm(x,y,z) using a cubemap texture.

You'll see this idea over and over again in shaders. Its a very common optimization strategy.

You can see how they use here for doing PPL:
http://www.ronfrazier.net/apparition/index.asp?appmain=research/per_pixel_lighting.html (http://www.ronfrazier.net/apparition/index.asp?appmain=research/per_pixel_lighting.html)

http://www.ronfrazier.net/apparition/index.asp?appmain=research/advanced_per_p ixel_lighting.html (http://www.ronfrazier.net/apparition/index.asp?appmain=research/advanced_per_pixel_lighting.html)

edits - grammar

[This message has been edited by Stephen_H (edited 12-26-2003).]

12-27-2003, 05:09 AM
I cannot really imagine how to do this with specular lighting. of course, it is a function that can be encoded in a texture, but one texture coordinate would have to be the result of the dot3, the other one the specular exponent!? how can this be done?