Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Single-pass gloss/specular mapping

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Brazil
    Posts
    8

    Single-pass gloss/specular mapping

    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.

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Single-pass gloss/specular mapping

    Vertex/fragment programs?

    Separate specular color is another possibility of gl1.2. Look after EXT_separate_specular_color

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Brazil
    Posts
    8

    Re: Single-pass gloss/specular mapping

    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.

    Thanks!

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Single-pass gloss/specular mapping

    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.
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Brazil
    Posts
    8

    Re: Single-pass gloss/specular mapping

    I know I may be pushing it a bit, but can you point me to an example of that? Would be tremendously helpful.

    Thanks!

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Single-pass gloss/specular mapping

    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.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  7. #7
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Brazil
    Posts
    8

    Re: Single-pass gloss/specular mapping

    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.

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Single-pass gloss/specular mapping

    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.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  9. #9
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Brazil
    Posts
    8

    Re: Single-pass gloss/specular mapping

    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •