View Full Version : Single-pass gloss/specular mapping
10-16-2003, 07:07 PM
I want my scene to have texture-modulated specular mapping, as in a texture map defining the shininess level of a model, but I'm having trouble finding a way to do that in a single pass.
Right now I'm using a two-pass approach, where I render the objects using the specular level texture and only specular light active, then blend it with the standard illuminated diffuse color pass. It seems to me that it should be fairly simple to modulate the specular level based on a texture (or an alpha component of a texture), but I couldn't find any way to do it without resorting to the two-pass approach.
I found a way to do it in Direct3D, but I don't want to touch that thing with a 10 foot pole, so I ask you: how can I do this? Can anyone point me to a tutorial and/or demo source that does it?
Thanks in advance.
10-17-2003, 06:32 AM
Separate specular color is another possibility of gl1.2. Look after EXT_separate_specular_color
10-17-2003, 09:51 AM
I looked into separate specular color, but I couldn't find any way to modulate the separate color... From what I understand of the specification, it simply stores the specular component separately and adds it after the textures are applied. Is there any way to modulate the separate specular value?
And I'll try to look into vertex programs - I never really tried that. If you have any good reference about it, I'd appreciate.
10-17-2003, 09:55 AM
it just adds another usable component into the pixelshading part (or multitexturing part, tex env, what ever)..
you can do the modulation in there manually by reconfiguring/reprogramming the pixelpipeline.
10-17-2003, 10:41 AM
I know I may be pushing it a bit, but can you point me to an example of that? Would be tremendously helpful.
10-17-2003, 07:25 PM
The texture mode should be GL_COMBINE and the source should be the SECONDARY color. This is all standard in GL 1.3 and higher, available as extensions in most earlier versions.
The problem is that you can't really do this and do a full diffuse color modulate at the same time on two-texture hardware (such as GeForce 2 and 4 MX, Intel i810, TNT 2, etc). This is because there's only two texture environments, and you can't do the final color sum.
10-20-2003, 07:33 AM
The table of combine arguments on the OpenGL 1.4 specification (page 156) doesn't list the parameter for the secodary color, and I couldn't find any reference to it... Guess I'll have to look into vertex programs after all.
10-20-2003, 09:59 AM
You are right, secondary color is not available as a combine input. The reason I thought it simply doable is that we do specular using a reflection (cube) map which is available using texture_env_crossbar or the NVIDIA almost-equivalent.
So, it's even less possible to do diffuse + specular in a single pass on 2-unit hardware. But it's still possible to do specular as an explicit additive pass after diffuse, using 2 texture units; by doing what we actually do and using reflection mapping. Bonus: it'll qualify as per-pixel lighting.
10-20-2003, 10:59 AM
Thanks, I had the reflection mapping part somewhat working before, but I didn't really want to follow that approach, though it's becoming more evident that it's my only choice if I want to keep it to a single pass (unless I can do it through vertex programs, which I'll be looking into tonight).
From the examples I checked, it seems that I need to map the light position (and its glare) to a cubemap that's used to generate the reflection, then I calculate the proper cubemap texture coordinates from the light position...
[This message has been edited by Styxx (edited 10-20-2003).]
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.