Frame Graph commit make depth buffer 16bit instead of 24bit for multi render (WebGL2)

Hi!

This big commit:

(only for WebGL2 on google chrome, other browsers can ignore depth you asked and always provide the same one) Made frame buffer for case of multi render setup (for example, ssr pipeline enabled) depth buffer for the whole pipeline to be 16bit, you can check it on any ssr demo like this one:

on the playground using debugger in the line (you need a conditional debugger when t is true):
t ? this._createRenderBuffer(r, n, i, a.DEPTH_STENCIL, s, a.DEPTH_STENCIL_ATTACHMENT)
s will be 16bit instead of 32bit (before commit it was 32bit)

Because of this change in createMultipleRenderTarget from:

this._setupFramebufferDepthAttachments(!useStencilTexture && generateStencilBuffer, !generateDepthTexture && generateDepthBuffer, width, height);

to:

rtWrapper._depthStencilBuffer = this._setupFramebufferDepthAttachments(rtWrapper._generateStencilBuffer, rtWrapper._generateDepthBuffer, width, height, 1, **depthTextureFormat**);

it happens because in the extension for the engine in createMultipleRenderTarget
the default is 16bit:
let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;

but later in the function _setupFramebufferDepthAttachments previously depthBuffer depth was undefined (it was changed by commit at the beginning of this post) and now it is16bit

inside _setupFramebufferDepthAttachments next lines will select the proper buffer (none is 16bit what is expected today) in case of undefined and do nothing if depth is already there:
depthTextureFormat = depthTextureFormat ?? (generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT);

i suggest or rewert changes if it was mistake or change for both engines default depth buffer size to Constants.TEXTUREFORMAT_DEPTH32_FLOAT instead of TEXTUREFORMAT_DEPTH16

BUT i can see in code check weather buffer has specific value then change itā€¦ so maybe change of default depth can break something else (like stencil will work incorrectly)

cc @Evgeni_Popov to have a quick look

Iā€™m having a look right now, but regarding the PG you linked, the depth used by the prepass renderer is 24/8. From Spector:

If I check with v7.32.0 (before the frame graph commit), I get the same thing, a 24/8 depth/stencil buffer.

I agree that the default value is not the same than before, though, so Iā€™m going to fix it in my current PR (Frame graph: refactor to use InternalTexture instead of RenderTargetWrapper + misc changes by Popov72 Ā· Pull Request #15874 Ā· BabylonJS/Babylon.js Ā· GitHub).

1 Like