The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Is there a way to hide objects under another object? I have a multimesh with a shader creating moving grass, but it pokes through my farm plot blocks. You can see the effect here

I found some code to cull things behind a plane from this youtube video

Someone suggested using a viewport texture to draw shapes where the grass would get drawn too, but I wasn't able to figure out how to do it. This plane culling thing seems like the most straight forward if I can get it to work. Right now, it's either applied to the grass as a whole, or the plane depending on which object I put the shader code in. I'm thinking it needs to go in the grass shader, and pass in each object as it's layed down. But I don't know how to pass in multiple block positions as they are layed down, much less how to make it dependent on them.

shader_type spatial;

uniform vec4 portal_plane = vec4(1.0, 0.5, 0.0, 0.0);

bool portal_culls(vec3 vertex, mat4 cam) {
vec3 pos = (cam * vec4(vertex, 1.0)).xyz;
return !any(isnan(portal_plane))
&& portal_plane.x * pos.x
+ portal_plane.y * pos.y
+ portal_plane.z * pos.z
+ portal_plane.w < 0.0;

void fragment() {
if (portal_culls(VERTEX, CAMERA_MATRIX)) {
ALBEDO = vec3(1.0, 0.0, 0.0);
Godot version v3.3.3 stable
in Engine by (26 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.