[osg-users] Change uniform array size

8 views
Skip to first unread message

Peterakos

unread,
Nov 12, 2012, 2:36:36 PM11/12/12
to OpenSceneGraph Users
Hello.

Is there any way to change uniform array size ?

What i do now is:

const int num_of_samples = 64;
uniform vec3 sample_kernel[num_of_samples];

Can i have num_of_samples as uniform ?

If not, is it a good idea to have sample_kernel's size as 512 or 1024
and iterate only num_of_samples ?

thank you.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Nov 13, 2012, 4:31:51 AM11/13/12
to OpenSceneGraph Users
Hi Peterakos,

How you would tackle the problem depends upon what your need are for changing the number of uniforms. 

In terms of OpenGL objects it's generally best to used fixed size objects so that you don't have to reallocate them.  To change the "size" used by the shader one would simply pass in  second uniform to control how man samples are used.

Robert.

Peterakos

unread,
Nov 16, 2012, 2:50:24 PM11/16/12
to OpenSceneGraph Users
Hello.

I try to create an algorithm which uses a configurable number of samples:
uniform vec3 sample_kernel[256];
When i use value higher than 502, i get some errors which probably
refer to my GPU (gtx 650).
It seems gl_MaxFragmentUniformComponents is 2048.

I try to use
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &value);
but i dont get the correct value.

In case I use a fixed size of samples and just pass as uniform the
number of samplesi want to be checked, won't it affect the
performance ?
I mean having a large array of samples while i need the half.

Thank you for your time.
Reply all
Reply to author
Forward
0 new messages