Dirty clothes and other texture masks/overlays in 2D

Hey guys, I was wondering how to go about creating an overlay for a 2D character that would simulate dirt on clothes or the body for example. The character is made with multiple Polygon2Ds and a skeletal bone system, while the dirt is basically a big rectangle texture with painted dirt. I tried using the new CanvasItem Clip children method, but that only seems to work if directly connected to a parent, eg. for each body part polygon2D I would have to duplicate and reparent the dirt texture node so it influences each part separately, as parenting the root 2Dnode with the mask does nothing. I need the big rectangle dirt texture to mask every single Polygon2D node texture in the character tree basically.

I could just make new polygon2D nodes with exactly cut dirt texture and weight paint it to the skeleton so it moves, and display it over the clothes, but I would have to paint it as precise as the clothes themselves so if the clothes move around and deform, the dirt also deforms…

Is there a way to do this?

Im not sure if it works but have you tried using clipping together with CanvasGroup? CanvasGroup — Godot Engine (stable) documentation in English

But this probably wont solve the moving problem

Quoting from the CanvasGroup Documentation

Note: Since CanvasGroup and CanvasItem.clip_children both utilize the backbuffer, children of a CanvasGroup who have their CanvasItem.clip_children set to anything other than CanvasItem.CLIP_CHILDREN_DISABLED will not function correctly.

I think it wouldn’t work due to this. Well I didn’t manage to make it work. Also, yeah, using the clip function wouldn’t work with moving parts. I think I would need something to blend the textures so they get merged and move with bones. I think the only way is probably using some sort of a shader.

But thanks for the help anyway!

1 Like