godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.03k stars 21.18k forks source link

Gridmaps do not render when using Rooms and Portals System #60833

Open GDelavy opened 2 years ago

GDelavy commented 2 years ago

Godot version

3.4.2 stable official (45eaa2daf)

System information

Windows 10, GLES 3, Nvidia Geforce 1660 Ti (30.0.14.7168)

Issue description

Steps to reproduce

Minimal reproduction project

Gridmap Culling.zip

lawnjelly commented 2 years ago

Yes, that's a known limitation, gridmaps aren't currently supported (unless you can e.g. bake them out to regular nodes). We should probably make a note of this in the docs.

It probably could be made to work to an extent, but it would be nicer to be able to have portals / rooms etc as part of the gridmap (rather than the gridmap in a room), and that would be quite complex to get working.

GDelavy commented 2 years ago

Thank you for the quick reply,

Is there any way to tell the Portal / Rooms system to ignore gridmaps? Even if I put the gridmap node outside of my room node, it doesn't render.

Alternatively, I've tried using the Occluder node to surround my gridmap, but the only OccluderShape available seems to be spheres. Is there a way for me to add cubes or planes or convex shapes instead?

I apologize for the many questions, but my entire project relies on gridmaps and I really don't know what I'm going to do if I don't find a workaround

Calinou commented 2 years ago

Alternatively, I've tried using the Occluder node to surround my gridmap, but the only OccluderShape available seems to be spheres. Is there a way for me to add cubes or planes or convex shapes instead?

3.5beta4 has occluder polygons available, so you can use it to represent quads, boxes and the like.

I apologize for the many questions, but my entire project relies on gridmaps and I really don't know what I'm going to do if I don't find a workaround

Since you're using GLES3, remember that the depth prepass is already significantly reducing the rendering cost of overdraw. Opaque pixels are only shaded once thanks to the depth prepass. While occlusion culling will help speed up this depth prepass, it probably won't give you a massive performance boost as it can in GLES2 (assuming the level design lends itself well to occlusion culling).

Therefore, it's probably not the end of the world if you can't use occlusion culling – especially if your level doesn't offer much opportunity for occlusion culling. Level of detail is likely a more viable approach in this case, and it'll show significant benefits in GLES3 too.

GDelavy commented 2 years ago

Thank you so much for all the help, I really appreciate all the work you do!

I'm going to look into implementing Lod and also experiment with 3.5beta4 to see if occluders make a significant difference. Thank you again!

Calinou commented 2 years ago

Reopening, as this limitation should still be documented.

lawnjelly commented 2 years ago

To elaborate a little - the problem stems because the gridmap is rather special - it completely overrides the scene tree, and does everything itself internally. Whereas the room conversion code is based on, and assumes, a scene tree structure. So gridmap would probably need custom conversion code written to traverse it during the room conversion, and additionally it has no machinery for setting the portal mode. There would likely be other problems as a result of it not being part of the scene tree. This is not trivial, it may represent weeks of work, and would require testing etc.

A far more practical approach would be to simply bake the gridmap into normal scene tree nodes containing meshes and multimeshes. The result could then be processed as normal during room conversion. I don't know whether this functionality exists already, or perhaps someone enthusiastic could write this. But this is not really a "portals" problem, it could probably be written by anyone who is familiar or who wants to get familiar with gridmap.

It is also possible that the gridmap objects might show up by changing their portal mode to global in the gridmap c++ code where it creates the instances. They would not be occlusion culled though.