Results 1 to 7 of 7

Thread: spec. highlights on textured surface

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    15

    spec. highlights on textured surface

    Hi,
    in the superbible I found sth. about how to keep specular highlights on textures. That's done by drawing the textured Object twice, first without texture and only with the highlights turned on, and then, drawing the object textured with all types of light turned on, except the spec. highlights. Before drawing the object the second time, GL_BLEND is enabled with glBlendFunc(GL_ONE, GL_ONE).
    When doing this, GL_DEPTH_TEST should be disabled, becaus otherwise the two objects are drawn at the same place, and that could result into problems with depth-testing (an effect calles z-fighting).

    But I'd like to do this with bezier-surfaces, and because of blending, I can look trough a 'hill' at the ground that is actually lying behind the hill.

    Has someone an idea that helps me out?
    Thanks!

    mathias_123

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: spec. highlights on textured surface

    There's a function in OpenGL which lets you apply specular highlight after texturing, instead of before.

    Code :
    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);
    And to go back to the original mode.
    Code :
    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT);
    This requires the extensions GL_EXT_separate_specular_color or OpenGL 1.2.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    15

    Re: spec. highlights on textured surface

    Thanks, but I don't have that extension.
    Does somebody know another way?
    I already succeeded in doing specular highlights on textured spheres, so I believe that it must be possible on bezier-surfaces, too.

    mahias_123

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: spec. highlights on textured surface

    One thing I didn't think about when reading your post the first time, was that you disable the depth buffer. You should not disable the depthbuffer in the second pass, but disable writing to it, and set depth function to GL_EQUAL.
    Code :
    glDepthMask(GL_FALSE);
    glDepthFunc(GL_EQUAL);
    If you disable depth test, objects far away won't be occluded by by objects near the viewpoint. The GL_EQUAL should not introduce any Z-fighting, unless you change some states between the two passes, that affect the fragment position (like matrices).

  5. #5
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: spec. highlights on textured surface

    This may not be an extension. It's part of core OpenGL now AFAIK. Look in the header files for similar tokens, maybe it was made an ARB extension, or is full on core. I don't track all this stuff.

  6. #6
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: spec. highlights on textured surface

    For the depth issues, the equal depth test is not a solution. You still need to depth test but less than or equal is still the right test. You should use plPolygonOffset to avoid 'interference' or zfighting between rendering passes.

    The depth mask is a good idea, but obviously you'd never need it with a GL_EQUAL depth test.

    [This message has been edited by dorbie (edited 01-29-2002).]

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: spec. highlights on textured surface

    The depth mask is rendurant if you only want to make it work, yes. But if you disable the depth mask, you will also make sure you don't do any rendurant updates of the depth buffer when a fragment with equal depth is generated. Some drivers might be smart enough to realize this, but you can't be sure every driver are.

Similar Threads

  1. Issues mixing textured and non-textured objects
    By deegee in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-12-2011, 08:35 AM
  2. moving over an infinite textured surface
    By indexicality in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-10-2005, 08:18 AM
  3. Possible to reflect specular highlights?
    By PickleWorld in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 04-16-2005, 03:57 PM
  4. nv25 highlights
    By jonasmr in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 05-06-2003, 05:24 AM
  5. Specular Highlights
    By qwert in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 08-23-2001, 07:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean