1
\$\begingroup\$

After much fiddling around and thinking I've got my AO working on my game engine as intended; except one specific case.

Example Diagram

When a block is nestled between others on two sides, but the corner block is missing, that corner doesn't get occluded. This isn't too shocking, because there's no logic to do otherwise. However, I can't think of a way to neatly solve that case. If I make it detect a block on each pair of sides, then check for the corner piece, we will end up with lots of broken AO in various scenarios, and that will be a lot of checks to boot.

Here's the table I came up with today which finally solved the missing bits of my AO algorithms:

AO Table Click for larger view

The logic in my code (C# MonoGame) essentially enforces this table.

If nobody comes up with anything better, I'll put a series of booleans in the checks for each side, then run through each combination and adjust as though a pair of side block were the corresponding corner block.

\$\endgroup\$
  • \$\begingroup\$ I've discovered a few mistakes in the table, which account for some bugs in the AO. There's still another few bugs left to find, but that shouldn't have any bearing on the question. I will, however, post a corrected table once I've finished checking it. \$\endgroup\$ – Yushatak Oct 8 '14 at 13:33
  • \$\begingroup\$ That's a very cute way to tackle the problem in a non-computation intensive manner. \$\endgroup\$ – v.oddou Oct 9 '14 at 8:24
  • \$\begingroup\$ lol, thanks. Since it's just a cube terrain I saw no reason to do a bunch of raycasting/etc.. \$\endgroup\$ – Yushatak Oct 9 '14 at 13:49
0
\$\begingroup\$

Fixing the table helped a lot, but the main issue I had was I was assigning the wrong AO values to the NegZ and PosZ face vertices. This meant that when I tried to fix things, other things broke as I tried to compensate for the unknown variable of the Z axis being rotated.

The table in the original post is updated, but basically the side cases shouldn't affect their own axis, and should affect the others. There were also a few mistakes of which values in a few spots. Everything's good now!

This table would have been invaluable to me if I'd found it online when starting this, so hopefully someone else finds it useful. If you do, let me know - I'd like to hear that all the work I put into that table is appreciated by others. :3

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.