I am working on a Fog of War shader for a space game. I am trying to get a collections of positions as Vector3s, and a radius for each one, and send them to a Shader Graph. This is so a gap can be drawn in the fog, in the area around the Vector3 created by the radius.
I think this can work in a normal shader, but I can’t seem to figure out how to pass arrays to a Shader Graph at run-time.
Is this possible? Or should I look into a regular shader.
Shader Graph doesn’t have array for floats. But you can use custom functions. Unfortunately you have to code it yourself but you don’t have to code all complex fragment and vertex pragmas. Just pass your array and world space position to your custom function using “material.SetVectorArray” and calculate lighting for each position. But it is expensive due to iterating too much, especially if you are doing dividing operation.
Another approach can be using render textures but I’m not sure how it can be done.
The lighting should not be too bad, the fog is unlit. Some of the vectors are going to be moving every frame, so there will be updates on where the drawing should occur.
I will have to brush up on my Shader coding for this one… I’m sure a fragment shader can set transparency for each pixel within the vector3 radius. Not sure how to do it without looping over each position each cycle.