OpenXR: Allow composition layers to enable hole punching
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?
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?
Gave it a try, seems to work well!
Thanks for testing!
If I understand correctly,
enable_hole_punchwill make thealpha_blendproperty 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.
@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.
Thanks!