2012-03-08 22:20:39 +00:00
|
|
|
uniform sampler2D baseTexture;
|
|
|
|
varying float fogFactor;
|
|
|
|
varying vec3 hazeColor;
|
2015-12-21 11:07:32 +00:00
|
|
|
varying vec3 relVector;
|
2012-03-08 22:20:39 +00:00
|
|
|
|
2016-04-08 12:57:59 +00:00
|
|
|
vec3 filter_combined (in vec3 color) ;
|
|
|
|
|
2015-08-12 08:31:05 +00:00
|
|
|
uniform bool is_lightning;
|
|
|
|
|
2015-12-21 11:07:32 +00:00
|
|
|
vec3 rainbow (in float index)
|
|
|
|
{
|
|
|
|
|
|
|
|
float red = max(1.0 - 2.0 * index,0.0);
|
|
|
|
float green;
|
|
|
|
|
|
|
|
if (index < 0.5)
|
|
|
|
{green = 2.0 * index;}
|
|
|
|
else
|
|
|
|
{green = 1.0 - 2.0 *(index - 0.5);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float blue = max(2.0 * (index - 0.5), 0.0);
|
|
|
|
|
|
|
|
red *= 1.3;
|
|
|
|
green *=0.6;
|
|
|
|
|
|
|
|
return vec3 (red, green, blue) * hazeColor;
|
|
|
|
}
|
|
|
|
|
2012-03-08 22:20:39 +00:00
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
vec4 base = texture2D( baseTexture, gl_TexCoord[0].st);
|
|
|
|
vec4 finalColor = base * gl_Color;
|
2015-12-21 11:07:32 +00:00
|
|
|
|
2016-04-08 12:57:59 +00:00
|
|
|
vec4 fragColor;
|
2015-12-21 11:07:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (is_lightning==false)
|
|
|
|
{
|
|
|
|
vec3 nView = normalize(relVector);
|
|
|
|
vec3 lightFull = normalize((gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz);
|
|
|
|
|
|
|
|
float calpha = dot(-lightFull, nView);
|
|
|
|
|
|
|
|
float rainbow_shape = smoothstep(0.743 -0.03, 0.743, calpha) * (1.0 - smoothstep(0.743, 0.743+0.03, calpha));
|
|
|
|
|
|
|
|
float color_index = clamp((calpha - 0.713)/ 0.06,0.0,1.0);
|
|
|
|
|
|
|
|
vec3 rainbow_color = rainbow(color_index);
|
|
|
|
finalColor.rgb = mix(finalColor.rgb, rainbow_color, 0.5* rainbow_shape);
|
|
|
|
|
|
|
|
|
2016-04-08 12:57:59 +00:00
|
|
|
fragColor.rgb = mix(hazeColor, finalColor.rgb, fogFactor );
|
2015-12-21 11:07:32 +00:00
|
|
|
}
|
2015-08-12 08:31:05 +00:00
|
|
|
else
|
2016-06-29 09:53:05 +00:00
|
|
|
{fragColor.rgb = finalColor.rgb;}
|
2016-04-08 12:57:59 +00:00
|
|
|
fragColor.a = mix(0.0, finalColor.a, fogFactor);
|
|
|
|
|
|
|
|
fragColor.rgb = filter_combined(fragColor.rgb);
|
|
|
|
|
|
|
|
gl_FragColor = fragColor;
|
|
|
|
|
2012-03-08 22:20:39 +00:00
|
|
|
}
|