godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.66k stars 20.11k forks source link

Easy and flexible way to make sprite masks #23763

Closed zhagsenkk closed 5 years ago

zhagsenkk commented 5 years ago

Issue description: Sprite masks is usually used in 2d game. Godot doesn't have a easy and flexible way to make it.And cocos game engine and unity both have an implementation of SpriteMasks or ClippingNode. Similar with some other engine.

unity: https://docs.unity3d.com/2018.3/Documentation/Manual/class-SpriteMask.html cocos: http://docs.cocos2d-x.org/api-ref/cplusplus/V3.17/d2/d06/classcocos2d_1_1_clipping_node.html 20131206093955500 Defold: https://www.defold.com/examples/gui/stencil/ Phaser: http://phaser.io/examples/v2/sprites/mask#gv

BastiaanOlij commented 5 years ago

This is a pretty easy effect to accomplish: SpriteMask.zip

groud commented 5 years ago

This is already possible and quite easy to do with shaders. I suggest to have a look to gdquests video about transition shaders : https://youtu.be/K9FBpJ2Ypb4

If you need any help please ask on the other community channels.

zhagsenkk commented 5 years ago

This is a pretty easy effect to accomplish: SpriteMask.zip

Thanks for the help. But if there is a group of sprites to be cut off, how to do it? @BastiaanOlij @groud

zhagsenkk commented 5 years ago

"a group of sprites" means that a sprite with several children.

groud commented 5 years ago

Simply apply the same material to all child nodes, and compute the masking according to the screen position. But once again, ask in the other community channels, this is not the place to ask for support.

BastiaanOlij commented 5 years ago

What @groud said, just reuse the material. :)

creikey commented 4 years ago

This does not work when using different sprites with a multitude of materials @groud