I've written this shader to create a radial gradient (translated code from hlsl found on internet)
uniform sampler2D tex;
const vec2 center = vec2(0.5, 0.5);
const vec3 start = vec3(1.0, 0.0, 0.0);
const vec3 end = vec3(1.0, 1.0, 1.0);
const float radius = 1.0;
void main()
{
float dist = clamp(distance(center, gl_TexCoord[0]) / radius, 0.0, 1.0);
gl_FragColor = vec4(mix(start, end, dist), 1.0);
}
1) The result shows me blue and black but i would like to have a red - white transition. If I change smoothstep() to mix() then it works but produces banding effect.
2) I would like to have a circle instead of an ellipse which is the case if screen width != screen height
any suggestions?