XaiJu
thinmatrix
thinmatrix

patreon


October Update - Road Improvements

Hey everyone!

After finishing off the basic Activity system at the start of this month I moved onto working on some improvements to the road system. The biggest change was allowing the player to place multiple roads at once (no more individually placing every single road tile!), plus there are a few visual improvements.

Road Placement Tool

The placement tool for the roads has been completely redone to allow the player to drag and place multiple roads in one swift movement. Hold down the left mouse button and move the mouse to start creating a new road. While you do this a preview of the road is shown, and you can cancel the placement by right-clicking at any time. Release the left mouse button to place the roads.

Placement Animation

When the roads get placed into the world they now do so with quite a satisfying animation. This animation is carried out entirely in the vertex shader, because the road system is a single mesh and I wanted to avoid having to update the mesh every frame to create the animation. Just a simple easing function in the vertex shader to change the vertex height and you get quite a nice wave effect on the newly placed roads!

Grid Tile Overlays

As part of the new placement tool I wanted to implement a more flexible system for highlighting grid squares in the world, to give feedback to the player. Previously I just had a simple shader based system which allowed one tile to be highlighted, and this was what I used previously in the placement tools to indicate whether something could be placed in a certain tile or not. The new system uses textured quads rendered on top of the terrain, allowing for multiple tiles to be highlighted and just generally providing a lot more flexibility in terms of what the overlays look like.

Road Markings

This turned out to be a bit of a failed experiment, but there are at least some simple marking on the roads for now. I wanted to try texturing the markings directly onto the road mesh without rendering any extra quads, and I had a plan to do it without any additional vertex attributes such as texture coordinates. The idea was to use a texture atlas containing all the possible markings for a tile, and then use the alpha component of each vertex's colour attribute (which I previously wasn't using) to store the id of the relevant part of the atlas which should be used for that vertex (as previously mentioned, all the roads are rendered together as a single mesh rather than each road tile being rendered separately, which would have been much easier to texture!)

Then in the shader, the id could be used to get the position of the relevant texture in the texture atlas, and along with the world position of the vertex could be used to determine the texture coordinates needed to sample the texture. And it very nearly works, except for a one pixel seam between each road tile due to the way the texture coordinates are calculated. And unfortunately can't really find a way around it.

So I'll have to take the traditional route of rendering extra textured quads to add the markings, which will allow for more complex combinations anyway so it's probably for the best! But I'll do that next time when I work on the roads again - for now it's time to move on.

Next Up...

Next month I'm getting back to the lives and activities of the towns-people, and working on their housing situation. Each person is going to have their own house which they will always return to, and people will only move into the town if there are enough homes to go around.

Thanks for reading! Download links for the game and code are available in the posts below.

Karl 

October Update - Road Improvements

Comments

Thanks for the technical details! How you go about solving these interesting problems is very much of interest to me.

KC Oaks

This project is really starting to take shape. You've done a lot of crucial groundwork (no pun intended). I'm looking forward to the addition of "residence logic" which you mentioned, and the host of features and systems that can build on that. This is going to be a great game!


More Creators