engine icon indicating copy to clipboard operation
engine copied to clipboard

Further SceneDepth refactoring / changes needed

Open mvaligursky opened this issue 3 years ago • 1 comments

A follow up for this could be done in the future: https://github.com/playcanvas/engine/pull/3132

Issues and possible solutions:

  1. Internally requestDepthMap() is used to request depth texture, which enables the depth layer. The problem is that the depth layer is added to cameras by default, and so when multiple cameras are used, all of them render depth to texture. This should be done similarly to how postprocessing is integrated to Layer Composition. When postprocessing is required for the camera, a property on CameraComponent is set. LayerComposition adds flag to RenderActions and callback executes from ForwardRenderer.

  2. SceneDepth currently uses device.width and height for render targets. This is not very compatible with using depth as part of post processing on a camera that renders to a texture with different size. Solution for issue 1 would solve it by handling it per camera.

  3. we could support option to render the the depth map before the camera renders, allowing SSAO to run ahead of time and be useable in main lighting pass. This would also prime the depth buffer on webgl2 platform to limit overdraw to gain some performance on heavy shaders.

mvaligursky avatar Apr 29 '21 11:04 mvaligursky

  1. has been addressed by #4244

mvaligursky avatar Jun 22 '22 10:06 mvaligursky