r/howdidtheycodeit • u/stop-thinking • Feb 10 '22
How did they code spraying a Graffiti in "Marc Ecos Getting Up"
So i m really interested how they did it, or how you guys think is the best way to code spraying a Graffiti Piece.
I already worked on a 2d unity version of this and it works. but i think it might not be the best way or the best performance.
It should include mechanics of the painting process like in marc ecos getting up with moving the hand and and only painting where the hand goes.
thanks for your ideas :)
17
Upvotes
3
u/nvec ProProgrammer Feb 11 '22
In general that's not too difficult conceptually, but involves some quite tricky coding to make the textures work correctly, and if you want it to follow the geometry of the level you're going to need some procedural geometry coding too.
The first part is to ignore the graffiti itself and implement a very crude 'spraycan', drawing large smooth strokes across the wall in monochrome (single colour channel) on the area the graffiti image is to appear. There're a lot of ways to do this but basically it's the same as writing a basic 2d paint package but with the brush following the character's hand.
Now you can add the image for the graffiti itself as a texture, and in a simple shader use the colour from the texture but for opacity you take the texture's alpha and multiply it by the colour channel from the spraycan above. Now you have the ability to move the brush and make the graffiti appear as it does.
By the way- never heard of "Marc Ecos Getting Up", and don't have the time to spend looking for a video of graffiti in it. In general if you're interested in knowing about how to approach a particular implementation you've seen then include a timestamped link to the exact part of a video showing what you're after- without that people won't know precisely what you mean. It can take a bit of time to find a good video but it means that others don't need to do that themselves before they can help you.
4
u/[deleted] Feb 10 '22
i think a shader on a decal in unity 3d
idk how to do this but I think this the right path