Sign in to follow this  

Pesky Shader Warning

This topic is 3312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

This topic is 3312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this