varying vec3 var;
vec4 func(vec3 passed_variable)
{
float z = abs(passed_variable.z); //The problem arises here
//do stuff and return
}
void main()
{
//tons of stuff omitted
color = func(var);
//some more stuff
}
Pesky Shader Warning
Hello again,
I'm not an amazingly good GLSL programmer yet--mostly it's just the syntax, (I'm used to Python). I'm getting a warning, and though I know where it is, I can't fix it. Here's some simplified fragment shader code:The specific error I'm getting is "warning C7050: "$temp0011" might be used before being initialized". This is a pretty simple problem--just, how do I fix it?
Thank you,
Geometrian
There doesn't appear to be any problem in the sample you gave - can you post the entire code, so we have a chance of uncovering your error?
You need the inout
vec4 func(inout vec3 passed_variable)
http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes#Functions
vec4 func(inout vec3 passed_variable)
http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes#Functions
OK. I can give more, but really, the entire shader is pretty big.
varying vec3 normal;vec4 outline(vec4 color, float threshhold, vec4 setcolor, vec3 norm){ float normz = abs(norm.z); if (normz < threshhold) { return setcolor; } return color;}void main(){ vec3 n = normalize(normal); //color vec4 color = vec4(0.0,0.0,0.0,1.0); //color is changed here by textures, colors, lights, etc. color = outline(color,0.5,vec4(0,0,1,1),n); gl_FragColor = color;}
unfortunately, changing to doesn't work either.
-G
vec4 outline(inout vec4 color, in float threshhold, in vec4 setcolor, in vec3 norm)
-G
Quote:Original post by Geometrian
unfortunately, changing to *** Source Snippet Removed ***doesn't work either.
-G
Shouldn't color just be in, not inout? (Though that may be utterly unrelated to your problem.)
Also, why not just pass in n.z since you only use that in the function?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement