-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Add OccluderShapePolygon #57361
Conversation
261db2d
to
b85c8e2
Compare
Does this PR supersede #52347? |
b85c8e2
to
e21fd0d
Compare
Yes I'll close that as the new PR for meshes will be quite a bit different. |
a87356f
to
9115f15
Compare
core/error_macros.h
Outdated
@@ -426,6 +427,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li | |||
#define CRASH_NOW() \ | |||
if (true) { \ | |||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed."); \ | |||
_err_flush_stdout(); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, though it could have been better suited in a dedicated PR (and it should be fixed in master
too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes this crept in because it was downsized from a larger PR, and doing the flush here was very obviously needed during development as otherwise it crashes before we see the error messages.
Can move this to a separate PR if desired, and will do one for 4.x as it will be good to fix there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed this now to go in separate PR.
We avoid shortening identifiers in the API, and this likely shouldn't be an exception either, so it should be |
Will change, should just be a search and replace. 👍 |
bdb1dc6
to
fd9bf73
Compare
fd9bf73
to
e528604
Compare
Add OccluderShapePolygon, glue to Occluder and gizmos etc.
e528604
to
8ea20f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Thanks! |
Add OccluderShapePolygon, glue to Occluder and gizmos etc.
Working in a similar way to the OccluderShapeSphere, the polygon occluder allows specifying convex polygon occluders. They are considerably more versatile than spheres, as they fit to many more level designs.
These can be edited in a similar fashion to Portals, by dragging handles for points, and specifying the orientation using the Node transform.
Additionally each polygon can have a single "hole". I've used the name hole to distinguish from portal, which has a very specific meaning in the Room system, and it would be confusing having two things with the same name, although they perform an analogous function.
Notes
The occluder polygons require considerably less manual setup than rooms & portals, they can be added to a game level in a matter of minutes (although you may want to spend longer tuning their position etc to get the best results).
The flipside, as with occluder spheres, is that they only operate to cull objects from rendering. They do not yet affect VisibilityEnablers (although that may be added in a later PR), and they cannot be used to throttle performance in the way that rooms can.
As with Occluder spheres, they can be used dynamically, although changing the transform of the poly is considerably cheaper than changing the points of the poly itself. This should match most use cases though.
2022-01-28.17-04-16.mp4
Main desert map from "Wrought Flesh" - by Miziziziz
2022-01-30.14-55-51.mp4
Under the hood
The poly occlusion engine is fairly intricate. It first has to transform polys into screen space in order to provide a screen space metric for goodness of fit of each poly according to screen area. Larger and closer polys, that are facing the viewer are ranked higher. The best 8 (by default) polys are chosen as occluders, in order to make the best use of processing. The max active polys can be changed via a project setting as with spheres.
Once the polys are identified, they are clipped against each other. Polys (and holes) that are obscured by closer polys can be removed at this stage. Culling planes are precalculated for each polygon and hole.
Finally at runtime AABB of objects can be tested against these culling planes rapidly.