I am trying to finish a game prototype at home and I haven't been able to solve one problem.
I have implemented a c++ version of the 2d Visibility algorithm to simulate lights but also to simulate enemies perception cone.
This is a link to the algorithm: http://www.redblobgames.com/articles/visibility/
And this is the result I expect to achieve:
[youtube]IHlHHLAIMx8[/youtube]
I got it working perfectly but now I would like to limit the algorithm in distance. I thought it would e easy but it is turning out more complicated than anticipated.
I tried to do it by modifying the algorithm itself but I fail, now I am under the impression I chose the wrong way, since I got the feeling it can be done with a render operation (some kind of intersection between the result of the algorithm and a full perception cone would give me the desired result).
Does anyone have an idea about how to do this? I got the feeling the solution is related with custom shadow mapping but I am not entirely sure.
Any help would be welcome
Kind Regards