r/roguelikedev • u/GreedCtrl Hex Adventure • Jul 01 '20
FOV: Shadowcasting
I wrote an article on shadowcasting, my favorite field of view algorithm. Shadowcasting is well-known for its speed, but sometimes cited as asymmetric. It can easily be made symmetric, which I wanted to show.
But beyond that, I wanted to show an interactive example of how the algorithm works, inspired by Red Blob Games. If any of you want to tinker with Field of View, or just want to better understand how it might work, I hope this helps.
And visualization is fun :)
It almost tempts me into showing the behind-the-scenes dashed lines in a roguelike.
8
u/MikolajKonarski coder of allureofthestars.com Jul 01 '20
Impressive article.
I doubt the point saying "it maps exactly to line of sight with Bresenham’s algorithm". If you mean the non-generalized Bresenham’s line, not a general digital line, then it can't be so, because Bresenham’s line is not symmetric and your FOV is, right? And if that was true for the set of all digital lines, it would probably imply your algorithm is Digital FOV and obviously, at most, the version for sight originating at wall tiles is (I didn't quite get it, so I'm not sure if that's only used for wall tiles or for all; in the latter case, it's probably Digital FOV or perhaps Permissive FOV, indeed). I'm a bit fuzzy here --- perhaps you take the set of two Bresenham's lines drawn in both directions instead of the set of all digital lines? No sure if that makes sense.
2
u/Sp3ci3s8472 Jul 04 '20
Very nice article! Love the interactive things.
How does your algorithm compare to Adam Milazzo's algorithm in terms of speed and results? At first glance when I try to rebuild the comparisons from Adam's blog It looks like a less permissive version of shadowcasting? I would be interested in seeing a small comparison. Nevertheless I might implement it in my game where I currently use Adams algorithm.
3
u/FratmanBootcake Jul 01 '20
Thanks for the article. I've scanned it and it looks good and it's come at a great time too! I implemented recursive shadowcasting in my c++ project for the code-along. Here's the result. I'm generally happy with it but would like to tweak it and also to reduce the artefacts like seeing through single width diagonal walls.
I'll have to give the article a proper read when it's not so late.
2
u/[deleted] Jul 02 '20
Thank you for the article! After implementing my own simple FOV just yesterday for this week's task I can clearly see the limitations of my approach and I can see that you have covered them! I have save this link and will be looking into improving my implementation based on your article once I have completed the tutorial series and have a handle on the basics. Thanks once again for taking the time to write this up! :-)
1
u/Del_Duio2 Equin: The Lantern Dev Jul 02 '20
This is cool. I'm currently working on a new roguelike and have been seriously considering having a darkness / FOV however I have almost zero experience with these. Usually I'll have a "darkness floor" where you can always just see the immediate area around the player instead.
1
u/[deleted] Jul 02 '20
Extremely high effort article, well done!
1
u/redblobgames tutorials Jul 02 '20
Woah, cool! I've been wanting to understand how this algorithm works.
1
u/chrisrobertrowe Jul 03 '20
This seems extremely cool and I would love to see more interactive articles like this.
1
u/gawwo Jul 03 '20
Thank you for the article. Really impressive quality. Can't wait to port it for my roguelike this weekend
1
u/Zireael07 Veins of the Earth Jul 04 '20
The interactive examples are simply brilliant! <3
(I discovered my FOV is broken, so I have to go back to the basics :P )