1
Graphics / Re: Problem when getting things to fade to black
« on: May 20, 2013, 02:30:38 pm »
Thanks.
I fixed it. The solution seems a bit dirty but it works.
Updated fragment shader:
I fixed it. The solution seems a bit dirty but it works.
Updated fragment shader:
uniform sampler2D texture;
void main()
{
// lookup the pixel in the texture
int range = 255;
float unit = 1.0f/255;
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
int red = (int)(pixel.r / unit);
int green = (int)(pixel.g / unit);
int blue = (int)(pixel.b / unit);
int alpha = (int)(pixel.a / unit);
red -= 1;
green -= 1;
blue -= 1;
alpha -= 1;
vec4 newCol = vec4((float)red*unit,(float)green*unit,(float)blue*unit,(float)alpha*unit);
// multiply it by the color
gl_FragColor = gl_Color * newCol;
}
void main()
{
// lookup the pixel in the texture
int range = 255;
float unit = 1.0f/255;
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
int red = (int)(pixel.r / unit);
int green = (int)(pixel.g / unit);
int blue = (int)(pixel.b / unit);
int alpha = (int)(pixel.a / unit);
red -= 1;
green -= 1;
blue -= 1;
alpha -= 1;
vec4 newCol = vec4((float)red*unit,(float)green*unit,(float)blue*unit,(float)alpha*unit);
// multiply it by the color
gl_FragColor = gl_Color * newCol;
}