Lighting up all triangles between two points in a mesh?

Ok, so I’m working on a type of fog of war that’s supposed to simulate the vision from a point, so that you can’t see through walls an so forth. This picture might help to explain:

I cast rays in 8 directions (Perhaps not the final amount) and detect the walls and illuminate the triangle in the plane where the ray hit the wall. All I want to do now is to illuminate the areas between these triangles. What would be the best way to do this? I’ve thought about it for some time but I can’t come to a solution. I’ll be thankful for every bit of help I can get, thanks!

Here’s a hack for you until you find something better :slight_smile:

Let’s assume all the triangles like to place tennis, so between all the points on the triangles, place a plane pointing upwards. Now RaycastAll from the current position across all the tennis nets (planes). For all the hits, record the triangle that it is connected to. Now just go through your triangles and light them up.

I say its a hack - a better answer is probably to go find yourself code that works out line segment to line segment intersection, then use the triangle vertices as the points for each line segment (like the nets). Of course, most examples online will likely be right hand coordinate while Unity is left hand so you’d need to replace y changes with z for 3D verts. Enjoy :smiley: