Jump to content
  • Advertisement

Unity Weekly Updates #35 - Can You See Me?



Well hello there! And welcome to this new installment of your favourite Weekly Update blog!

I won't lie: this week wasn't as productive as I wanted.

Although I was able to still add some new things in the game taking care of my niece and nephew took most of my time (especially earlier this week).

Nevertheless, there's still new stuff to talk about, so let's get right to it.

New gun animations

First thing first, let's talk about the gun.

For those who didn't know there's a gun in the game. With it, the player can have a ranged weapon that doesn't need to charge to the expends of having limited ammo compared to the bow.

Previously the gun was completely static: it didn't move at all.

Now there are new animations for it.

When the player reloads the gun you can now see the actual reloading.

Here's a video of it:


Another big thing is that now the game occludes obstructed rooms.

Previously when the player clears a room the next one is activated and fully rendered. It was fine at the beginning of the level, as there were only a few geometries to render. 

However, as the player advanced the number of geometries got progressively bigger and bigger, to the point where the framerates were taking a noticeable hit.

Unity themselves recommends to keep the vertices count below 200k, but with all the geometries rendered at once (even for a low poly game) I actually was well above 200k. This meant FPS that got below 25 (yikes!).

Of course, it was unacceptable. The game needed to be able to hide unseen geometries. Here comes our hero: Occlusion Culling. 

The idea is quite simple really: hide geometries that are occluded by others.

Unity actually got their own Occlusion system, however, to function properly it requires baking. Needless to say that for a procedurally generated roguelite baking was out of the question. In order to fix this, I needed to implement my own occlusion algorithm (or at least integrate one).

Enters portals.


I've may or may not mentioned this before but I used to makeTF2 maps in my spare time. It was fun and all. 

The Source engine can look quite archaic on the surface, but there's a lot of interesting technologies here too.


One of them was the use of Area Portal. These were specially marked brush that indicates some type of opening (a window, door. hole and whatnot).


The idea is that when the player is inside a completely closed area it skips rendering any other area. This is effectively some kind of occlusion by itself.

This applies to properly closed areas. If the area isn't properly closed (AKA there's a leak) then that functionality is not applied, meaning that everything will be rendered at once.

In some area (like a house for example) there are actual openings like doors and windows. On the surface, you might think that once in the house the engine got to render everything as it isn't a sealed space. But we can do better...

This is where the area portal brush gets quite useful. With it, the mapper can tell the game that this whole is a portal to the outside. Once this is said the engine can now shut it close and open at will.

Once closed, every geometry outside the sealed area will be skipped. If it's open then the engine will only show the geometries in the direct line of sight of the camera.

This is quite useful. By doing this we can hide unseen geometries and save ourselves some frames.



Because I already knew about Area Portals I knew that this was the way to go with the game as well.

The Algorithm

To be frank, I didn't come up with the implementation myself, but I did get the main gist of it.

(To illustrate this I'm taking a top-down view but you'll get the idea)

The idea with portals is that each portal describes a connection between two areas. 


If the camera is in a given area then we check each of its linked portals and do a bit of testing.


Fist, we need to find the actual visible part of that portal. To do this we simply need to protect the camera's frustum onto them (essentially taking a slice of the viewing pyramid)


If the camera is in full view of the portal then its B area is activated.

We then recursively test the other visible areas by getting each point of the projected camera frustum and creating another frustum from which we basically do the exact thing until there are no more visible portals.


And voilà! All our visible rooms are rendered!


In essence, we're basically checking whenever or not two portals overlap each other. If it is them we render the connected room.

With this, depending on the level I can get the vertice count below 100k. This effectively means glorious 60 FPS!

The whole algorithm is actually based on Id Sofware's DOOM 3 code (idWinding). The only thing is that it translated for Unity. 

Here's where I've got the code from.

I won't lie though: there's still a bit of bug here and there but nothing that a nice debugging session can't solve...

I would show you this but, well, it's occluded...

