[osg-users] pass mat4 as attribute for glsl
Garfield Pig
yuqicxy at foxmail.com
Mon Nov 26 21:27:45 PST 2018
Hi Ye Cong:
For instance rendering,You can see osgEarth::Drawinstance,they use uniform texture buffer instead of vertex attribute.
If you insist on using VertexAttribute,I guess you may inherit the osg::Geometry,and rewrite DrawImplement method,create a GLExtension to do this.
just like this:
contextID = state.getContextID();
osg::ref_ptr<osg::GLExtensions> ext = osg::GLExtensions::Get(contextID, true);
ext->glVertexAttribPointer(blabla);
ext->glVertexAttribPointer(blabla);
Finally,you can use Matrix Array uniform ,but it's a stupid way I think.
------------------ Original ------------------
From: "Cong Ye"<sirian_ye at hotmail.com>;
Date: 2018年11月27日(星期二) 中午12:58
To: "osg-users"<osg-users at lists.openscenegraph.org>;
Subject: [osg-users] pass mat4 as attribute for glsl
Hi,
I am currently working on a project requires gpu instancing. I worked out a way to do the instancing with vec4 as position attribute in. However, in the real case, instances need to be scaled/rotated/translated. Now, I want to send the transform matrix as an attribute to the shader. Normally, general opengl uses glVertexAttribPointer with offset and glVertexAttribDivisor to sperate mat4 to vec4 then pass to the shader. However, I don't find the replacement function to do the offset data structure pass. Could someone enlighten me about it, please?
thanks very much!
...
Thank you!
Cheers,
Cong
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75249#75249
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181127/4ef1d486/attachment.html>
More information about the osg-users
mailing list