Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

Pesky Shader Warning

This topic is 3626 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
Advertisement
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
unfortunately, changing to
vec4 outline(inout vec4 color, in float threshhold, in vec4 setcolor, in vec3 norm)
doesn't work either.
-G

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!