Minor changes

  • Added a grass density calculation.
    • Previously every room got a set amount of grass strains.
      • This meant that small grass patches were densely populated with strains
      • This wasn't really good on the CPU and on the aesthetics
    • To remedy this I've simply added a density function that calculates the number of strains a room need based on the amount of grass square it got.
  • Added even more LOD models (I'm on a roll bae)
  • Changed the appearance of liquids
    • Now the liquid floor looks a lot deeper.
    • There are also new SFX playing when a collectable items fall in a liquid floor.
    • Changed steps SFX so it sounds like the player is swimming through it rather than walking on it shallow depts. 
  • Fixed bugs with the ammo counter not being displayed when picking up a gun.
  • Fixed a bug with gun reserves not getting loaded in the gun properly.
  • Remodelled the mall models to patch up any holes in the geometry.

Next Week

Next week is probably going to be me finishing up LODs and whatnot. I also need to fix bugs with the occlusion algorithm.

Other than that I really want to touch-up enemies. Probably add another one or changing that behaviour tree altogether...

Otherwise, it's the usual suspect if I have time.

I'm trying as much as I can to get that demo up, although for some it might be too early yet (It's only been technically like about 7 months in development so yeah)


Recommended Comments


Posted (edited)

Hammer was a great tool.  It was the first program I learned that allowed users to create game content.  Great memories.  When I uploaded my map in 2006 it got 4 downloads haha, and it had models made in milkshape ( where I drew inspiration for z-model ).

Edited by Awoken

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By RoKabium Games
      ALPHA TESTERS WANTED! Our PC game "Something Ate My Alien" is starting public testing today! If you would like to test our game, contact us or visit the link below:
      SAMA forums: http://bit.ly/sama-testing
    • By AtomicBrain
      Hi all. This is a small little arcade game that I have been working on for the past 6 months.
      Move the ball behind your finger and avoid obstacles.
      The speed of obstacles gradually increases, slowdown them with simple movements of a finger.
      Collect coins and discover new ball styles. More coins - more styles!
      Compete with friends: check whose finger is faster!
      Link: https://play.google.com/store/apps/details?id=com.Brain.JustMove
      Gameplay video: YouTube

    • By horror_man
      Hello, I'm currently searching for additional talented and passionate members for our team that's creating a small horror game.
      About the game: The game would be a small sci-fi/post-apocalyptic survival horror 3D game with FPS (First person shooter) mechanics and an original setting and story based in a book (which I'm writing) scene, where a group of prisoners are left behind in an abandoned underground facility. It would play similar to Dead Space combined with Penumbra and SCP: Secret Laboratory, with the option of playing solo or multiplayer.
      Engine that'd be used to create the game: Unity
      About me: I'm a music composer with 4 years of experience and I'm fairly new in this game development world, and I'm currently leading the team that'd be creating this beautiful and horrifying game. I decided that making the book which I'm writing into a game would be really cool, and I got more motivated about doing so some time ago when I got a bunch of expensive Unity assets for a very low price. However, I researched about how to do things right in game development so I reduced the scope of it as much as I could so that's why this game is really based in a scene of the book and not the entire thing. Also I'm currently learning how to use Unity and learning how to program.
      Our team right now consists of: Me (Game Designer, Creator, Music Composer, Writer), 4 3D Modelers, 2 Game Programmers, 1 Sound Effect Designer, 1 Concept Artist, 1 3D Animator and 1 Community Manager.
      Who am I looking for: We are looking for a talented and passionate programmer that's experienced with Unity and C#.
      Right now the game is in mid-early development and you can see more information about it and follow our progress in our game jolt page here: https://gamejolt.com/games/devilspunishment/391190 . We expect to finish some sort of prototype in 3 months from now.
      This is a contract rev-share position
      If you are interested in joining, contributing or have questions about the project then let's talk. You can message me in Discord: world_creator#9524
    • By RoKabium Games
      A message from the Aliens for this week's #screenshotsaturday.
      Happy Easter to all!
      If you're looking for something to do, why not join our Alpha testing?
      Check it out at this link: http://bit.ly/sama-testing
    • By Veizyr
      Hello people! We have a spot open in the team, here's a little bit about the game and the team making it!
      About the game: The project is a 2D trading/combat/exploration oriented game set in a medieval fantasy world developed in unity. It involves several different play styles like turn by turn combat, board game style exploration and more! As far as we know, nothing like this is currently on the market and therefor kind of hard to pin down into a specific genre. We're going for a pretty gloomy theme and putting a lot of focus on the art style, animation and music.
      Our team: The project is in it's very early stage and we are currently building the team. We currently have an environment artist, two programmers, a project manager, a writer, a composer and a sound designer. We will be adding more team members as the project moves forward. Our current goal is to build a small prototype to be able to present for further development.
      What we need: - A 2D artist aiming for unique character designs and if possible, animation. (no pixel art)
      If you think your unique style could fit with our game and are up for a challenge, contact me on discord at Veizyr#1797 for more details. We'd love to see some of your work and chat more!

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!