[x3d-public] How to implement glTF EXT_mesh_gpu_instancing?!

John Carlson yottzumm at gmail.com
Tue Apr 23 18:39:34 PDT 2024


>From what I saw of X_ITE code, I could create a particle systems physics
model that could use one or more variables in a shader to introduce
parameters.  But I don’t know if the physics model is for all instances or
one instance, so I’m questioning if this is possible.

It would seem like x3d_ParticleMatrix is at an instance level, along with a
couple of other variables.

Maybe something like an InstancedShape could be used instead of a particle
system.

Say the object i want to morph is a sphere, and I have an SFVec4f per
sphere.  I can use rotations for the other 2 variables.

This seems much more doable than a particle system.

But I would also like to use a ParticleMatrix to position the instance or
particle in space.

Feedback welcome!

John

On Sun, Apr 21, 2024 at 10:23 AM John Carlson <yottzumm at gmail.com> wrote:

> Makes me wonder if I could target individual instances using a new
> attribute or field, “toIndex” on ROUTEs, targeting a particular
> translation, scale or rotation in an MF field of InstanceShape.
>
> Sorry for spew of emails.
>
> John
>
> On Sun, Apr 21, 2024 at 6:36 AM Holger Seelig via x3d-public <
> x3d-public at web3d.org> wrote:
>
>> How to implement glTF EXT_mesh_gpu_instancing?!
>>
>> When looking through the glTF sample models, sooner or later you will
>> stumble across an example and this extension.
>>
>>
>> https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
>>
>> https://github.com/KhronosGroup/glTF-Sample-Models/tree/main/2.0/SimpleInstancing
>>
>> The simplest idea to implement this, which I did, was to generate a lot
>> of Transform nodes (one for each instance) and clone the shapes or geometry
>> nodes. But this runs counter to the name of the extension (GPU). Especially
>> if you create thousands of transform nodes for a shape with a geometry with
>> only a few polygons. The extension is made to clone a lot of objects, e.g.
>> a leaf on a tree, which then reappears in many places on the tree, only
>> with different transformations, and everything should be calculated in one
>> pass by the GPU.
>>
>> The second idea I had was to somehow incorporate the transformations
>> (translation, rotation, scale) for each instance into the X3DGeometryNode
>> nodes. However, this would have meant changing all of these nodes. So I
>> discarded this for the time being and postponed it.
>>
>> Then I came up with the idea of why add it to the geometry nodes when you
>> could invent a new shape node. So the idea of "InstancedShape" grew:
>>
>> Documentation of InstancedShape in X_ITE with example at the bottom of
>> the page (2500 instances, 2,160,040 triangles):
>> https://create3000.github.io/x_ite/components/x-ite/instancedshape/
>>
>> InstancedShape : X3DShapeNode {
>>    # ... inherited fields
>>    MFVec3f [in,out] translations [] #
>>    MFRotation [in,out] rotations [] # list of rotations, one for each
>> instance
>>    MFVec3f [in,out] scales [] # list of scales, one for each instance
>>    # List of translations, rotations, scales; one for each instance.
>>    # If only one value is provided, it is provided to each instance
>> equivalently.
>> }
>>
>> The advantage is that the geometry nodes do not have to be changed, and
>> the same functions could be used to implement these nodes that were already
>> available for ParticleSystem nodes with some trivial additions.
>>
>> Examples to see InstancedShape node in action, all files are in glTF or
>> GLB format converted to X3D:
>>
>> Simple Instancing (125 instances, 1,500 triangles):
>>
>> https://create3000.github.io/x_ite/playground/?url=https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/SimpleInstancing/glTF/SimpleInstancing.gltf
>>
>> Teapots Galore (958 instances, 7,725,314 triangles):
>>
>> https://create3000.github.io/x_ite/playground/?url=https://raw.githubusercontent.com/KhronosGroup/glTF/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/samples/teapots_galore/teapots_galore.gltf
>>
>> Fur Instancing (10,000 instances, 3,200,000 triangles):
>>
>> https://create3000.github.io/x_ite/playground/?url=https://create3000.github.io/media/glTF/FurInstancing/FurInstancing.glb
>>
>> 3D Tiles (10 instances, 120 triangles):
>>
>> https://create3000.github.io/x_ite/playground/?url=https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/glTF/GpuInstancesMetadata/GpuInstancesMetadata.gltf
>>
>> Forest (100 instances, 21,400 triangles):
>>
>> https://create3000.github.io/x_ite/playground/?url=https://raw.githubusercontent.com/bertt/cesium_3dtiles_samples/master/samples/1.1/forest/forest.glb
>>
>> How do you do that, do you? Maybe we could consider this for a future X3D
>> version.
>>
>> Make X3D even better!
>> Best regards,
>> Holger
>>
>> --
>> Holger Seelig
>> Leipzig, Germany
>>
>> holger.seelig at yahoo.de
>> https://create3000.github.io/x_ite/
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240423/6135c6a6/attachment.html>


More information about the x3d-public mailing list