36 lines
724 B
GLSL
36 lines
724 B
GLSL
#version 100
|
|
|
|
precision mediump float;
|
|
|
|
varying vec2 fragTexCoord;
|
|
varying vec4 fragColor;
|
|
|
|
|
|
uniform vec3 color;
|
|
uniform float sun_radius;
|
|
uniform float start_transperency;
|
|
|
|
vec2 offset = vec2(1.0, 1.0);
|
|
float sun_end = 1.0;
|
|
|
|
void main()
|
|
{
|
|
offset.x -= fragTexCoord.x * 2.0;
|
|
offset.y -= fragTexCoord.y * 2.0;
|
|
float radius = length(offset);
|
|
|
|
if(radius < sun_radius){
|
|
|
|
gl_FragColor = vec4(color, 1.0);
|
|
|
|
}else if(radius < sun_end){
|
|
|
|
float gradient = radius;
|
|
gradient -= sun_radius;
|
|
gradient = gradient / (sun_end - sun_radius) * start_transperency;
|
|
gl_FragColor = vec4(color, start_transperency - gradient);
|
|
|
|
}else{
|
|
gl_FragColor = vec4(color, 0.0);
|
|
}
|
|
} |