Author Topic: Volumetric Lights And Custom Frustrum Culling  (Read 13690 times)

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Volumetric Lights And Custom Frustrum Culling
« on: August 02, 2016, 01:05:36 pm »
Original: http://arcengames.com/volumetric-lights-and-custom-frustrum-culling/

What!?  Shouldn't this post be about procedural generation or new robots? ;)  That stuff is coming, don't worry.  As you can see in the release notes, a lot of work has been done on that.  But in the meantime I did want to do a release with a few other things in it.

HolySmokesDeepFog

Volumetric Lighting

First up, we're now using the brand-spanking-new Hx Volumetric Lighting component from Hitbox Team, the folks behind Dustforce and the upcoming Spire.  I figure I owe them some shout-outs there, because their work on the volumetric lighting is so freaking fantastic.

It has a moderate impact on framerate, depending on your graphics card.  For a lot of lower-end cards you'll need to turn it off.  But for folks running on middle-high or high-end rigs, this is something that really takes the game to the next level visually.

This is something I've wanted to do for quite some time, to give more of a sense of atmosphere to the game.  However, short of particle effects that can look iffy, and a few light-specific options that usually have iffy performance, there's been no good way to do that until now.

IndustrialDemo

Anyway, so, that's neat.  That will make for some nice differences in the next round of videos, so I'm pleased to get that in now.

Obviously this is an effect that is not to be used on every last freaking light in the game -- sometimes it's really nice to have crystal clear areas that just pop with sharpness.  Other times you want a slight bit of softness, and other times you want something that's super foggy.  The point isn't that we're switching over to deep fog all over the place, but that we now have a greater depth of mood effects we can go for.

The screenshots in this post are really leaning on higher-volumetric views, though, since that's what is new; the non-volumetric views don't look any different.  Oh!  And if you hate it, you can always turn it completely off.  So, as with all things, tune to taste.

VerySlightVolumetricApartment

Custom Frustrum Culling

Occlusion culling is a complicated subject, particularly in games that are partly or completely procedurally-generated.  What it means is not rendering things that the camera can't see.  The biggest problem is knowing what is behind other opaque stuff and thus invisible.

Unity has some built-in support, but only for static levels, not procedurally-generated ones.  I created my own occlusion culling system that works on procedurally-generated levels, but the levels have to be designed with the occlusion system in mind or else it doesn't work to full effect.

However, there's also a middle-tier of object culling that is based around the "view frustrum."  Aka, the view out of your camera based on where it is pointed right now and what your FOV is, etc.  Put another way, it's to avoid drawing things that are either offscreen to your side or behind you.

ThatHallAgain

Unity has a built-in way of handling this, too, and I had -- until now -- not bothered to create my own.  I'm not in the habit of trying to reinvent the wheel for no reason.  However, I found that unity's solution has some really strange issues with false-negatives when the camera gets close to a wall.  Basically it would stop drawing certain objects that were straight in front of me once my camera got a bit close to the wall behind it.

Imagine having your head leaning back against a wall, and the wall on the other side of the room in front of you mysteriously disappears.  Um... no thanks on that.

Apparently with any of Unity's occlusion culling on at all, it was trying to do a mixture of occlusion culling (what is behind something else should not draw) and frustrum culling (what is out of my view should not draw).  And when I got really close to a wall with the camera, it decided "oh hey, you must be on the other side of that wall."

HolySmokesDeepFog2

I've known about this for well over a month, and I figured that the solution was to get the camera to stay a bit further from the walls.  Turns out... nope!  That doesn't work in any way that I can figure out.  I thought that it perhaps was related to concave mesh colliders, but nope there too!  I was really surprised, because I thought for sure that was the one.

I had turned off unity's occlusion culling a few weeks ago because of the graphical errors it was introducing, but then performance took a big hit and so I turned it back on.  Now the graphical errors were getting on my nerves increasingly, so I decided to once again disable their system, and this time come up with my own frustrum culling system.

So I did.  It works!  No false negatives.  It seems to have a very similar performance profile to what unity's system did, but minus the errors.  Knock on wood that's what others also experience with it!
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline crazyroosterman

  • Master Member Mark II
  • *****
  • Posts: 1,558
  • Cluck.
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #1 on: August 02, 2016, 02:59:07 pm »
so I suppose this frustum culling as you call it will improve its performance? you'll certainly get no complaints from me there.
although ill probably end up turning those volumetrics off asides from the performance issues that looks like it'll be really disorientating to me during play.
c.r

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #2 on: August 02, 2016, 03:07:30 pm »
Yep, frustrum culling is 100% about performance.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline tombik

  • Full Member Mark II
  • ***
  • Posts: 172
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #3 on: August 04, 2016, 07:55:39 am »
Looks really neat!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #4 on: August 04, 2016, 11:49:56 am »
Thank you!
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #5 on: August 05, 2016, 03:09:47 am »
Is this the Unity AO implementation? Because I can see some "fringing" especially in this one

http://arcengames.com/wp-content/uploads/2016/08/VerySlightVolumetricApartment-1024x576.jpg

this artifacting is why HBAO+ was developed. Is it feasible to include this in this game?
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Volumetric Lights And Custom Frustrum Culling
« Reply #6 on: August 05, 2016, 09:58:21 am »
That is HBAO.  The fringing in that case is I believe actually light bleed which has to do with some of the shadow issues that unity's lighting system has.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!