godotengine / godot-demo-projects

Demonstration and Template Projects
https://godotengine.org
MIT License
5.44k stars 1.52k forks source link

OpenXR composition layer example #1080

Open BastiaanOlij opened 1 week ago

BastiaanOlij commented 1 week ago

This new example project demonstrates the new composition layer feature in Godot 4.3.

It's a direct companion to https://docs.godotengine.org/en/latest/tutorials/xr/openxr_composition_layers.html, once this is merged I'll update the documentation to reference this project.

xr_composition_layer_demo

BastiaanOlij commented 1 week ago

Working out some last wrinkles, but nearly got this working.

surreal6 commented 1 week ago

Thanks for the example project!

I was testing this and found some different behaviour in compositionLayerQuad and compositionLayerEquirect.

In pcvr i can't make Hole Punch work with compLayerQuad, but when exporting to quest2 it works. When using compLayerEquirect it works fine both in pcvr and standalone.

To reproduce, i used this sample project, duplicated the UIViewport, duplicated the Equirect, and change node type to Quad. Also duplicated the handle_pointers.gd to extend from Quad class, and assigned the duplicated viewport to the quad layer.

Here are some screenshots:

This is a Quest2 screenshot: quest2_screenshot

This is a SteamVR screenshot (valve index hmd) steamvr_screenshot

But what happens inside the valve index hmd is this: valve_index_hmd_1 valve_index_hmd_2

BastiaanOlij commented 5 days ago

@surreal6 interesting, that seems to be more a problem on the XR runtime though. On the SteamVR side we can see that the equirect on the left is using our build in fallback and only the quad is being rendered on the headset. It's showing up black because of the hole punch logic.

It looks like its doing additive blending, not alpha blending, I'm also guessing the viewport isn't setup with transparency (seeing we also have a sky) and the hole punch logic needs that. It's why I didn't add hole punch to the demo.

Interesting that on Quest the transparency isn't working, though that could be a side effect of the hole punch.

In the end, not directly applicable to this demo as I'm only showing using this feature in VR, but definitely worth raising an issue on the main Godot repo to further investigate the platform differences and whether we need to make clearer instructions or detail out the platform differences here.

Also cc @dsnopek

BastiaanOlij commented 5 days ago

Just renamed the folder so it uses underscores instead of dashes and be consistent with naming of other projects.

dsnopek commented 5 days ago

@surreal6 I don't entirely follow the screenshots above: Can you explain in my detail what you're trying to accomplish, or share a project that's fully setup?

EDIT: Nevermind! I didn't see the new issue with MRP that you uploaded. I'll check it out when I have a chance.

Interesting that on Quest the transparency isn't working, though that could be a side effect of the hole punch.

When using hole punching, you move the composition layer behind the projection layer (ie set the sort order to a negative value). This means if you make the layer transparent, then it'll show what's behind it, which is probably just black, unless you placed another composition layer even further back behind it (ie with a sort order value that was lower). One option is using an equirect layer to draw the sky, rather than Godot's sky rendering, but that's something you'd only want to do if you were 100% sure that the device supported equirect layers.