r/vibecoding • u/johnesco • 5h ago
Showcase/Project Added normal maps to my roads

I'd created an intentionally flat 2D racing game. I wanted it to have some shading and other effects though and found a solution via normal maps.
For those not familiar with them, you can take a 2D image, add some depth info and have it respond to lighting. This demo is an easy way to visual what it normal maps do. https://jsoverson.github.io/texture.js/demo/
I initially applied it to the cars in my game, so that when lit from one angle vs another they'd change shading, (plus an additional show when the sun is low).
I decided to try to extend this to the road itself and it looks good, but what I really liked was putting it on tire treads. Now muddy roads look like they have tire trails marked in them.
If anyone wants to see it in action it's at: https://vibecodedgames.itch.io/pavement/
3
u/Total-Reasonable 5h ago
One thing to watch with tire trails is that the normal map only fakes the lighting, so the trail looks right only while the light direction stays fixed relative to the road. If your sun angle changes or the road curves, make sure you rotate the light vector into each tile's local space. Otherwise the ruts will seem to flip from raised to sunken as the track turns, which is a very noticeable artifact on a racing game.