Results 1 to 2 of 2

Thread: Uniform buffer objects or constant registers in OpenGL ES 2.

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    1

    Uniform buffer objects or constant registers in OpenGL ES 2.

    When changing shaders, it may be desirable to have certain uniforms carry over without having to set/write to them each time. For example, when rendering elements in a scene, you may want to change shaders more than once; and yet it would be nice to only have to set the view projection matrix once and have the value carried over when switching shader programs. In direct 3d, I believe this is done through constant registers (i.e. postfixing uniforms with a c0, c1, c2, etc. semantic), and in the "old" opengl way of doing things, constants like gl_ModelViewMatrix were available in the shader. Uniform Buffer Objects seemed like an alternative to this, however it looks like they are not available in OpenGL ES 2.0? If so, is there any way to do what I have described above or is the only option to simply set uniforms like this each time you change shaders?

  2. #2

    Re: Uniform buffer objects or constant registers in OpenGL E

    I have been being have same head-ache.
    All matrices such like bone matrix palette and parameters such as lighting and so on must be set every shader changes. This extra and waste process is going to be heavy load for CPU and GPU pretty much.
    And, if you set shader constant registers in every shader changes, extra parameter management is going to be needed. For instance, write shader class and make it have all parameters that are needed to be set into GPU constant registers before render. This means, if you use a hounded shaders in the scene, then there must be a hounded times duplicated projection matrices and so on exist on the memory.
    To avoid this, I made shaders into one shader using conditional branch a lot. However putting conditional branch in shader especially fragment shader is the worst thing that GPU programmer has to avoid as much as he can.
    In DirectX9, constant registers can be easily shared by EffectPool object. Using EffectPool object and share bunch of matrices between shaders, my DirectX9 engine runs with out extra costs that I described above.
    I am new to ES shader so I might be having wrong understanding about this, or there may be smart solution about this, any suggestion appreciated.

Similar Threads

  1. Uniform buffer object testing
    By rohalcg in forum Developers Coding:Beginner
    Replies: 0
    Last Post: 01-14-2012, 09:19 AM
  2. Difference between uniform and constant vertex attribute?
    By andyskinner in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 3
    Last Post: 10-17-2011, 04:28 AM

Posting Permissions

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