I’ve just seen some very realistic ground contact shadows in some models of Sketchfab and it seems that is generated realtime as a post process. Is it possible to get something similar with the built in babylon post processes?
I guess to efficiently do those, either you bake offline a texture looking like this:
or you would need to render from the top on a rendertargettexture the depth to the plain then make a special blur (probably 2-3 passes) depending on the previous result. This might be a bit slow and it looks like sketchfab generates it on the server.
Thanks for your answer. I think I may try something like your second option, as it needs to be created on the fly and not baked beforehand, but it seems complex to get that blurred shape
But if you look closer at the edges of that shadow, it seems that flickers a bit and it’s being updated as the camera moves, so it may be some screen space post process, but also taking into acount the zdepth. It’s a really good effect by the way, so congrats to the developer.
Thanks @sebavan, it worked! I had some trouble figuring out the conversion of the float32array and the fact that the zdepth info was stored only in the red channel. I’ve modified the playground with an almost working sollution for getting the texture out as a base64 (but it’s skewed and clamped, so I need to work that part out): https://www.babylonjs-playground.com/#T5YWJQ#12
Thanks for the info Eugeni. It works but the image is red, so I need to process it to remove the color:
And also I needed to open an anonymous browser window in order for it to work (clearing the cache didn´t work in my case)
Anyway, using the helper function you mention provides a cleaner and shorter code (no need to mess with temprary canvases and 2d contexts), the only real concern here is the red tinting but it’s something that is related on how the depthmap is created in the first place I think