I'm having an issue with my camera, it is clipping one of my 3D models (cf images below).
My camera Near Clipping Planes is already at its lowest value and all my shaders have an opaque rendering mode.
It only does that with the 3D models I generated with Fuse CC. The one I did with Blender don't clip! Any ideas? Thanks!
The actual problem seems to be that your models' bounds are not correct. Frustrum culling allows your GPU to skip rendering models that are out of sight by testing their bounds against the camera frustrum. This is important if you want good rendering performance. So just disabling it is not the best idea, if it is only to work around a simple issue like incorrect bounds.
If you select your mesh renderer in the scene, you should see it surrounded by a wireframe cube. That cube visualizes your meshs bounds. You should see them fit quite well on your Blender models, and be way off on your Fuse CC models.
Once you've verified that your Fuse CC models' bounds are off, you can try and fix them manually or by changing the import settings.
Reasons why the bounds can be off:
All of these can be fixed by adjusting the bounds on your mesh in the editor so that they leave enough room for your runtime animations/modifications.
The bounds are chosen well, when all of the following are true:
Thanks to Draco18s who led me to frustrum culling. I found this post that demonstrates how to deactivate frustrum culling on a particular gameobject and my issue is solved! The script is a little bit out of date so here is the updated version.
// Update is called once per frame
void Update () {
// boundsTarget is the center of the camera's frustum, in world coordinates:
Vector3 camPosition = Camera.main.transform.position;
Vector3 normCamForward = Vector3.Normalize(Camera.main.transform.forward);
float boundsDistance = (Camera.main.farClipPlane - Camera.main.nearClipPlane) / 2 + Camera.main.nearClipPlane;
Vector3 boundsTarget = camPosition + (normCamForward * boundsDistance);
// The game object's transform will be applied to the mesh's bounds for frustum culling checking.
// We need to "undo" this transform by making the boundsTarget relative to the game object's transform:
Vector3 realtiveBoundsTarget = this.transform.InverseTransformPoint(boundsTarget);
// Set the bounds of the mesh to be a 1x1x1 cube (actually doesn't matter what the size is)
SkinnedMeshRenderer mesh = this.GetComponent<SkinnedMeshRenderer>();
mesh.localBounds = new Bounds(realtiveBoundsTarget, Vector3.one);
}
Place this script on the GameObject which is causing problem.
Note: Replace SkinnedMeshRenderer by the mesh renderer type your gameobject is having.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With