the plane needs to be always over the background landscape, how can in use the scene’s depthmap to displace the geometry?
You can’t access the depth buffer directly. If you want to access is, you have to create/manage/render to/use… a WebGLRenderTarget with a depth attachment, then pass the depth target.texture as a uniform for a custom shader to displace with, or you might be able to get away with using it in plane.material.displacementMap = depthTarget.texture
Your plane may need many subdivisions to get something interesting.
Thanks! so i add a camera to the scene, render a depth texture to use it? wouldnt there be a simpler way to get it (like in unity/unreal)?
I just re-read your question and I might be overthinking what you need.
You sure you don’t just want:
depthTest:false,depthWrite:false,transparent:true.
and mesh.renderOrder = 10;
on your plane? (causing it to always render last, and on top of what was there before)
Or are you trying to actually warp a mesh to a depth buffer?
By default in webGL you can’t access the contents of the main display buffer, only rendertargets.