#Procedural Mesh With DOTS
1 messages · Page 1 of 1 (latest)
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
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
ah there's an api i think that lets you make mesh buffers from compute buffers without ever going back to the cpu
https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Mesh.GetVertexBuffer.html see the part where it says You can also use this method to make the vertex buffer available for reading or writing in a ComputeShader. and after that
and then https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Mesh.SetVertexBufferParams.html to control the vertex buffer layout and hot/cold split into streams
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?
There's also the meshdata api https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Mesh.MeshData.html which let's you use and set all the mesh data from a job, though you still have to at some point upload it on main thread
probably should like to the 22.3 one just to be safe
Updated, (was just what Google returned on phone)
I think I prefer the compute shader approach but if it doesn't work I'll try this instead
Now I just need to figure out how to instantiate my entities with empty meshes. Should I use RenderMesh components?
RenderMesh is only used in baking (in 1.0)
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)
^
RenderMeshArray is what graphics cares about now
I replaced it with a RenderMeshArray and it's still not rendering :/
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