Wednesday, January 11, 2017

Working with landscapes for games

     Okay, I know what you are thinking. My last blog post was in the middle of December. I said that the plan was to get enough of my new game finished and post the greenlight campaign to Steam by the end the month. Obviously this did not happen then I just disappeared from the blog ever since.  And now I come back, in the middle of January and this is my first update for 2017!? Talking about landscapes!!! Are you kidding me!? What  great way to start off the new year right? Okay, joking aside, I have been working on my new game, I have been making a lot of progress and I will have a proper update blog post later on to talk about my plans for 2017, give more info on the new game project and so on. But for now, I want to talk about working with landscapes in a game project. 

   I was working on a new scene for the game that features a piece of land that is split down the middle. This can work as a river for example. I was happy with the results and I thought that I just had to share this on the blog. In games or just 3d modeling in general landscapes can be very tricky to work with. The Unity game engine does have its own terrain system which has a ton of great features and tools to help you create massive terrains for your game. Personally, I hate Unity's terrain system based on past experiences with it trying to create good landscapes for my games. It can be very time consuming to sculpt in main features like rivers, you end up with these giant empty terrains that look messy, constantly switching between brushes, adjusting sizes, erasing over areas constantly to try and get something looking right is frustrating to do within the Unity engine. You get all this unnecessary geometry/increase in poly count that could take a hit on your games performance, etc. I can go on and on about the many flaws the terrain system and tools the Unity engine bring. If you are a Unity developer and have used the terrain system or even if you used a terrain system in a different engine you might understand what I am talking about.  

     I figured, instead of throwing in this giant unnecessary piece of land into the game, why not just focus on the important features of the land that the player will actually get to explore? Before I continue, just know that this is more of a personal design preference and depending on the kind of game you are making, this might not be a proper solution for you. For example, if you are working on a huge open world game that's all based on terrain like MGSV for example, then you might want to actually sculpt and entire terrain. But for my case, I am working on a linear game that is broken down into smaller scenes with loading times in between. Anyway, I realized that just focusing on the important parts of the landscape such as rivers, canyons, etc is all I really need to create. I can save a ton of time and polygons by just putting in the parts that matter, and then make it feel seamless or give it that seamless illusion in post such as covering the area with fog, decorating it with trees, foliage and other props to make the land feel more believable and adjusting the camera clipping so that the player never sees past the edges of the world. There is no need to create a massive landscape that would take the player time to traverse. That would just be filler. Just cut straight to the main parts of the game. 

     So in the screenshots I am posting I am showing this grassy type land that is split down the middle which shows the under side of the earth. This can be used as a river, I can re-texture it as a canyon or really any kind of land-form that splits. This literally only took me about 5-10 mins to model and texture in blender. It is very low poly, it looks good in the Unity engine and just works for my game. Here is a breakdown of the mesh so that you can see and get a better understanding of how it was made. 

Here is the actual mesh inside of blender. The wireframe shows that it is actually very low in poly count. The loop-cuts/edges/vertices/faces (whatever it is you call them) are very clean and form the mesh very nicely. 

Here is the textured mesh. (Still inside blender) Everything was done in blender then exported to the Unity engine. About the textures - it can be very tricky to texture landscapes because they have all these different materials blending into them like dirt and grass and wet mud and rocks and so on. If you are using a terrain system like Unity's terrain system you can easily just paint and blend textures directly onto the terrain and make it look seamless. When you actually model a piece of land like this that has very few polygons, texturing and blending can be tricky to do. What I did for this is created two different materials. Grass and dirt. I applied these to the model on the appropriate uv coordinates. The trick to making everything blend together is within the mesh itself. It is very important to make the right amount of polygons for the model. Just focus on the silhouette of the landscape first. Model in the areas that are needed then you can apply you're textures. If the model looks right without the textures and you can visualize where the grass needs to be placed or where the mud needs to be placed, then texturing will be simple because you know you have the right amount of polygons and it will look fine.

The best part about this particular model is that it is modular. Meaning that I could just reuse this river/landscape split over and over again. I can extend the river and make one huge seamless formation. I can use it for different environment and so on. 

Here is a screenshot of just a simple lighting test done in blender. 

     It won't be perfect and that's okay. Keep in mind when working on games there are so many other things to take into consideration besides the graphical appearance. Poly count, performance, gameplay, etc. The landscape won't be perfect. Mine is not perfect. Up close you can see a very straight line where the grass and mud separate. The trick with games is, you can get away with this kind of stuff because most likely the player would never even need to get that close to notice anything. Plus as mentioned before, these small things will be hidden by other game elements like foliage, fog and so on. Don't focus on making something perfect. Just focus on making something look believable and acceptable then move on. Remember there is still a lot of other stuff that needs to be worked on in a game. So never dedicate too much time to a single piece. You can get away with these things. I was thinking about how older games like Zelda Ocarina of time handled landscapes when the hardware was so limited. I looked at a couple of screenshots from various parts of Hyrule and noticed that those landscapes seem to be modeled very similarly to how I modeled this river example I am showing above. It wasn't perfect at all, but it just works and it still felt like I was in this believable game world even with some of the obvious seam lines.