[osg-users] Draw geometry on demand

Tyler Durden mynewphoneaaaa at gmail.com
Fri Jun 15 07:07:26 PDT 2018


Hi,

Sorry for my late answer.
Forget about my last question.
What i'm trying is to use a single mesh to draw a terrain in a quadtree.
I want reuse same geometry over quadtree's nodes.

My problem is to use a single grid mesh (only x-y plane, because i use
Vertex texture fetch on vertex shader to sample heights from a Texture2D).
For this purpose i'm using geometry instancing, by invoking setNumInstances of DrawElementsUInt class.
My problem now is to add some vertex attribute to shader capable to 
distinguish from geometry instance.
For this purpose i'm using 



Code:

osg::StateSet* ss = new osg::StateSet();
ss->setAttribute(new osg::VertexAttribDivisor(index,1));



where index is the slot of a particular vertex attribute.
If i have 4 instances of a geometry, how many time i have to invoke setAttribute for 4 different values? 4 times?

Thank you! 

Cheers, 
Tyler

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74081#74081







More information about the osg-users mailing list