Improve runway reflection shader by Emilian H.
This commit is contained in:
parent
aae72d7266
commit
3132b761d0
1 changed files with 16 additions and 13 deletions
|
@ -52,6 +52,7 @@ void main (void)
|
||||||
|
|
||||||
float nFactor = 1.0 - N.z;
|
float nFactor = 1.0 - N.z;
|
||||||
float lightness = dot(texel.rgb, vec3( 0.3, 0.59, 0.11 ));
|
float lightness = dot(texel.rgb, vec3( 0.3, 0.59, 0.11 ));
|
||||||
|
|
||||||
// calculate the specular light
|
// calculate the specular light
|
||||||
float refl_correction = spec_adjust * 2.5 - 1.0;
|
float refl_correction = spec_adjust * 2.5 - 1.0;
|
||||||
float shininess = max (0.35, refl_correction) * nmap.a * nFactor;
|
float shininess = max (0.35, refl_correction) * nmap.a * nFactor;
|
||||||
|
@ -99,11 +100,13 @@ void main (void)
|
||||||
vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v);
|
vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v);
|
||||||
vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness);
|
vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness);
|
||||||
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0) * nFactor;
|
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0) * nFactor;
|
||||||
|
|
||||||
vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor);
|
vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor);
|
||||||
|
|
||||||
// the final reflection
|
// the final reflection
|
||||||
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction * nFactor, color.a);
|
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction * nFactor, color.a);
|
||||||
|
float doWater = step(0.1, reflFactor);
|
||||||
|
int matIndex = int(doWater) * 253 + 1;
|
||||||
|
shininess += doWater * reflFactor * 240.0;
|
||||||
|
|
||||||
encode_gbuffer(N, fragColor.rgb, 1, specular, shininess, emission, gl_FragCoord.z);
|
encode_gbuffer(N, fragColor.rgb, matIndex, specular, shininess, emission, gl_FragCoord.z);
|
||||||
}
|
}
|
Loading…
Reference in a new issue