Hi Nick, There is nothing special in the contents of the buffers. They are just arrays like vertex array. Special is the definition as buffer objects and "overlaying" them with a texture like shown in my code. In the shader you have the instance ID and from that you access the meshlet info via the 1D texture. Get your operation parameters from there and fetch vertices, normals, colors etc. also via the textures. The only difficulty is the size limit of the textures. So you eventually have to split the arrays. That's it. Werner
On 24. Mai 2022 22:59:52 MESZ, Trajce Nikolov NICK <[email protected]> wrote: >Hi, > >I am also researching this subject. Have you succeeded? Any hints about >the >meshelts buffer objects? Any other hints? > >Thank you a bunch for any shared info! > >Nick > >On Wed, May 11, 2022 at 5:35 PM DC <[email protected]> >wrote: > >> Thanks Werner! >> This will certainly help me get started. >> >> Much appreciated, >> DC >> >> On Wednesday, May 11, 2022 at 4:13:08 AM UTC-5 Werner Modenbach >wrote: >> >>> Hi DC, >>> >>> here is the link: >https://github.com/nvpro-samples/gl_vk_meshlet_cadscene >>> This should help you with items 1) and 2) >>> >>> For item 3) see my code below. >>> The way I assign the data structures in OSG is like that: >>> >>> // ---------------------- >>> // Create Meshlet primitive // ---------------------- >>> >_geode->getOrCreateStateSet()->getOrCreateUniform(TASK_INVOCATIONS_PER_MESHLET, >osg::Uniform::INT)->set(taskInvocationsPerMeshlet); >>> >>> osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry; >>> >>> osg::ref_ptr<osg::ProxyPrimitive> proxyPrimitive = new >osg::ProxyPrimitive; >>> >>> proxyPrimitive->drawMeshTasks = new osg::DrawMeshTasks(0, >workgroupsInGeometry * taskInvocationsPerMeshlet); >>> >>> geometry->setUseDisplayList(false); >>> >>> geometry->addPrimitiveSet(proxyPrimitive.get()); >>> >>> _geode->addChild(geometry); >>> >>> // ---------------------- >>> // Vertices >>> >>> // ---------------------- >>> >>> osg::ref_ptr<osg::Vec4Array> osgVertices = new >osg::Vec4Array(toCopy); >>> >>> for (auto i=0; i<toCopy; ++i) { // fill array // Fill >buffer >>> } >>> >>> // Create Buffer and Texture >>> >>> osg::ref_ptr<osg::VertexBufferObject> verticesBufferObject = new >osg::VertexBufferObject(); >>> >>> verticesBufferObject->setUsage(GL_DYNAMIC_READ_ARB); >>> >>> osgVertices->setBufferObject(verticesBufferObject.get()); >>> >>> osg::ref_ptr<osg::TextureBuffer> vertexTexture = new >osg::TextureBuffer(osgVertices.get()); >>> >>> vertexTexture->setInternalFormat(GL_RGBA32F_ARB); >>> >>> >vertexTexture->setInternalFormatMode(Texture::USE_USER_DEFINED_FORMAT); >>> >>> >stateSet->setTextureAttributeAndModes(MESH_VERTEX_ARRAY_TEXTURE_UNIT, >vertexTexture.get()); >>> >>> // ---------------------- >>> // MeshletInfos >>> >>> // ---------------------- >>> >>> osg::ref_ptr<Vec4uiArray> MeshletInfosArray = new >Vec4uiArray(workgroupsInGeometry); >>> >>> int startVertex = 1; >>> >>> int anzahl = _anzahlVertices; >>> >>> for (auto i=0; i<workgroupsInGeometry; ++i) { >>> >>> (*MeshletInfosArray)[i][0] = startVertex; >>> >>> (*MeshletInfosArray)[i][1] = min(TS_WORKGROUP_SIZE, anzahl); >>> >>> startVertex += TS_WORKGROUP_STEP; >>> >>> anzahl -= TS_WORKGROUP_STEP; >>> >>> } >>> >>> // Create Buffer and Texture >>> >>> osg::ref_ptr<osg::VertexBufferObject> meshInfosBufferObject = >new osg::VertexBufferObject(); >>> >>> meshInfosBufferObject->setUsage(GL_DYNAMIC_READ_ARB); >>> >>> MeshletInfosArray->setBufferObject(meshInfosBufferObject.get()); >>> >>> osg::ref_ptr<osg::TextureBuffer> meshInfosTexture = new >osg::TextureBuffer(MeshletInfosArray.get()); >>> >>> meshInfosTexture->setInternalFormat(GL_RGBA32UI_EXT); >>> >>> >meshInfosTexture->setInternalFormatMode(Texture::USE_USER_DEFINED_FORMAT); >>> >>> >stateSet->setTextureAttributeAndModes(MESH_INFOS_ARRAY_TEXTURE_UNIT, >meshInfosTexture.get()); >>> >>> >>> // ---------------------- >>> // Create and assign the Task- and Mesh shader as usual by using >the corresponding shader type // ---------------------- >>> >>> >>> Am 10.05.2022 um 21:20 schrieb DC: >>> >>> OK. Thank you. >>> >>> On Tuesday, May 10, 2022 at 12:59:37 PM UTC-5 Werner Modenbach >wrote: >>> >>>> Hi DC, >>>> I think we should clarify some aspects before going into the >details. If >>>> I understand well, your problem can be split into 3 parts >>>> 1) You want to convert an existing model into meshlets. This is not >>>> related to OSG. But I found a git repository from NVIDIA doing this >job. I >>>> will lookup the link and send it to you tomorrow. >>>> 2) For this to work you need task/mesh shaders doing their job on >the >>>> GPU. This is also not related to OSG. Maybe you find some starting >point in >>>> the repository as well. >>>> 3) You need to know how to load your shader and how to setup the >data >>>> structures in OSG. I hope I can help you with that by providing >some code >>>> snippets. >>>> Just let me know when you are ready for that step. But the code I >>>> provided already should help you. >>>> Werner >>>> >>> -- >> You received this message because you are subscribed to the Google >Groups >> "OpenSceneGraph Users" group. >> To unsubscribe from this group and stop receiving emails from it, >send an >> email to [email protected]. >> To view this discussion on the web visit >> >https://groups.google.com/d/msgid/osg-users/7680959c-297e-41ff-9159-464b38c8df73n%40googlegroups.com >> ><https://groups.google.com/d/msgid/osg-users/7680959c-297e-41ff-9159-464b38c8df73n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > >-- >trajce nikolov nick > >-- >You received this message because you are subscribed to the Google >Groups "OpenSceneGraph Users" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to [email protected]. >To view this discussion on the web visit >https://groups.google.com/d/msgid/osg-users/CAO-%2Bzine4AtqdBor-0XH-fE1aCr4_%3DocD73OFErsf%2Bh-kDFgBg%40mail.gmail.com. -- You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/eb4531f5-3420-4c75-be46-539490c5c659%40email.android.com.
