Pesky Shader Warning

Started by
5 comments, last by Geometrian 15 years, 5 months ago
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:
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
}
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

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Advertisement
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?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

You need the inout
vec4 func(inout vec3 passed_variable)

http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes#Functions
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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;}

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

unfortunately, changing to
vec4 outline(inout vec4 color, in float threshhold, in vec4 setcolor, in vec3 norm)
doesn't work either.
-G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

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?
changing inout to in doesn't fix the problem. Passing in the float is a good idea. It doesn't fix the problem though.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

This topic is closed to new replies.

Advertisement