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

Thread: Uniforms limit in shaders ,OpenGL 4.0

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Mar 2011
    Location
    Israel
    Posts
    53

    Question Uniforms limit in shaders ,OpenGL 4.0

    Hi All. I have a frag shader that does multi - source phong point lightning . I define an array of structs which hold all the properties needed for each light source.I have 5 uniforms in each struct.Then I noticed
    that passing more than25-30 (haven't checked the exact number)structs in the array the program linkage fails.So I guess I pass the uniforms limit for that shader.Anybody can tell me what is the limit ?
    Also , in such a case what is the best way to process multiple lightsource using forward rendering without getting restricted by number of uniforms? So uniform buffers solve this problem ?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    There is a distinction between the amount of uniform components in the default uniform block and the default block plus user defined uniform blocks. You can query the default uniform component limits with glGetInteger*() and GL_MAX_stage_UNIFORM_COMPONENTS (where stage is either one of VERTEX,FRAGMENT,GEOMETRY, TESS_CONTROL or TESS_EVALUATION). The number of 4-component uniform vectors is the above value divided by 4. The limit of combined uniform components, i.e. the components in the default block plus all user defined uniforms blocks, can be queried with using GL_MAX_stage_COMBINED_UNIFORM_COMPONENTS.

    See sections 2.11.7, 2.12.1, 2.12.3, 2.13.3 and 3.10.1 of the OpenGL 4.2 core specification for more information.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,124
    Quote Originally Posted by SasMaster View Post
    Also , in such a case what is the best way to process multiple lightsource using forward rendering without getting restricted by number of uniforms? So uniform buffers solve this problem ?
    Best depends on your situation, but one solution is multipass + accumulate. Another is (since your limit is passing light source attributes in) to put your light source attributes in a textures/images where they don't count against the uniform limit.

  4. #4
    Intern Contributor
    Join Date
    Mar 2011
    Location
    Israel
    Posts
    53
    Yes , I am switching to multipass+accumulate. I have a question here.Should I blend each light color add to the buffer and then also blend that buffer with the scene geometry?I just see here several ways to do it and want to know which is the fastest.So that is what I think: I run first pass to render a geometry second pass I render all the lights for that geometry into some texture of custom fbo, then I add it via blending into the default buffer. Is this the way to do a forward rendering ? If U have let's say 50 lights ,that means for each object I run second pass x50 to accumulate all lights. Looks like a serious performance hit.

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
  •