Maskpass for terrain

I use the polygon region, and now I just need to do slope analysis on the ground of this region. First, I thought of masking the polygon with a maskpass. After passing maskpass, I get something like the following. But I only want the surface part. Is there any way to keep the slope analysis for the part attached to the ground and give up the rest?

My current effect looks like this

main code:

const clearPass = new ClearPass();

composer.addPass(tintPass); // A post-processor to calculate the global slope analysis results

const maskPass = new MaskPass(engine); // The engine contains the custom mask polygon

const texturePass = new TexturePass(engine); // Here I've changed the texturepass code slightly to pass tDiffuse, map globally, to engine

const clearMask = new ClearMaskPass();


I wanted to do it in a post-processing way because I used other frameworks based on three.js, which was cheaper for me.
I want to get a topographic map of the ground, and now I have a stencil buffer, and I can change the maskpass or whatever to get what I want

Is there a friend who knows and can help to answer the question?

I’m not sure I fully understand what effect you’re trying to achieve. Is the issue that the current implementation will render the slope on the sky as well as the ground, and you’d like to only be the ground?

If so, I would think one way to do that is to render a buffer that is black for sky and white for ground, and then pass that as an input to your slope post process so it knows where the sky is.

Also, if you’re able to post a minimal example others can run I think that will help others understand & help you out faster.

I have released a small demo, which probably reappears the problem I encountered. What I want is the result of the slope of the box surrounding the part that is attached to the ground. Could you please help to see what can be done.

So the current demo you posted looks like it’s just showing a static image through the movable box. It sounds like what you want is to show the normals of the terrain through that.

To do that, first you need to render the terrain with the normals, using this ThreeJS material: three.js docs

Once you get that working, you can apply the dynamic mask to the scene that contains the terrain.

So the question is how do I get this mask? The maskpass I used was passed into a box, and the result after my mask was also surrounded by a box, which could not achieve the effect of sticking to the ground. This is also what bothers me

Ok, I see what you mean. Instead of displaying the slope within the area of the box, you want to display the slope within the area of the entire ground?

If that’s all you need, I think this can all be done much simpler in a single pass by just assigning to your terrain mesh the MeshNormalMaterial, assuming the terrain is made of one or more meshes. That way it applies only to the ground. Have you tried that?

What I need is the terrain where the terrain intersects the box,Will using MeshNormalMaterial achieve my desired effect without using a mask?Could you please give me a minimal example to help me understand your implementation?

I see someone who has similar problems with me, and you have answers. I don’t use cesium.js now, but I have implemented the ground rendering, so I want to get local material should I also let the ground rendering support the map, and then pass in the normalMap,I think it should work.