Hey guys i have a fragment shader and vertex shader and so far i can get a nice looking background image, but i cant get 2 colours to fade in to each other, the problem im having is that the Y position is 1.0 and then at the bottom -1.0, now i can just work out the different and take it away, because if i did then once it hit the middle of the screen it will be the second colour, does anyone know a algorithm to work it out?
this is my fragment shader code
#version 120
varying vec3 pos_fragment;
uniform vec3 color1;
uniform vec3 color2;
vec3 actuallyColor;
vec3 difference;
void main()
{
//col = (pos.y * col1.y/col2.y);
gl_FragColor = vec4((color1.rgb) * (pos_fragment.y * pos_fragment.y), 1.0); // white
}
and here is my vertex shader
#version 120
attribute vec3 position;
varying vec3 pos_fragment;
void main()
{
gl_Position = vec4(position.xyz,1);
pos_fragment = vec3(position.xyz);
}
cheers