J-S, Another uniform array snafu I ran into is this: different drivers may report the uniform location differently for arrays. Specifically: the ATI windows driver reports the uniform array location at "array[0]" and on NVIDIA it is reported as "array". Both are valid, according to the spec. But OSG believe only supports the latter last time I checked. I had to introduce a helper class to account for this.
This may not be relevant to your problem but it's a good thing to be aware of anyway when using arrays.. Glenn Waldron : Pelican Mapping : +1.703.652.4791 On Thu, Feb 17, 2011 at 2:52 PM, Jean-Sébastien Guay < jean-sebastien.g...@cm-labs.com> wrote: > Hi all, > > I'm trying to draw some instanced geometry, passing a transform per > instance. I've set up a uniform array for each node I'm instancing, which > has a fixed number of values (I'm using 128 now) and that works well. > > The problem is that this way of passing data seems limited to a small > number of matrices. As I said I'm using a size of 128, so 128*16 floats, > which doesn't seem like much (8192 bytes of memory). I want to increase that > (my initial goal was about 1024 instances). But if I increase this just to > 256, I get > > Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,) > > repeatedly on the console, and my instances don't display anything > (presumably the matrices it's getting are all zeros). > > This is to be used to display small rocks as particles, so I really need > more than 128 of each rock type. One solution might be to increase the > number of rock types (so the number of drawables that will be instanced), > but I would prefer another way. > > One thing I could see to increase the number of instances I can use is to > pass less data per instance, for example a vec3 translation, a float uniform > scale and a vec4 quaternion which gives 8 floats instead of 16 per instance. > Would this work, i.e. am I right in my assumption that the problem is the > amount of data and not the number of elements in the array? > > Another solution might be a texture. In a float texture, I could pass (if I > use the same members above, so 8 floats per instance) over 2 million > instances in a 4096x4096 texture. So to get to my initial goal of 1024 > instances, I would need a 128x64 float texture, which seems manageable, and > I could potentially go much higher if I wanted to. > > I've seen an example (osguniformbuffer) that used uniform buffer arrays, > I'm not sure if this would apply to what I'm doing but the usage seems more > complicated than a uniform mat4 array, so as long as the performance > difference isn't too large I'd prefer to use those. > > Are there other ways to pass lots of data in an array to a vertex shader > that I haven't thought about? I've thought of the above options, so what I'm > asking is what other people have been using and what has worked for them. > Right now the float texture seems like the best option (especially since the > hardware we target seems fast at vertex texture fetch, which we use for > display of height fields). > > Thanks in advance, > > J-S > -- > ______________________________________________________ > Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org