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: Conditional shader compile

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

    Conditional shader compile

    It would be nice to have a possibility to declare #define-like constants from the main app code. This will allow for conditinal compiling of shader code without need for multiply sahders. Like:

    App:
    glDefineDeclARB(ProgramObject, "ADV_LIGHT");

    Shader:
    #ifdef ADV_LIGHT
    - do some sort of advanced lighting
    #else
    - simple lighting
    #end

    I think this possibility will allow better interaction with extensions. For example, nvidia has it's glslang implementation based on cg. One could test the presence of EXT_cg_shader and make use of mixed precision. This could be nice(from my point of view) mechanism for glslang extensions - you can write one shader that would handle everything.
    Of cource, a workaround is to manually add #define lines into the code string. But it's not so elegant.

  2. #2
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Conditional shader compile

    Defines already exist. Though you'll have to set up the defines by including extra strings. This is one of the reasons why you pass an array of strings to the compile calls.

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

    Re: Conditional shader compile

    Oh... Sometimes I'm simply stupid

Posting Permissions

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