我正在使用
Graphics.DrawMesh(mesh, _matrix, material, 0, cam);
而且我的网格太高了,所以当移动相机时,当网格在屏幕内时,它不会提前显示出来。它被淘汰了。但是当我用MeshRenderer创建一个新的游戏对象时,没有问题,它剔除得很好,并不是太早。那么这里有什么不同呢?
我试着像这样设置网格边界:
mesh.bounds = new Bounds()
{
center = Vector3.zero,
extents = mesh.bounds.extents * 1000,
max = mesh.bounds.max * 1000,
min = mesh.bounds.min * 1000,
size = mesh.bounds.size * 1000
};
它还是不起作用。
也是试试这段代码:还是不能工作...
void OnPreCull()
{
cam.cullingMatrix = Matrix4x4.Ortho(-99999, 99999, -99999, 99999, 0.001f, 99999) *
Matrix4x4.Translate(Vector3.forward * -99999 / 2f) *
cam.worldToCameraMatrix;
}
void OnDisable()
{
cam.ResetCullingMatrix();
}
发布于 2021-05-12 07:04:38
你不应该手动设置网格的边界,除非你有一些疯狂的自定义着色器,可以大幅移动一些顶点。
如果您正在使用Unity Shader,那么您应该能够调用mesh.RecalculateBounds();
,并且没有任何问题
https://stackoverflow.com/questions/67483944
复制相似问题