I’m editing shaders for a game and i came up with a problem.
There are two files: x.vertex and x.fragment. I’m creating a varying vec3 POS in the vertex file to pass data to the fragment file. Howerver, sometimes POS doesnt get defined in the vertex file, so my code crashes in the fragment file if i try to use it. Is there a way to determine from .fragment file if the variable was defined in the .vertex file?
Pseudocode might look like this:
.vextex
varying vec3 POS = vec3(1.0, 1.0, 1.0);
.fragment
varying vec3 POS;
float data;
if(defined(POS)){//i dont know what to do there...
data = POS.x;
}
data = POS.x;//if i just write this it crashes
I can add the actual code if needed.