Mesh Ignore Camera MaxZ

Dear Community,

I am a bit perplexed by the behavior of meshes having ignoreCameraMaxZ set to true.

Firstly: In the PG provided, I expect that meshes having ignoreCameraMaxZ set to true will always render, however they don’t after some distance from the camera. Why?

Secondly: In the PG provided, I expect the meshes having ignoreCameraMaxZ set to true to be properly depth sorted and be visually occluded as normal by other meshes, however this is not the case. Why?

Hi! Let me investigate this

1 Like

After discussing with @carolhmj I agree the behavior is somehow unintuitive.

ignoreCameraMaxZ only changes the transform matrix of the camera to prevent clipping on the GPU.

It does not interfer with mesh selection and clipping. As it is mostly to be used with skyboxes, it is never culled. In your case you can use alwaysSelectAsActiveMesh to prevent clipping.

We do not do it automatically to prevent bloating the mesh selection which is one of the bottleneck with too many edge case as it should in theory still clip on x and y but z.

About the second point, It might be a side effect of pushing everything on z.

May I ask why you are trying to rely on this feature to see if there could be a better way ?


Thank you @sebavan ! In one of our environments which has a large span in world space, we would like to have certain meshes, such as prominent buildings, the ground, and far away clouds (not from sky box, by design, but meshes), always fully visible unless fully or partly occluded by another mesh. Other meshes such as small bushes, outdoor seating, and such we want to be culled due to the camera’s maxZ setting.

1 Like


You have the occlusion queries to do this, without needing camera MaxZ setting. Any meshes : bushes, seat, etc would be obscured.

Otherwise, you can use the LOD to make the mesh not visible at a certain distance (with setEnabled)

1 Like

Yes, the transformation matrix is not the same when the far plane is at infinity, so the depth values are different than when ignoreCameraMaxZ is not used. This means that you cannot mix objects with this flag set and others with the flag not set, unless the objects do not write to the depth buffer (like a skybox).

1 Like

Thanks @Dad72 . We do use occlusion queries.

We should add that to the docstring then as a general recommendation. Maybe something like “intended for use only for objects that don’t write to the depth buffer, like skyboxes”?

Yes, but the other valid use case would be to set this flag for all objects. That way, even if they write to the depth buffer, it still works because they all use the same type of transformation matrix.

I will update the docs.



Thanks for this @Evgeni_Popov !

Is there a way to designate only certain objects should be rendered beyond the camera’s max z setting?

That’s what ignoreCameraMaxZ=true is for? You should also set alwaysSelectAsActiveMesh=true so that they are not culled on the CPU side.

1 Like