Hi J-S.

There one more point about available data size if you are using uniform arrays 
or uniform buffers:
you should pack your data into vec4's if it possible, cause uniforms counts 
towards max size with some kind of slots, with one slot taking storage size of 
vec4; if you declare your uniform as "uniform float[size] a;" it can takes 
"size" slots therefore wasting 3*size floats of memory, same with all types 
that less components than 4. Its ok with 4x4 matrices, and with 3x3 matrices 
you waste 3 floats per matrix. If you use uniform blocks - there are same thing 
to some extent, as data inside block is aligned and padded.

About texture buffers:
If you generate data for your instances on cpu side there are no point in using 
texture buffers actually. They pretty much same as 1D textures, except there 
are no filtering in them, they can fit more data and u access them in shaders 
with integer index (with texelFetch). They are useful if you generate data on 
gpu side with transform feedback, and you need more storage than uniform 
buffers. You still can use plain textures in latter case, just writing to your 
texture with fragment shaders instead of using transform feedback, tho this is 
a bit tricky.

Cheers,
Sergey.

18.02.2011, 06:57, "Jean-Sébastien Guay" <[email protected]>:
> Hi Sergey,
>
> Thanks for your guidance. The data I need per drawable might fit in 16k
> floats per drawable. I need a transform and a color, but the transform
> will always have a uniform scale, so that's:
>
> - 3 floats for translation
> - 4 floats for rotation quaternion
> - 1 float for uniform scale
> - 4 floats for color
>
> = 12 floats.
>
> I could probably easily pack the color into one 32-bit integer (8 bits
> each for R, G, B, A) and then extract the colors into a vec4 in the
> shader, so that would save an extra 3 floats.
>
> So without doing anything really esoteric like packing multiple floats
> into one, my data would fit in 9 floats. So that would be about 1777
> instances' worth of data, if I have access to 16k floats.
>
> When you mentioned using texture buffers for dynamic data, what does
> that mean? I would have just used a regular float texture which I fill
> with the float data each frame. What are texture buffers and how do they
> differ from this? Is there an OSG example that shows how to use them?
>
> Thanks again,
>
> J-S
>
> --
> ______________________________________________________
> Jean-Sebastien Guay    [email protected]
>                                http://www.cm-labs.com/
>                         http://whitestar02.webhop.org/
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to