+1 vote

Is it possible to write a shader that makes all the nodes transparent inside the cube? Except that it doesn't affect the lighting in any way. Anything inside the cube that became transparent should cast a shadow as usual.

If yes, please tell me what I need to deal with to achieve this result!

Godot version 3.4
in Engine by (32 points)

1 Answer

0 votes

The complexity here depends on the exact behaviour you want.

If you want the whole object to blink out when it enters the cube, then just make the cube an Area, and use the collision to drive a is_inside bool. Send this in as a uniform, let it drive the alpha and job done.

Another way that makes only the parts of the obj that are inside the cube transparent is to send the cube's origin in as a uniform, calculate the cube and set alpha accordingly. I'd start with a sphere as it's much simpler.

Two further approaches that I'm not certain about: 1) viewports projected on sides of cubes (like the Portal 2 method) 2) It might be possible to use passes. Not sure.

I'm also not certain about alpha and shadow behaviour. Try it and see.

by (1,749 points)
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 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 webmaster@godotengine.org with your username.