playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.66k stars 1.35k forks source link

Refactor Webgl's use of the default frame buffer #4281

Closed mvaligursky closed 1 year ago

mvaligursky commented 2 years ago

This is the current implementation:

Limitations:

Suggested implementation:

Possible complication:

mvaligursky commented 2 years ago

From what I can see, there are two ways XR interacts with the depth:

  1. depth / depth-sending feature. From those XR APIs we get depth data in raw format, which can then be uploaded to a texture / texture used to render into the depth buffer. This should work without any changes.
  2. When XR is initialized, a XRWebGLLayer is created, which gives us color / depth/ stencil framebuffer, which can be then set on a WebGL to be used as the default framebuffer. When XRWebGLLayer is created, an option ignoreDepthValues can be specified. If its set to false, the default frame buffer needs to output depth as well, which is not what the proposal wants to use. So in this case, we would likely need to allocate a single sampled depth attachment as well, and resolve / shader-copy depth to it.
mvaligursky commented 1 year ago

This is now done in #5628, closing