RE-SS3D / SS3D

Space Station 3D, another remake of SS13, but with an extra D.
https://ss3d.space/
252 stars 139 forks source link

Disable rendering of unseen tilemap layers #1373

Open cosmiccoincidence opened 9 months ago

cosmiccoincidence commented 9 months ago

Summary

If we cant seen them, why render them? Disable rendering of unseen tilemap layers.

Goal

If a tile and all of its 8 neighbors (4 sides + 4 corners) have an occupied "turf" layer, do not render the following layers:

stilnat commented 9 months ago

I suggest creating a "render system" for that, on the same models of other systems, specially for custom rendering. Note that occlusion culling is not an option as Unity does not support it natively for dynamic objects. Doing it efficiently is actually pretty difficult I think. An option could be the following :

Another option would be to compute a full "should render" map at game start, and update it each time a player remove or add a turf, but we should be careful with that because it involves using server data, fine if can use data already sent, less fine if we have to send some just for that.

could also imagine reducing the work load by splitting the computation over multiple frame, first checking tiles very close to player, and then the one further. Putting difficulty hard on this one.

Also since we said we're trying to use a bit more bounties, this task probably deserve one. Any other efficient solution is welcomed.

cosmiccoincidence commented 9 months ago

@stilnat outdated branch used deferred rendering, which has not been ported yet. I believe occlusion culling would be possible with that.

stilnat commented 9 months ago

So I read about deferred rendering, take my words with a pinch of salt because I do not know much about this stuff. I believe deferred rendering does not have any impact on which geometry is rendered. It's a shading screen space method, so it only cares about visible portions of objects, hence maybe the confusion, I'm not sure if this data is easily retrievable.

Also according to Wikipedia :

In the field of 3D computer graphics, deferred shading is a screen-space shading technique that is performed on a second rendering pass, after the vertex and pixel shaders are rendered.

Wikipedia clearly say the technique is used after rendering all geometry, so it should not impact at all the number of rendered vertices.

Regarding dynamic occlusion culling, Unity say this :

You can use occlusion culling to occlude Dynamic GameObjects, but Dynamic GameObjects cannot occlude other GameObjects. If your Project generates Scene geometry at runtime, then Unity’s built-in occlusion culling is not suitable for your Project.

Our turf object are dynamics, hence there's no built in Unity solution for that. From what I've read about dynamic occlusion culling, it's an open problem, there's no single fit all solution. In our case, we are lucky that our geometry is extremely simple (squares of same size), so the algorithm I suggested above might be enough.