Saturday, 15 February 2014

HOQ say hello to HZB

Play

For my leisurely weekend, I decided to tackle the problem of Occlusion once and for all, and to that end spent the first six hours reading every technique every used in computer games from CPU software rendering through to insanely ambitious prediction systems for reducing hardware query checks. The reason I am not satisfied with the current hardware query system in Reloaded is that the object 'popping' you see when you run around corners is not just 'occasional' but pretty much in your face!  No-one has come up with a decent solution to solve the occlusion query popping as it is an inevitable result of having the data for the occlusion cull one frame behind the rest of the visual rendering. Only coherence systems attempt to solve this, but it only amounts to guesswork. I even pioneered some non-white-paper thoughts about creating multiple queries as a product of the player running in several dead-reckoning vectors, but I quickly realized the cost of those queries would be insane, and there are a lot of articles out there which feverishly attempt to reduce query count so why would I deliberate make multiples of them!  Here are my brain storming notes from the day:





During my researches, I stumbled onto a technique called Hierarchical Z Buffers (used in several top end games you know) which basically renders a smaller version of the scene into a depth buffer and squashes it down into a real-time mipmap. It is then used in concert with any object you wish to test the occlusion state of using some pretty wicked GPU based test. The wicked part is how they get the DX9 test data back into system memory ;)

I did not wish to go this route originally as adding another pre-render to the scene seemed like spending more GPU time than saving it.  It's now nearly 3AM and I want to eat and watch a movie before I sleep, and I am currently at the point where most of the C++ code is in a new set of DBP commands and I just need to establish some occluder candidates, create an object bounds database and then set the object visibility flags.  These last three steps should allow me to choose key occluders from any Reloaded scene, then sit back and watch as the GPU performs full occlusion testing with a single draw call and instantly rejects thousands of arbitrary objects from the scene :)  I will know more come Monday afternoon, but the early results are exciting!

I have recently discovered how to use Microsoft PIX properly (now replaced with the VS graphical debugger) and have been having a whale of a time watching the scene built up one draw call at a time. I plan to use this tool A LOT now I know where all the buttons are. For those who just fell over in shock, I do admit that I was one of those coders who mostly 'guessed' where the rendering problems where in my engine. The upshot of course is that these days my guesses are pretty accurate!

7 comments:

  1. Awesome blog. I like to know this stuff! I'm glad you have mentioned you are adding new, faster commands into DB as many seem to think we are at the limit, when really we are at the limit of old DB Pro, and progressing into new untested waters!

    It also shows the amount of work you put in to get the results needed, you used at least 2 more pieces of paper than I would have ;) Although I would have given up way before, due to being not quite/nowhere near, as talented.

    I'm sending you a demo of a small level I have been working on. Hopefully, it will help you with a few bugs at the moment, and also give you a bit of fun seeing what we users are playing with. The level would probably take 5 mins to make from scratch in Reloaded, if that. After taking into account models and billboards, you can make that 30+ hours, lol. I can't wait to be able to move stuff about a bit to get a more living scene!

    ReplyDelete
  2. Great work Lee,nice to see things are moving on.Love those notes ,looks like a madman at work.

    ReplyDelete
  3. Lee, IMO, what you should be doing is taking one game (if it were me I'd be using Half-Life 2) and trying to recreate it with FPSCR. When you get stuck on something that's not possible in FPSCR, add the feature or fix the bug. When you realise it runs at only 1/8th the speed of HL2, work out why. Find out what Valve did to speed up that shader, or those occlusion queries. Find out how they made great-looking water and copy them.

    As I have said before, you MUST take your cue from biggest and best games and developers. If you don't, you're reinventing the wheel for stuff that has been solved years ago.

    ReplyDelete
  4. Also I forgot to mention: this is one of my favourite posts so far. I love it when we get to see the really technical stuff and the bits of paper you've scribbled on. Also, I think what you've done here is excellent: solve just one problem, do it properly and finally, and research it extensively. Perfect!

    ReplyDelete
  5. Where did my weekend go? I thought I could get occlusion sorted then play a few games. If you read Sunday's blog, occlusion is now sorted and my weekend has gone :( Hopefully next weekend I can blog about something a little more leisurely..

    ReplyDelete
    Replies
    1. Oh no, I feel sorry for you! :( You've been working a whole week straight without a break now! To be honest, I'm sure none of us would mind terribly if you decided to take Monday off instead. Go ahead, play some games, watch Time Team and recharge :)

      Delete
  6. Great work here, lee! I will mess with something for about a week before I start using a paper and pencil, then it's "what was I thinking there". It's good to see that your using magic on reloaded.
    I submit, your kungfu is strong, I cannot defeat you.

    ReplyDelete