Can I disable culling

Hi,

I ran into a problem: Unity decides to cull one of my objects event if part of that object is still in camera view (I can see it clearly in scene view). It’s a skinned mesh and one of the bones and part of the mesh is still in view. I’m not doing any custom shader stuff.

Is there a way to force Unity to render my object? Disable culling or expand bounding box or something like that?

set your near clipping plane on the camera in question to a low value like 0.01 and it might solve this problem

or increase it’s field of view

Turn on “Update when offscreen” on the skinned mesh renderer.

–Eric

1 Like

Thanks! That solved my problem!

@Eric5h5 Sorry for bumping a very old thread, but your answer was very on spot for what I need and thus I might not mess the forum with an uncessary new thread. So, is there an equivalent to that option for a simple mesh, that can be activated via script? Thanks!

Is this a procedural mesh? If its being culled then you probably need to update the Bounds.
http://docs.unity3d.com/ScriptReference/Mesh-bounds.html

5 Likes

Many thanks for your reply! That is the exact problem: it is procedural. But the issue is that vertices change frequently and I keep having to update Bounds all the time, incurring in unnecessary costs. Also, think of meshes that are only used to convey shader code: they can be culled out even if a shader is set to overlay. There should be a simple option to mark objects to be rendered anyways, just like there is this option to update animations of skinned meshes no matter if they are offscreen.

Or even better, there should be a simple flag in the GameObjects or in the MeshFilter components to set them to either not be culled or even to not be tested for culling, in the case we already know they are visible.

You don’t need to calculate the bounds, just set it to a really high value.
By default no bounds are calculated when its only vertices so assign a value to it once and you should be fine.

The problem is: in one of my procedural meshes that are giving me culling issues, vertices are updated all the time. Sometimes vertices are added or removed. When that happens, one needs to redefine the indices of the vertices. And that requires a new recalculation of the bounds. While the mesh has low number of vertices, it’s fine. But if the number of vertices is high, redefining bounds gives an unnecessary burden on the processing of the procedural mesh

You dont need to calculate the bounds. Just assign a large value that will encompass all the verts. This will give you a mesh that is always rendered.

mesh.bounds = new Bounds(transform.position, new Vector3(float.MaxValue, float.MaxValue, float.MaxValue));
1 Like

Ah, I see what you mean. Great idea, makes sense. So it’s all about performing that every time a mesh.SetIndices(indices, MeshTopology.Points, 0) is called again to update the vertices. Much faster, since it’s no more than an assignment of a new Vector3.

Problem solved! In any case, here you have my plea that in the future objects could have an option to disable frustum culling checks on them. Would be cleaner and even improve performance in some cases. Anyways, thanks for the tips!

1 Like

Give it a vote https://feedback.unity3d.com/suggestions/please-add-the-ability-to-disable-automatic-culling-on-particle-systems or maybe create a new one that is not particle specific.

Aha maybe this one https://feedback.unity3d.com/suggestions/ability-do-disable-view-frustum-culling-for-chosen-game-objects

1 Like

Excellent that someone has already put that there! And I completely agree with the arguments presented by both. Now, the question becomes: is it better to vote for the one with 42 votes but which was raised in the particles context, or to the very recent one that is more general but pretty much does not have votes?

I don’t know :face_with_spiral_eyes:
I investigated allowing custom culling to the particle system earlier in the year and we deiced at the time that it was not worth it. The performance gain was minute and the space for mistakes was huge. So maybe add it to the more generic one :slight_smile:

1 Like

@karl_jones Thanks for all the info! Voted on the second link. Hope that at some point you guys reconsider it for the more general non-particle cases. Having a flag to determine which objects are view frustum tested would be awesome…

Hey everyone, sorry for reviving old thread :smile:

I tried doing that to one of my meshes, and it worked, no frustum culling anymore! But I’m getting a lot of “Expanding invalid MinMaxAABB” errors.

Why does that happen (did I break my mesh internally?)? Should I look for a sweetspot of size for the bound box that will solve the issue and don’t give me the error?

Thanks for the replies so far guys.

Have a wonderful day :slight_smile:

Another question on the same matter.

I have Sprites and World Canvas on the scene, those don’t have Mesh Filters how can I fix for those cases ?

Did you ever figure this out, Roiw? I’m running into the same problem with 3D text.

It’s been so long ago I can’t quiet remember what I did… Your problem is that your Sprite is disappearing from your world space canvas?

Yes. A few different things in my scene are being moved by a vertex shader and they disappear at certain camera angles. For the objects that have mesh filters, I can easily fix the problem by setting the mesh bounds to something large. However, I can’t figure out a way to solve to problem for text since it has no mesh filter for me to adjust mesh bounds with. Any help would be greatly appreciated!