Live data from Hacker News

Show HN: 2D field of view demo

jsfiddle.net

21–30 of 80 posts

Re: Show HN: 2D field of view demo

#21

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…

Looking at this with a decent understanding of how the computing world works today, I have an immense appreciation of all the work and care that went into the iconic classics such as Baldur's Gate. The combination of technical skill, ingenuity and also the (presumably) passionate creative focus and attention to detail when creating and integrating the artwork is just incredible.

Re: Show HN: 2D field of view demo

#22

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…

The roguelike development community has spent a lot of time thinking about this problem: http://www.roguebasin.com/index.php?title=Field_of_Vision

Re: Show HN: 2D field of view demo

#23

I 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.

I found different bug. Might it be the same issue? https://imgur.com/Rxaq72M

Re: Show HN: 2D field of view demo

#26

In 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…

Well done! It's almost the same algorithm I came up with in one sleepless night, 7 years ago. I used it in a game that was not finished: http://feiss.be/games/luxi (shameless Show HN)

Re: Show HN: 2D field of view demo

#28
post #23

Earlier 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

This is new! I'd never hit it. But it seems the angular point sorting is off, can you please send the browser and its build you are on? I'm unable to reproduce it.

Re: Show HN: 2D field of view demo

#30
This is some interesting work! I was musing about another algorithm to achieve the same effect, as I was reading:

* 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.

Post reply on HN