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: Speed of built in lights v.s. custom lights

  1. #1
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    46

    Speed of built in lights v.s. custom lights

    Hi there,

    Quick question: if you are writing a custom shader for lighting, it is still useful (faster) to use the build in lights from openGL, or might I just as wel use my own array of lights? I don't expect that many object will be lit by more than 8 lights OFTEN but I would really prefer that it would just work with 9 or more lights as well. So is there still a good reason to use the built in lights from opengl when you write your own shader??

    thanks!

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,220
    So you're just talking about using the built-in gl_* uniforms provided by OpenGL with GLSL <= 1.2 instead of passing in your own uniforms. Right?

    If so, you're going to have to have the shader logic in there either way. And it's just a convenience to use the built-in uniforms populated by the glLight* and other fixed-function APIs.

    As you said, using the built-in uniforms implicitly limits you to what the fixed-function pipeline inputs can define (unless you want a complete mix of built-in and custom uniforms). OTOH, if you pass in your own uniforms, you can do whatever you want (new light types, light cone attenuation functions, fog types, etc.).

    Further it limits you to GLSL <= v1.2 as these "go away" in GLSL 1.3 IIRC.

    If your comfortable with shaders and are starting from scratch, I'd just pass in your own uniforms. Though if you have some existing code that you're porting that uses the legacy glLight* APIs, then consider using the built-in uniforms with GLSL 1.2 only initially as a porting stepping stone, with the idea of kicking them to the curb once you get things working.

  3. #3
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    46
    Thanks a lot, that was the answer was hoping for! I am working from scratch and i do prefer my own type of lights, so i'll just pass my own lights then.

Posting Permissions

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