~ Remember when you gathered in your basement for all night long playsessions?
To fight critters and try keeping your eyes open at 4am?
We do, and we want to have it all again. ~
Biosignature - escape from ice moon is an aliens-like 80s scifi Top-Down Shooter
for up to 4 Players on the couch/online or mixed if you like
Well hello again! The past week was probably one of the hardest for me in all the development process. I ran into a problem that occured as a side effect of me wanting to have the levels spread over multiple floors.
You want to always see your player character!
As simple as it sounds – with a top down camera, it’s totally not. Whenever you are in a room which is below another room on a higher floor, you won’t see anything anymore because your camera will show you the upper room instead:
So what you naturally want to do is to somehow hide that room. Thing is, how do you figure when and what to hide? There are a few options available, but not every option is applicable for my case:
So the third option was the most appealing to me, however I’d need to somehow force it to cull the way I want it to cull, which means I had to:
Customize the cameras projection matrix
Now what the near clipping plane does is clip away anything closer to the camera than a defined distance. Modifiing the distance during runtime looks like this:
So this is not really helpful yet. I need to find a way to have it clip away along the y-axis instead, and what I need to achive this is: Matrices. I was very good with matrices back at the university, but boy is that long ago. So what I naturally did was Google the shit out of it. And Google delivered, I found that I will need the camera have an oblique projection matrix to compensate:
Basically the near and far clip plane should align with the xz-plane. And after a rough evening, I had a decent result:
Only that on the very next day, when I moved from the test scene and tried to implement it into the actual game, I learned that this actually does completely mess up the lighting, at least in deferred rendering. When the GPU renders shadowmaps, it needs the original projection matrix to work properly. So changing the actual projection matrix is a dead end for me. But there is one more option:
Customize the cameras culling matrix
Yes, you can also do this instead. However it turns out that you can’t just use the previously calculated oblique matrix. I can tell that because I tried it The results are just plain wrong. Some research on the forums point to the culling matrix is somehow not based on the cameras origin but somewhere else within the camera space, most likely its somehow married with the near clipping plane. If you know how to get the matrix right, please let me know! In the meantime, for me it meant it was time to get creative. Fortunatly the Unity documentation pointed to another interesting direction. They use a second cameras matrix on the main camera. So what I did was this:
And thats it!
Addendum: Since the new camera has a FOV of 180° it would actually see far more on the same level, so I also added a light weight manager that additionally culls static room geometry which is more far away, just for more optimization, however thats only the stuff I know from the generation process, so just some lines of code:
Edit: I put some more work in optimization and added selective Frustum culling. This brought a huge boost in render performance:
PS: New Unity version came out a few days ago, with a new command buffer command that could change the projection matrix during rendering, however it did nothing for me. Maybe that could save me the second camera, if anyone knows more, please tell me! ;-)
That is all for this week and I return to finish the cyclic level generator! See you next time,
Exploiting Unitys lightcookies and a new, innovative level generation approach.
We had a nice test session on friday and here's videofootage! I also worked on distributing gameplay in the level generation process and live.
Finally the game has a title! I also finished the player characters (first iteration) and I added camera rotation control for more emphasis on the 3D...
Introducing Biosignature, an Aliens-like 80s SciFi coop Top-Down Shooter
No articles were found matching the criteria specified. We suggest you try the article list with no filter applied, to browse all available. Post article and help us achieve our mission of showcasing the best content from all developers. Join now to share your own content, we welcome creators and consumers alike and look forward to your comments.