But here it is! |
Easy: MAGIC! ...Or is it math?
Shaders (in a really dumb nutshell) are programs that talk with your computer's GPU, instructing it how to render what you're seeing in the game. They calculate the colour of the thing you're looking at, account for things like lighting, specularity (i.e. shininess), texture (is it rough or smooth?), and emissiveness (does it glow?), and generate a final pixel colour - and it does this for each pixel on your screen!
So the answer, naturally, is to build a shader that can randomly generate colours and patterns to apply to a single 3d model, giving it a varied look. To do this, I used four basic textures:
Colour, Detail, Metallic, Normal |
- The colour replace map to determine the basic pattern and colour of the paint job. This doesn't look like much but I'll explain.
- The detail (or diffuse) map shows the car's actual visual texture - metal fixings, rust, dents, and so on.
- The metallic (or specular) map determines specularity - where it's shiny and how shiny it is. Black is dull, while white is very shiny.
- A normal map, referring to the geometric normal of a surface, which determines how "bumpy" or textured the model will look. It will talk with any light sources in the game to simulate high and low spots to give the model a more detailed look.
The Jokermobile never looked so good. |
The end result is simple, but pretty neat, if I do say so myself.
Get you a cab that can do both. |
Speaking of car models, the model I'm using was not made by me; it's a placeholder I'm using, made by Renafox on Sketchfab. I've made some modifications to the textures - and, of course, removed the wheels. Renafox has tons of car models, and other neat stuff available, and its all amazing. Check it out!
I hope I was able to explain myself well enough here. And for those interested in the shader code itself, check it out here. Any suggestions for improvement? Feel free to post a comment here or on the linked page.
What's next? Camera stuff?