- Home /
Entities are not rendering until the bottom left point is in camera
So I create an entity with the basic components for rendering, RenderMesh
, LocalToWorld
, Translation
, RenderBounds
.
My mesh however is fairly large (terrain chunks). I want the terrain to generate as I move the map. As it is now it seems it is waiting until the bottom left point of my Quad mesh is in view of the camera before it renders the entire mesh. However when the mesh is large that leaves a huge opening until they scroll far enough left and down to see that point. ideally it would render as soon as any piece of the mesh was in view of the camera.
Any idea how I can set the bounds where it will actually render the mesh? Like give it some info like center point and size of the mesh so it will calculate when to render it accurately?
Answer by andrew-lukasik · Feb 15 at 08:41 AM
using Unity.Mathematics;
using Unity.Rendering;
entityManager.SetComponentData( entity , new RenderBounds{
Value = mesh.bounds.ToAABB()
} );
I think you are on to something, but .ToAABB() doesn't exist for me on Bounds.
Oh, right, It requires:
using Unity.Rendering;
using Unity.Mathematics;
But this worked:
Value = new Unity.Mathematics.AABB {
Center = mesh.bounds.center,
Extents = mesh.bounds.extents
}
Your answer
Follow this Question
Related Questions
ECS - entity connection 1 Answer
How to have an array property in a component 2 Answers
Class as a member of IComponentData struct? 0 Answers