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 3 of 3

Thread: emulation of built-in uniforms

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    emulation of built-in uniforms

    so far i'm still using opengl's built-in uniforms for most of my lighting calculations, but i'd like to replace them by my own uniforms. this works well in most cases, but i still have some problems..

    i realized that if i want to emulate gl_LightSource[n].position e.g., that i have to multiply my original vector by the inverse of the current modelview matrix and then pass this to the shader.
    but what do i have to do to emulate gl_LightSource[n].spotDirection? i tried to do it the same way, but it results in no spotlight cone at all. in addition, gl_LightSource[n].spotCosCutoff does not seem to be equal to cos(gl_LightSource[n].spotCutoff)..

    is there a document that decribes how these built-in uniforms are computed? it's not in the glsl specs

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: emulation of built-in uniforms

    check the gl spec (the lighting section) i believe they have the various lighting equations written down.

    with the spot direction u dont wanna take into consideration the position ie uonly the direction, the 3x3 part of the 4x4 matrix.

    for the cos cutoff i think GL u specify it in degrees but cos takes radians as input so use cos( X * DEG2RAD )

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: emulation of built-in uniforms

    realized that if i want to emulate gl_LightSource[n].position e.g., that i have to multiply my original vector by the inverse of the current modelview matrix and then pass this to the shader.
    Remember one thing - light position is transformed by matrix when glLight is called to setup it's position. When you render polygons your matrices can be completely different.

Posting Permissions

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