I’m working on a third person game, and I’m trying to make a sight vision triangle (or cone-shaped).
I followed a tutorial to make a shader of fog of war which is what I want actually, but it shapes a circle. Is there a possibility to draw a cone-shaped ?
Video of tutorial with the script of the shader :
Screenshot of my current prototype :
What I want :
Thanks for help, if you need some more information, just ask.
We discussed this in private but I’m assuming posting about it could help people.
My approach would be to keep the same principle, passing more information to the shader: the “forward” vector (where the direction of the vision cone) and the angle of the cone (or this can be hardcoded in the shader).
In the tutorial, a comment says “return 0 if pos - nearvertex > fogRadius”, thats is “keep black every point outside the radius”, you need to implement it such as it ALSO return 0 if the angle between the forward vector and the vector defined by (pos - player position) is superior to a predefined angle.
I haven’t really messed with Unity shaders for a while so I won’t risk a bad implementation but you get the idea.