I’ve been working with PlayCanvas for a few weeks playing around with shaders in general and everything seems to run smoothly except for the Depth Buffer. I have browsed the forums and saw many different things being said about it like using :
scope.resolve("uDepthBuffer) = this.depthMap; in the shader settings
this.needsDepthBuffer = true; …
None of them seemed to output a proper map, I never managed to see once a clear depthBuffer. A lot of projects supposed to work good with depth buffer are shared online, but all those that claimed to work are either in “error 404” either when you start them with the editor (therefore using the latest version of playcavnas) the depthBuffer simply doesn’t work.
Is it actually possible to use the Depth Buffer in playcanvas or did that functionality get removed from the engine ?
I have seen that one however it is not a project but a precompiled render, it uses depthBuffer with a version that is not stated and there is no access to the actual code of the post-effect, only generic code that says something like “apply post-effect to the sphere” without actually showing the code of the effect
force webgl1 on your project, run debug mode of the engine and capture the frame with SpectorJS. Then see what happens. You should see in webgl1 rendering to depth (we do separate pass for this), and its stored in RGBA format, so you can see it in the screenshots there.
Webgl2 uses the actual depth buffer and spector JS does not show you the image, so that is less convenient when debugging.
also note that the debug shader I shared needs to have that “#define GL2” in it - make sure your one does as well (on WebGL2 platforms only of course)