28 lines
711 B
GLSL
28 lines
711 B
GLSL
vec3 SunGlare(vec3 color, vec3 nViewPos, vec3 lightCol) {
|
|
float cosSp = dot(nViewPos, lightVec);
|
|
if (cosSp > 0.0) {
|
|
float cosS = cosSp;
|
|
cosS *= cosS;
|
|
cosS *= cosS;
|
|
cosS *= cosS;
|
|
float visfactor = 0.075;
|
|
|
|
float sunGlare = cosS;
|
|
sunGlare = visfactor / (1.0 - (1.0 - visfactor) * sunGlare) - visfactor;
|
|
sunGlare *= cosSp;
|
|
|
|
sunGlare *= 0.25 * SUN_GLARE_STRENGTH * (1.0 - rainStrengthS);
|
|
|
|
float shadowTime = abs(sunVisibility - 0.5) * 2.0;
|
|
shadowTime *= shadowTime;
|
|
sunGlare *= shadowTime * shadowTime;
|
|
|
|
vec3 finalSunGlare = lightCol * sunGlare;
|
|
|
|
if (isEyeInWater == 1) finalSunGlare *= underwaterColor.rgb * underwaterColor.rgb * 200.0;
|
|
|
|
color += finalSunGlare;
|
|
}
|
|
|
|
return color;
|
|
} |