Persistent decals 2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sparks
:warning: Old Version Published before Godot 3 was released.

Hi,

I wonder how to implement decals (like blood, remains, footprints, trails, …), which last some time (and may fade out), in 2D.

I used to work a lot with Game Maker, there we have surfaces which simply hold the stuff drawn on - if they are not cleared.

Is there something similar in Godot? How would you approach this?
Thanks in advance!

:bust_in_silhouette: Reply From: eons

For simple things like footprints, trails, the particle node may be enough (turn emission when moving, use motionless particles), for more complex trails search the Q&A, there is a nice plugin not present in the asset lib.


For objects with more complex behaviour (blood splats, debris) I don’t know how are the regular implementations for decal systems.

If there will be just a few, the node origin of the decal may be enough to control the remains before being freed (just make it instance the effect scene as a child while removing the normal behaviour).

If there will be tons of stuff on screen, I may look at it the same as a bullet hell system, you can make a generic global decal manager that works as your particle/decal control system, each time you generate one, register it on the manager and make it control the time, apply tweens, change shader values (for fading, disintegrate, and other effects) and remove, for all the registered items at once.

The manager can generate the decals too, allowing to control/limit the number and recycle items.

Weren’t decals planned for 3.0?

Zylann | 2017-04-09 14:19

Thanks! :slight_smile:

So it is (currently) not possible to paint on some kind of layer / surface / canvas with the option of keeping the painted. So there is no access to such function like:

.clear(Color) 
# actually not calling clear() would keep the content of the painting

Is there any chance this may be in Godot 3.0 ?

The particle approach may be sufficient for what I need currently. It’s maybe possible to make some complex behavior when animating the particles once. You can animate them, right?

sparks | 2017-04-09 14:40

In Godot 3.0 you can control particles from a shader, however I don’t understand how you would expect particles to behave like decals Oo (like this? https://blogs.unity3d.com/wp-content/uploads/2015/02/RenderingCommandBufferDecals.png)

Zylann | 2017-04-09 14:46

Yes, you can “paint” pixels on screen (search docs about custom drawing in 2D), even create and/or edit Image resources used on textures.

Note that I was not talking about “decal” proper but persistent particles-like effect painted on screen.


I don’t know about decals, for now the only thing I have seen is the shaders and meshes on particles that can work to make better trails (not sure how that will work on 2D without meshes there).

Physics on particles I’ve thought were for 3.1, that may help to create things like blood splats with shaders but I need to know how that works first and I have less than no idea.

eons | 2017-04-09 15:12

Ooooops I misread the post, I thought it was for 3D (because I never seen the term “decal” being used in 2D lol).

Zylann | 2017-04-09 15:14

@zylann yes, is used for splats and the like (I don’t think it have a name), and may be correctly used on another engine ™, I believe GM may not use real decals.

eons | 2017-04-09 15:26

Sorry about the confusion about 2D or 3D. I edited the original question while you @Zylann answered, so you didn’t misread it in the first place, I actually missed to mention the the 2D part, but now that’s clarified.

And yeah, “decal” may not be the most appropriate word, but it’s more universal than just “blood splatter” I guess.

@eons
Not sure, what you are heading for when you mention “paint pixels on screen”? Wouldn’t this end in many draw calls, which are to be avoided? And creating textures on the fly and updating them every frame, does this work well? Again, not sure if I understood you here.

sparks | 2017-04-09 15:49

Godot is pretty good managing draw calls and if you have a central effect manager, all that will be done once (of course, process all the elements on _process and just draw on _draw).

You can edit and stamp images on the image of a texture, then on _draw draw all the texture(s) once.
I think could be better to have many images for the corresponding splat sections than a single big image.

This could be kind of easy to set up for things like Super Meat Boy blood trail.


There are not many examples of how to manage images, but this may give an idea on how to edit textures and detect collision for simple particles without physics:
https://twitter.com/bogdan_kustan/status/832993691325386752

I can’t access the site, google cache is here:
http://webcache.googleusercontent.com/search?client=ubuntu&channel=fs&q=cache:https://www.fullstackend.com/2017/02/godot-destructible-terrain/&ie=utf-8&oe=utf-8&gws_rd=cr&ei=QF_qWPvEG8arwASQhbnwAw

GH: GitHub - bogdanaslt/Godot-destructible-terrain

eons | 2017-04-09 16:28

That’s very cool stuff, thanks !

sparks | 2017-04-10 13:14