PDA

View Full Version : Gloss mapping in fixed function pipeline?



keelx
08-07-2011, 03:13 PM
I have opengl 1.4 with a lot of extensions, and I can do normal mapping using the GL_DOT3_RGB_ARB extension, and texture blending operations described in the Paul's Projects tutorials. However, I want to know how to implement specular/gloss mapping using a grayscale texture for the specular exponents. How would I go about doing this in the fixed-function pipeline without using any vendor-specific extensions (the specular tutorial on paul's projects uses an nvidia specific extension that I don't have). And I wont accept 'just use shaders' or 'get a better card' or anything like that.

Alfonse Reinheart
08-07-2011, 03:39 PM
However, I want to know how to implement specular/gloss mapping using a grayscale texture for the specular exponents.

You don't.

Core fixed function is incapable of doing specular per-pixel, and it is certainly incapable of the kind of specular computation you're talking about, which is effectively a dependent texture access.


And I wont accept 'just use shaders' or 'get a better card' or anything like that.

Then you're not going to get it done.

There's a reason why everyone switched to shaders. It wasn't because shaders are a fad. It wasn't because shaders are the "in thing." It's because you can do more with shaders than you ever could with fixed-function.

The simple fact is this: if you want to do what you're asking for, the only tool is shaders. And if your hardware can't handle those, then you can't do what you're trying to.

You have to accept the limits of your hardware. And you have reached them.

keelx
08-07-2011, 04:25 PM
Well, I said that because I want replies that would actually help, given my situation. I am on a laptop with integrated graphics, and I assume a lot of my target audience (casual gamers) will be too. However, I still want my game to look good, and I cannot stand the look of per-vertex lighting. It just looks terrible (by today's standards). My card does support shaders, sort of, direct ARB assembly, and barely GLSL (really slow). If I have to use ARB assembly to achieve the effect I want, then I guess I will. I was just looking for an easier solution. Thank you for your input!

mhagain
08-07-2011, 04:36 PM
If it's an Intel you'll probably find that trying to do any kind of effects (beyond the most basic) in OpenGL is a dead end. Their D3D drivers do however support shader model 2 (and sometimes 3), so there's another option.

keelx
08-07-2011, 08:14 PM
Well, I'm on ubuntu, and I completely removed windows (big mistake), so d3d isn't really an option. I used to have SM2.0 and HLSL. If I had d3d there wouldn't be a problem...
But games that use ARB shaders like doom 3, quake 4, prey, they all ran fine on my computer. So I think there lies my only option.

BionicBytes
08-08-2011, 02:57 AM
You have to accept the limits of your hardware. And you have reached them.
No, it can be done in multiple passes with fixed function pipeline.
See here for a link to an article explaining what to do (http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node134.html)

Paraphrasing the above link the technique is:
Basically diffuse, ambient, and emissive lighting components are drawn in the first pass (without specular) and then the specular lighting component is added using blending (via a gloss map) in a second pass.

So, the first pass sets the specular material to zero, using glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specularColorArray(GL_FRONT_AND_BACK, GL_SPECULAR, specularColorArray)), and draw the surface with diffuse lighting as usual.
Second pass restore the specular color and set the diffuse, ambient, and emissive colors set to zero, and bind a gloss map texture using the alpha component. Set the depth test to GL_EQUAL and then draw the second pass with Additive blending enabled using the function glBlendFunc (GL_SRC_ALPHA, GL_ONE) which is adding the new pixel color modulated by the alpha value from the texture.

Alfonse Reinheart
08-08-2011, 03:48 AM
You may want to re-read what he asked for:


However, I want to know how to implement specular/gloss mapping using a grayscale texture for the specular exponents.

He wants a texture that specifies the specular exponent, not the overall specular reflectance. Also, he wants it per-fragment, not per-vertex, so all of that glMaterial stuff is useless to him.

BionicBytes
08-08-2011, 05:16 AM
Having re-read: agreed. He can't encode the specular exponents and have that processed via fixed function.
He will have to accecpt a limitation and either provide no gloss mapping (per pixel) or implment a per vertex approximation.