Hi! This is the second dev log for Project Trains. We're talking about how we did our 3D graphics in Project Trains to make it as beautiful as possible and keep the reasonable amount of FPS on mobile devices.
Well... This one is pretty obvious. On mobiles we don't want to use realtime shadows on all objects on the scene. Project Trains : Traffic Control levels have many static objects that should cast shadows. It's natural to use Unity lightmapping feature.
Lightmapping has one serious drawback. When used with realtime shadows you can easily see the difference between these two. Lightmapping shadows look more realistic because these are more blurry as the distance between caster and the ground is further. Still it's better than nothing :-)
Yes, we're using realtime shadows! Mainly for trains and trains loaders/unloaders like cranes. Unity allows to customize these shadows to choose between quality and performance. Because there aren't so many objects with a shadow, we've decided to stay somewhere in between.
Some levels have traction lines. Usually cables in games are rendered using simple thick lines (like GL_LINES). We're not different, but we decided to make it a little more eye-candy.
For most of the time player observes the game from the isometric-like point of view. It's not really isometric and the camera Matrix is set something in between orthographic and perspective. Yet. the fact is, that you see the scene from the top and all the objects are rather small.
On some displays one-pixel thick cable can be too wide, so we did a little trick. We check how big is the screen size and based on that information, we make the cables more transparent. In the end it looks like cables are equally thick like on bigger devices.
Not everything is in 3D, but train tracks are! The reason why we kept those in 3D is that... it would be totally visible if we would just flatten them out. Train tracks look very different from different angles.
What about wooden connectors? Yep, these are flat! Do you see the shadows? It is painted on texture. Just like that!
Bump mapping and specular
Two things that really improved the looks of our 3D graphics are bump mapping and specular. Here's a comparison:
Specular made our metal objects look like real. Both effects are fairy cheap for today's mobile graphics cards even on older devices.
We wanted wheat to look realistic. The problem with plants is the volume. Plants can be deadly for GPUs if not prepared with caution.
Our wheat block is a single object with 168 vertices and soft edge cutout shader. Thanks to that the rendering is cheap and the visual effect is more than acceptable.
Here's the close-up:
Of course the player won't see these holes :-) Yet leaving it as is, allowed us to make a great effect without making the GPU to overheat.