#Procedural Mesh With DOTS

1 messages · Page 1 of 1 (latest)

tender timber
#

I'm working on a procedural terrain system and I'm stuck on the part where I need to add the triangles I calculated to a mesh. I prefer a pure DOTS solution to avoid creating too many GameObjects for my meshes.

sullen wasp
#

accessing the actual Mesh object is not burstable, but there's a fancy-pants api to let you create and access vertex and index buffers with burst & jobs

tender timber
#

Which API?
Also, it's fine if it isn't burstable, I mainly do this to work with entities instead of gameobjects. Most of the optimization in the generation system comes from the compute shaders

sullen wasp
#

ah there's an api i think that lets you make mesh buffers from compute buffers without ever going back to the cpu

tender timber
#

I'll try to use these to add the generated triangles.
But going one step back, when I'm initializing my entity, how do I add a mesh to it?

dire marsh
sullen wasp
#

probably should like to the 22.3 one just to be safe

dire marsh
#

Updated, (was just what Google returned on phone)

tender timber
#

Now I just need to figure out how to instantiate my entities with empty meshes. Should I use RenderMesh components?

dire marsh
#

RenderMesh is only used in baking (in 1.0)

tender timber
#

Which component should I use instead? this is my current setup: ```
entityCommandBuffer.AddComponent(entity, new LocalToWorld
{
Value = float4x4.identity
});

            entityCommandBuffer.AddComponent(entity, new RenderBounds()
            {
                Value = new AABB
                {
                    Center = new float3(0, 0, 0),
                    Extents = new float3(chunkSizeWorldUnits, chunkSizeWorldUnits, chunkSizeWorldUnits)
                }
            });

            entityCommandBuffer.AddSharedComponentManaged(entity, new RenderFilterSettings
            {
                Layer = 0,
                RenderingLayerMask = 1,
                MotionMode = MotionVectorGenerationMode.Object,
                ShadowCastingMode = ShadowCastingMode.On,
                ReceiveShadows = true,
                StaticShadowCaster = false
            });

            entityCommandBuffer.AddSharedComponentManaged(entity, new RenderMesh
            {
                mesh = mesh,
                material = material
            });
The mesh is being generated properly but it doesn't get rendered in the scene (I can see the mesh in the inspector)
dire marsh
#

RenderMeshArray is what graphics cares about now

tender timber
#

I replaced it with a RenderMeshArray and it's still not rendering :/

dire marsh
#

i think you're missing a bunch of stuff tbh

#
ComponentType.ReadWrite<WorldRenderBounds>(),
ComponentType.ReadWrite<RenderFilterSettings>(),
ComponentType.ReadWrite<MaterialMeshInfo>(),
ComponentType.ChunkComponent<ChunkWorldRenderBounds>(),
ComponentType.ChunkComponent<EntitiesGraphicsChunkInfo>(),
ComponentType.ReadWrite<WorldToLocal_Tag>(),
ComponentType.ReadWrite<RenderBounds>(),
ComponentType.ReadWrite<PerInstanceCullingTag>(),
ComponentType.ReadWrite<RenderMeshArray>(),
ComponentType.ReadWrite<LocalToWorld>(),

ComponentType.ReadWrite<BlendProbeTag>(),
ComponentType.ReadWrite<CustomProbeTag>(),
ComponentType.ReadWrite<DepthSorted_Tag>()```
these are like all the components that can exist (bottom 3 probably not needed)
#

it is not recommended to set this up manually like that

#

at least use the util