• Stephen Brown

Procedural Skidmarks

So we've got to a place where the game is live on pretty much every platform, except for Sony PlayStation consoles (which, for those who have asked, I'm hoping to get up and running at some point in the future!).


So many people have asked for a bit of a graphics update, things include windscreen effects and wipers that wipe rain, puddles, customisation of cars (including ability to add light pods on), and track detail. I've always wanted to add some track detail to bring the game to life and as I have a few spare days, I thought I'd have a dabble in adding some skidmarks to the track to give it a bit of variance.


Given the whole game is about procedural generation to keep that install size low, skidmarks will need to also be generated at load time as well. So here's my though plan behind it all:

  • First consider more detail on the corners, so use the AI data to find the apex

  • work out a random number of how many we will be aiming to draw at each apex

  • randomise the start and end points forwards and backwards a little bit

  • adjust the position to the left or right slighty on the track

  • convert to a cubic/hermit spline to get a smooth curve

  • create polygons to draw it smoothly (tesselate a certain amount)

  • then use something like to project verts onto the track as a decal

So the first thing to do was get the code in place to generate where skid marks will be drawn, the debug renderer helps us with this, and we can see below how skid marks will be drawn:

The next step is to take this data and turn it into a pretty renderable piece of data. We have to consider that there are a number of surface types all of which will have different skid marks textures/colours associated with them, so we have to split the render into different materials, or use shaders to give us that variance. We also need to spatially split all this up to make sure that we only render stuff that is near to us to optimise the speed, especially on mobile devices.


the other consideration to make is that I'd like this to have a level of detail approach, so users on low end devices who select low detail, may see 1 or 2 skidmarks per corner, whereas those on a high end device will see all of them.


Once we have done that, we end up with something like this, and it makes the track look so much nicer and less uniform, of course this is just showing you my progress, I'm going to make it even more detailed but this was a "daily" challenge I decided to work on last week!



Can't wait to get this finished, polished and released in an update soon!


Ste

207 views3 comments

Recent Posts

See All