0 votes

Is there a way to make a mask, perhaps as a child of a 2d image/sprite, that does nothing but hide portions of it? either through making an entire node used as a shader, or using a singular node.
I tried the SpriteMask.zip here and it is not what I'm looking for. I also tried finding tutorials on this subject but came up blank.
The SpriteMask.zip's shader applies a global shape to an image, while I just want to manipulate images/sprites while under a mask.
I tried demonstrating it with basic polygons and shapes:
enter image description here

enter image description here

The image isnt being hidden, more like the pixels of the viewport or the parent, the red being the mask, hiding the orange bar.

I feel like this would be incredibly useful in the long term, so if there is a way to do this, that'd be wonderful.

Godot version 3.3.2.stable
in Engine by (14 points)

1 Answer

0 votes

I dont know if there is a mask to hide part of a node but I can suggest another alternative. You could create a scene of the polygon shape made up of several different polygons. Then you can control it but turning the visibility of the specific parts of the polygon shape off.

by (1,683 points)

If i wanted to be non-flexible with how the mask is represented, that is definitely an alternative. I'm thinking more along the lines of how a control's rect size + clip content can be used to obscure it's content when outside the bounds. Though, obviously, instead of a control it is a polygon/image that can be changed to the user's will, as a square won't help much in the grand scheme of things.
Perhaps a polygon container of sorts?
enter image description here

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 webmaster@godotengine.org with your username.