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 10 of 11

Thread: Is there some way to bind uniform with dynamic size to shader?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Contributor
    Join Date
    Nov 2017
    Posts
    80

    Question Is there some way to bind uniform with dynamic size to shader?

    I have shader with constant size of uniform array looks like next:
    Code :
    #version 430  // maximum version that can be supported by my ATI card with open source mesa driver.
     
    const int MAX_POINT_LIGHTS = 5;
    ...
     
    uniform PointLight pointLights[MAX_POINT_LIGHTS];
     
    struct Attenuation {
      float constant;
      float linear;
      float exponent;
      float distance;
    };
     
     
    struct PointLight {
      vec3 colour;
      vec3 position;
      float intensity;
      Attenuation att;
    };
     
    ...


    May I use in some way dynamic size of uniform array with my own structs?
    I mean:
    1 - On the CPU side I calculate "point light" number as three items.
    2 - I bind them those three lights to the shader.
    3 - On the shader side I have array with 3 items with known size.

    That is so cool if it possible!

    Tank you for answer!
    Last edited by nimelord; 12-05-2017 at 11:53 AM.

Tags for this Thread

Posting Permissions

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