OIT module imports

Hi all, I wanted to implement OIT in Seedborn which didn’t exist back during dev. I think its a good test case with a lot of different types of meshes with post. I tested on PG with the individual meshes and they seem to work fine. So I plunged ahead with this.scene.useOrderIndependentTransparency = true;

I’m using es6 modules (v6.13 for core + materials) and the first error I got was this._scene.depthPeelingRenderer is undefined

I added import "@babylonjs/core/Rendering/depthPeelingSceneComponent.js";

which gave e.enablePrePassRenderer is not a function.

I then added import "@babylonjs/core/Rendering/prePassRendererSceneComponent.js";

which gave this._scene.disableGeometryBufferRenderer is not a function

so I added import "@babylonjs/core/Rendering/geometryBufferRendererSceneComponent.js";

which threw this._postProcessesSourceForThisPass is undefined

And I realized I have run out of possible stuff to add from the Rendering src folder, I believe the error has to do with postProcess. Is there a doc somewhere that points to the modules for OIT? Kindly advise, thks!

_postProcessesSourceForThisPass is a private variable of PrePassRenderer, so I think the error doesn’t come from a missing import but appears during program execution.

If this is the case, I’m afraid it would be difficult to help you without some kind of reproduction…

1 Like

You can take a look at the file structure on the github too: Babylon.js/packages/dev/core/src/Rendering/depthRenderer.ts at master · BabylonJS/Babylon.js (github.com)

1 Like

I found a repro and possibly the cause of my error:

water refraction texture doesn’t work with OIT, hrmm… :frowning:

You should disable the prepass renderer for your custom target texture by doing _refractionRTT.noPrePassRenderer = true;:

1 Like

well, the error goes away but the PG doesn’t show anything. Commenting out scene.customRenderTargets.push(_refractionRTT); works. But it broke other custom shaders in my game. :frowning:

Thanks for all the help, this experiment is kiv’ed indefinitely.
Marking as solved, cheers!

A workaround is to enable OIT after a little time:

Note however that the water mesh won’t be handled by OIT, as it is not flagged as transparent. You can set it as transparent by adding needAlphaBlending: true to the options of the ShaderMaterial constructor but that will fail, because the shader would have to handle the specificities of the prepass renderer (it needs to write to some specific render targets).

1 Like