Interesting! How much more complicated would it be if the obstacles were not polygons but points on a grid? I've always been curious how the FoV was computed so fast in the Baldur's Gate games given the complex grid-based map and the weak harder at the time. Example grid: http://aigamedev.com/static/tutorials/FPSB_bg_rsr.png And the FoV rendered: http://cdn.wegotthiscovered.com/wp-content/uploads/Baldurs-G... (the ro…
Show HN: 2D field of view demo
21–30 of 80 posts
Re: Show HN: 2D field of view demo
#22Interesting! How much more complicated would it be if the obstacles were not polygons but points on a grid? I've always been curious how the FoV was computed so fast in the Baldur's Gate games given the complex grid-based map and the weak harder at the time. Example grid: http://aigamedev.com/static/tutorials/FPSB_bg_rsr.png And the FoV rendered: http://cdn.wegotthiscovered.com/wp-content/uploads/Baldurs-G... (the ro…
Re: Show HN: 2D field of view demo
#23I found a bit of a weird 'bug', where I could get the POV to have a straight edge (rather than the curvature), if it's of any use: http://imgur.com/a/MPzGa
Thanks for reporting this ;) This is a floating-point comparison problem, I faced it frequently during development; need to play more with it to arrive at a better epsilon ε value.
Re: Show HN: 2D field of view demo
#24Re: Show HN: 2D field of view demo
#25Here's an interesting approach to do this from a game worked on by Shamus Young, http://www.shamusyoung.com/twentysidedtale/?p=20777
Re: Show HN: 2D field of view demo
#26In case someone is interested in the design: https://bbcdn.githack.com/rmsundaram/tryouts/raw/e06259fffad... Devising the algorithm took around a month; did it in my free time. The implementation took a week, in HTML5 Canvas/JavaScript. Doing a 360°, not-bound-by-distance FoV would have been simpler, but FoV limited by both angle and distance took time. The idea is to find the field of view of an observer on a map wi…
Re: Show HN: 2D field of view demo
#27Re: Show HN: 2D field of view demo
#28Earlier quoted context omitted.
Thanks for reporting this ;) This is a floating-point comparison problem, I faced it frequently during development; need to play more with it to arrive at a better epsilon ε value.
I found different bug. Might it be the same issue? https://imgur.com/Rxaq72M
Re: Show HN: 2D field of view demo
#29This brings back memories of playing Commandos: Behind Enemy Lines: http://store.steampowered.com/app/6800/
Re: Show HN: 2D field of view demo
#30* First render the scene in 3D, from the viewer's position, using a perspective transformation with the right field-of-view to match the "bounding angle".
* Save the resulting Z-buffer into a texture.
* When rendering the 2D, top-down scene, you can consult the Z-buffer (now a texture) to see whether that pixel should be highlighted or not.
I think this is a technique that's already used, but almost complementarily, to calculate shadows from dynamic lights.