godot icon indicating copy to clipboard operation
godot copied to clipboard

OpenXR: Allow composition layers to enable hole punching

Open dsnopek opened this issue 1 year ago • 2 comments

I would probably have tried to include this in PR https://github.com/godotengine/godot/pull/89880, which added the OpenXRCompositionLayer nodes, but I thought it wasn't supported by Godot's renderer, until last week @BastiaanOlij let us know about the magical shadow_to_opacity shader render mode (and fixed it in PR https://github.com/godotengine/godot/pull/91096).

This adds an enable_hole_punch property on OpenXRCompositionLayer that can enable a technique called "hole punching", which allows putting the composition layer behind the main projection layer (ie setting sort_order to a negative value) while "punching a hole" through everything rendered by Godot so that the layer is still visible.

This can be used to create the illusion that the composition layer exists in the same 3D space as everything rendered by Godot, allowing objects to appear to pass both behind or in front of the composition layer.

Anyway, given that it is a small change to a feature added in Godot 4.3, perhaps we can sneak it in?

dsnopek avatar May 02 '24 22:05 dsnopek

Gave it a try, seems to work well! If I understand correctly, enable_hole_punch will make the alpha_blend property useless. Perhaps it's worth mentioning that in the property description?

devloglogan avatar May 03 '24 16:05 devloglogan

Gave it a try, seems to work well!

Thanks for testing!

If I understand correctly, enable_hole_punch will make the alpha_blend property useless. Perhaps it's worth mentioning that in the property description?

I think it's still potentially useful, it depends on what's behind the composition layer. If there's a passthrough layer at the back, you could use alpha_blend to make the composition layer partially transparent, and show the passthrough behind it.

dsnopek avatar May 03 '24 17:05 dsnopek

@BastiaanOlij @AThousandShips @m4gr3d Thanks for the review!

My latest push has integrated all of your suggestions, except for two where I personally think the current code is fine - both are explained in my responses above.

dsnopek avatar May 07 '24 15:05 dsnopek

Thanks!

akien-mga avatar May 07 '24 19:05 akien-mga