my game is a planet that rotates and revolves around a star and you can walk on the planet and explore. however, the biggest problem is the lag. just looking at the ground immediately lowers fps to 0.5 (normal is around 60) since all the surface scatters are still being rendered through the ground. an easy fix for this would be occlusion culling; however, since the occluder (planet) is moving, it's just not possible. i've also tried with occlusion areas but that didnt work either and i also tried implementing a "render distance" to the camera but then the moon and sun wouldnt be visible. any feedback would be greatly appreciated!
#Dynamic Occlusion Culling
1 messages · Page 1 of 1 (latest)
Are you taking advantage of LODs? (Levels of Detail). You should always be using a more simplified mesh if you still want it to be visible at a distance.
already implemented that a while ago
never heard of that thanks for the tip
Planets tend to be predictable shapes, so it wouldn't be difficult to compare whether their renderer bounds are behind the planet origin and closer to the origin than the planet radius from the camera's point of view
GPU occlusion culling would take care of that though
It likely helps to split the planet surface into tile meshes, so parts of the planet can be culled individually and can have their own LODs too
you seem to be missing the point here; its not that the planet is not spherical; its that it is orbiting the star. (moving very fast)
How's that a problem for what I suggest?
because the planet is MOVING and you cant have MOVING occluders
Who said you can't?
If you use the unity cpu occlusion culling solution, sure, you can't. But I think Spazi was talking about a simple custom occlusion culling logic.
and how would that even work?
In the simplest form, check if the target object bounding box is behind the planed bounding box relative to the camera. A naive solution would be to cast rays from the camera towards the object. And disable it, if the ray hits the planet.
There numerous optimizations that can be done, but that's beside the point.
ohhhhhhhhhhhhhhh thanks for clearing that up
okay i solved it with selective layer culling. i basically attatched this script to the camera to cull scatters that are too far away
public class renderDistance : MonoBehaviour
{
// set render distance on setup
void Start() {
Camera camera = GetComponent<Camera>();
float[] distances = new float[32]; // importing layers and other stuff
distances[7] = 100f; // scatters layer (7) and render distance
camera.layerCullDistances = distances;
}
// not used here
void Update()
{
}
}
Yep. That's a valid solution too. And it can be used with the other one too.