Godot 4.4 dev 7, Web export
Mechanic:

How can I ensure the paint appears on top of the physical platforms without clipping into the ColorRect background? Currently, I’m using tweens to move sprites based on the raycast’s collision normal with the platform. The tweens move towards the objects’ forward direction, offset by a random angle, to make the paint seem more realistic while scaling up the sprite.
I think this effect could be achieved using shaders or subviewports, but I’m unsure where to begin cause I haven’t really used those features before, or is this approach bad for the effect i’m trying to achieve?
If the platform itself is a ColorRect, then (I would hope) making the paint blobs children of the platform and turning its clip_contents to true would work?
I also think there’s probably a good way to do this with shaders or viewports, but it would get a bit more technical.
To follow up:
- Viewports might be overkill, but should definitely be able to handle the clipping.
- Shaders seem really natural and would allow for some nice alpha blending, too, but you’d have to track which points get hit and shaders only allow fixed sized arrays, which seem to lead to some technical issues in making this work nicely in general.
- Another great approach would be to use an ImageTexture and then use the blit_rect or blit_mask function on its Image to change the color of the object.
3 Likes
Actually, any CanvasItem has a clip_children that can have the same effect.
1 Like
I think the clip-contents solution should work with my game, lemme try implementing it and see what happens.
1 Like
I got it working!

Thanks to your advice, I was able to come up with a solution! Currently, clip-contents isn’t working with tilemaps for some reason, so I rendered the viewport onto a sprite instead. Then I added the paint as children of the tile view sprite with the clip-contents property turned on, which uses a sub-viewport texture.


Thank you for informing me about clip-contents, I woulda never found about this property on my own lol.
2 Likes