Wall Visibility, and Vision/Light Ranges

Hey Folks! A bit more progress today, as you can see from the image. I got a slightly better wall visibility trick working, and I'm working on limiting vision/light range.

Yesterday's trick to get walls visible was a bit hacky, and I wasn't thrilled with it. I basically just extended the vision rays outward a bit so they revealed chunks of the walls that stopped them. However, it revealed walls in weird slanting angles, and it was a bit distracting when they moved around. Interesting to look at, but for the wrong reasons.

As a test, I scrapped that approach and tried a different one. Namely, what if I add extra quads to the end of each vision cone, covering the block that stopped it? Then, when it comes time to render, those blockers (walls, furniture, etc.) are fully exposed to the viewer, but everything behind it remains hidden.

You can see it in action in today's image, and I think that's probably how I'll keep it. In first person view, we'd be seeing these walls for what they are, so it makes sense to show the top-down user what they are, too. Even if it is a bit unrealistic.

The next feature that's missing is range. The current system requires bounding objects placed beyond the camera to stop the rays. Otherwise they'd continue on forever, which could mean a lot of wasted processing. By applying a limited range, I can basically ignore light pools that are 100% outside of the screen, or player vision range if I limit that.

So far, it kind of works. I was able to get it to produce acceptable results when the spaces were tightly-packed. But it broke as soon as the player entered a wide open area. Imagine an analog clock face, and a situation where we can see everything from 2 o'clock to 9 o'clock. It's a big, sweeping angle from upper right, through the bottom, to the left. The visibility code tries to draw a triangle from the middle of the clock to 2 and then 9, and we end up with a thin sliver running between them, instead of a fat semicircle covering the lower half of the clock.

The solution, I'm hoping, is to notice when these angles are really far apart, and insert some segments in there so we never do more than 45 degrees at a time. So even if we were in an open field, the game would draw an octagon around the center. And in the case of lights, with a radius slightly larger than the light range, so we don't see the hard edges.

That's the theory. Still working out the kinks!

Tags: Ostranauts


ra1's picture

45 degrees seems too narrow. How about 45 degrees for long range (small cone), but 90-120 for close range (left & right outside cones).

dcfedor's picture

I might not have explained that very well, because it sounds like we're talking about different things :)

The view angle is currently 360 degrees, so line of sight and lighting both project outwards in all directions. The 45 degrees thing just refers to the minimum number of segments as the circle around the player is swept. This means we never have more than 45 degrees before another segment is added, resulting in a minimum complexity of an octagon around the player.

So if two walls are 180 degrees apart from the player's point of view, the game will insert vertices between them such that we get a nice circle instead of cutting the view too close to the player.

I should really have just drawn this first :)


Dan Fedor - Founder, Blue Bottle Games