Re: Field of view algorithm implementation problems



On 13 jan, 09:46, mike3 <mike4...@xxxxxxxxx> wrote:
Hi.

I was trying to implement the "recursive shadowcasting" field-of-view
algorithm for a
Rogue-like game, and seem to have ran into a problem.

Here's what the output I've got at present looks like (use a fixed-
width font to view this):

....sssss..s...ss
 ....ssss#.....ss
  ...ssss#.....ss
   ...ss##..#..##
    ...##........
     ............
      ...........
       ..........
        .........
         ........
          .......
           ......
            .....
             ....
              ...
               ..
                @


If I understand, you mark all cells as 'not visible', then use the
recursive shadow casting algorithm to mark some cells as visible. The
problem is that there are several 'shadow-border' rays that traverse
the cells behind the pillar. Especially, the rays that go through the
cells directly left and right to the pillar go through those cells and
mark them as visible. You should try reverse the whole algorithm :
- mark all cells as 'visible'
- use the shadow casting algorithm to mark cells in shadow as 'not
visible'.
Thus, the pillar will necessarily cast a shadow behind it.
I don't know though if this will not generate new artifacts. If fact,
due to the discrete nature of the bresenham algorithm, I'm not sure
that an artifact-free solution can exist without going to sub-cell
accuracy (using a float for the cell visibility instead of a
boolean)...

--
jice
.



Relevant Pages


Loading