Hi everyone, for today’s update I thought it would be good to show some behind the scenes tech from the game, and show the progress over time from one of our early builds.
When designing Xenosis, I knew that I wanted to give a unique take on the top down genre and really use lighting to great affect to create atmosphere in the game. I knew how I wanted it to look in my head, it was just a case of translating that into the game engine.
Traditionally, 2D games are all created on a flat 2D plane, with the sprites “sitting” on top of the background, and that’s how I originally started prototyping the game, but it looked so flat and I spent a long time writing a “fake” 2D lighting system, that could cast shadows, but it just didn’t look right.
In order to get the look I wanted, I needed to leverage Unity’s lighting system, and for that you need to be working in 3D. So I needed to change my approach in order to get this to work, and that meant two things.
Sprites all need to react to realtime lighting.
Sprites need to cast and receive shadows.
In order to achieve the first, that was relatively simple and just meant using normal maps to make the sprites react to light based on data contained in the normal map.
Then, in order to cast and receive shadows, I changed the game from a 2D layout and started re-constructing in 3D with hidden geometry that can react to light.
Once setup, now I could have lights react to 3D geometry, for example, a crate is simply a hidden 3D cube with a sprite on top, so you only see the cube sprite, but it casts a realistic shadow.
Now whilst this approach was good, it still felt very flat, and one of the biggest changes I made to the game that had a huge impact was to not display a 2D game using an Orthographic camera, as this projects everything as flat, regardless of how close it is to the camera, instead I swapped to a perspective camera, that allowed me to give height to the game.
Now things were starting to look good, but it still lacked a little, so then it was onto the level details and shader tech. I worked on creating details to adorn the levels with, cracks in the floor, rubble and misc items, things to give more context to the levels. I also worked to create deeper shadow areas, allow light to have more of an impact and overlayed a number of shader effects to bring grit and contrast to the game.
Now it was starting to look as I had intended, and the lighting was constantly being tweaked to get it looking just right.
Now with this tech in place, we have super juicy things like volumetric lighting, particles that react to lighting and we can use loads of dynamic lights to make it look super awesome, whilst still maintaining performance and this is something I am very proud of.
So lastly, here is quick peek of it all put together as it is now. This shows you the “flat” 2D sprites inside the game engine, without any of the lighting turned on, and this is viewed directly from above would indeed look like a traditional 2D game.
As you can see, all the in game items such as these crates and the player are flat sprites, but they are hiding the invisible 3D geometry, so lets turn the lights on to see what happens…
Now you can see how the light is reacting to the sprites, and the 3D geometry is casting realistic shadows. The custom shader tech I wrote handles the sprites receiving those shadows and reacting as if they had real texture that responds to light.
Finally, now you can see the same thing, but this time from the game view with all the shader tech enabled.
And there you have it, realistic lighting and shadowing in a top down 2D game :)
So, there’s a quick look at our lighting tech, I hope you enjoyed reading and if you want more tech updates like this or behind the scenes info, let me know in the comments!
Kind Regards,
James.
Xenosis: Alien Infection is being crowdfunded on Fig, visit the campaign here: http://www.fig.co/Xenosis
0 comments