2D Line of Sight + Visibility Calculations I am currently working on an algorithm to calculate visibility in a 2D top-down level.

The level contains


actors, with position and "sight" information
walls, with start &amp; end positions
light sources, with position and range


I have written a fragment shader that renders my scene based on a texture I compose of the informations above.






Red channel = line of sight for actors (in the example just the selected token is an actor)
Green channel = light sources with their range and their respective line of sight
Blue channel (not present in example) = night-vision of actors (means areas are shaded despite no light present)


I am using Babylonjs and am naively rendering all those calculations one after the other into a DynamicTexture using the canvas 2d context.

Can I use the GPU for some of these calculations (or all?) I am no expert for shader programming and don't know where to start / look.

The code for my line-of-sight calculation can be found here: https://gitlab.com/aiacta/visibility
In this SIGGRAPH paper is described a similar operation for the visibility calculation from every pixel in the domain (you only need calculate it from actors position), which has been implemented in GPU. 

Although it is oriented to fluid dynamics, it may be a starting point to look.

You can see other related shader examples like this one with implicit geometry.