Here's an interesting approach to do this from a game worked on by Shamus Young, http://www.shamusyoung.com/twentysidedtale/?p=20777
Show HN: 2D field of view demo
31–40 of 80 posts
Re: Show HN: 2D field of view demo
#32In 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
#33In 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
#34Re: Show HN: 2D field of view demo
#35Earlier quoted context omitted.
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
#36Earlier quoted context omitted.
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)
Wow, the visuals look stunning, I like the noir theme!
Re: Show HN: 2D field of view demo
#37Earlier quoted context omitted.
Not the example code I pasted into the blogpost. To be honest, its not an obvious candidate for offloading the the GPU. Its a light task, the result is probably wanted by the CPU, and these days we probably have spare CPU cores that could be utilized while the GPU is busy. However, with the move towards UMA for CPUs and GPUs - even the newly-announced ARM cores with Mali GPUs have coherent caches between CPU and GPU…
> the result is probably wanted by the CPU -- I think this is a good reason to do it in the CPU. > its not an obvious candidate for offloading the the GPU -- How? Shooting a ray to every vertex comes to my mind.
http://i.imgur.com/ZJhr4Ll.png
The "player" is sitting on the "wall" of a room, to the right of it there are stairs going "downwards", it's all just a heightmap.
Needless to say it's kinda slow, but I was surprised how neat it came out considering how little I put in. I'm sure someone who knows what they're doing (which isn't me) could do the same a lot faster and prettier, since I really did it in the most plump way possible.
Re: Show HN: 2D field of view demo
#38This 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…
Re: Show HN: 2D field of view demo
#39Re: Show HN: 2D field of view demo
#40Both the idea and the algorithms are decades old and were already used in the 80s and 90s computer games like Wolf3D and Doom.