I’m currently utilizing a shader graph below to craft a forcefield-esque effect (Used shader here). When applied to a plane and interacting with surrounding geometry, it yields results akin to this:
Now, I’m seeking guidance on modifying the shader graph to selectively mask the upper region of the intersecting geometry, aiming for an outcome resembling this:
I haven’t tried using the shader graph yet so I don’t have an answer for your question but I can think of few ways to get to what you want to achieve, if it can give you some leads:
You can cut your plane in blender if it’s something static that won’t change
You could use a depth-based masking technique in order to get the desired result for a dynamic terrain or a scrolling camera view
You can make a dynamic mesh that would take the vertices of the terrain’s edge to generate the plane
You can make a stencil buffer but I don’t think it will be easy to do with a terrain
You can use a clipping method to see if the plane is under or above the terrain but I’m not sure about terrain, it works fine with cubes, spheres and others because they have an “inside” and “outside”
I’ll do some research to help you more but for now that’s all I can do
I hope it helps
Hi @Cyber_Cats thank you for your answer. •Unfortunately, my terrain is changing, so a static cut will not be an option. •I did consider making a dynamic mesh, but I am targeting low-end AR devices so I figured using a shader would be much more efficient. Do you have any idea how to use a depth-based masking technique? I guess that would be the most suitable solution, I am unable to figure out how to do that with a shader graph. Or shader in general, I am not familiar with coding shaders.
By using the camera you can render a depth texture that could be used by your shader and by playing with the dark and white parts of the texture you can select what can be hidden and displayed, first step would be to check what a depth texture is and try to rendre one, the second step would be to use the depth texture (or a test texture) in your shader graph to display / hide the parts of your plane based on the texture's gray scale and lastly you'd combine the rendering of the depth texture with the terrain shader. Remember to try to cut your work in small parts.
Hi @Cyber_Cats thank you for your answer. •Unfortunately, my terrain is changing, so a static cut will not be an option. •I did consider making a dynamic mesh, but I am targeting low-end AR devices so I figured using a shader would be much more efficient. Do you have any idea how to use a depth-based masking technique? I guess that would be the most suitable solution, I am unable to figure out how to do that with a shader graph. Or shader in general, I am not familiar with coding shaders.
– SmaikaBy using the camera you can render a depth texture that could be used by your shader and by playing with the dark and white parts of the texture you can select what can be hidden and displayed, first step would be to check what a depth texture is and try to rendre one, the second step would be to use the depth texture (or a test texture) in your shader graph to display / hide the parts of your plane based on the texture's gray scale and lastly you'd combine the rendering of the depth texture with the terrain shader. Remember to try to cut your work in small parts.
– Cyber_Cats