Small fixes and tweaks. Fix ugly black faces paralel to view direction on random buildings.
Signed-off-by: Emilian Huminiuc <emilianh@gmail.com>
This commit is contained in:
parent
fbe8231ed5
commit
e7dcbcf494
5 changed files with 18 additions and 15 deletions
|
@ -66,7 +66,7 @@
|
||||||
<diffuse type="vec4d">1.0 1.0 1.0 1.0</diffuse>
|
<diffuse type="vec4d">1.0 1.0 1.0 1.0</diffuse>
|
||||||
<specular type="vec4d">0.0 0.0 0.0 1.0</specular>
|
<specular type="vec4d">0.0 0.0 0.0 1.0</specular>
|
||||||
<emissive type="vec4d">0.02 0.02 0.02 1.0</emissive>
|
<emissive type="vec4d">0.02 0.02 0.02 1.0</emissive>
|
||||||
<shininess>0.0</shininess>
|
<shininess>0.1</shininess>
|
||||||
<color-mode>ambient-and-diffuse</color-mode>
|
<color-mode>ambient-and-diffuse</color-mode>
|
||||||
<color-mode-uniform>ambient-and-diffuse</color-mode-uniform>
|
<color-mode-uniform>ambient-and-diffuse</color-mode-uniform>
|
||||||
<!-- DIFFUSE -->
|
<!-- DIFFUSE -->
|
||||||
|
|
|
@ -50,12 +50,14 @@ void main (void)
|
||||||
if (normalmap_dds > 0)
|
if (normalmap_dds > 0)
|
||||||
N = -N;
|
N = -N;
|
||||||
|
|
||||||
|
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;
|
float shininess = max (0.35, refl_correction) * nmap.a * nFactor;
|
||||||
|
|
||||||
float specular = dot(vec3(1.0) * lightness , vec3( 0.3, 0.59, 0.11 ));
|
|
||||||
|
float specular = dot(vec3(1.0) * lightness , vec3( 0.3, 0.59, 0.11 )) * nFactor;
|
||||||
|
|
||||||
vec4 color = vec4(1.0);
|
vec4 color = vec4(1.0);
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ void main (void)
|
||||||
vec3 viewVec = normalize(vViewVec);
|
vec3 viewVec = normalize(vViewVec);
|
||||||
|
|
||||||
// Map a rainbowish color
|
// Map a rainbowish color
|
||||||
float v = dot(viewVec, normalize(VNormal));
|
float v = abs(dot(viewVec, normalize(VNormal)));
|
||||||
vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
|
vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
|
||||||
|
|
||||||
// Map a fresnel effect
|
// Map a fresnel effect
|
||||||
|
@ -83,7 +85,7 @@ void main (void)
|
||||||
|
|
||||||
MixFactor = 0.75 * smoothstep(0.0, 1.0, MixFactor);
|
MixFactor = 0.75 * smoothstep(0.0, 1.0, MixFactor);
|
||||||
|
|
||||||
reflFactor = max(map.a * (texel.r + texel.g), 1.0 - MixFactor) * (1.0- N.z) + transparency_offset ;
|
reflFactor = max(map.a * (texel.r + texel.g), 1.0 - MixFactor) * nFactor + transparency_offset ;
|
||||||
reflFactor =0.75 * smoothstep(0.05, 1.0, reflFactor);
|
reflFactor =0.75 * smoothstep(0.05, 1.0, reflFactor);
|
||||||
|
|
||||||
// set ambient adjustment to remove bluiness with user input
|
// set ambient adjustment to remove bluiness with user input
|
||||||
|
@ -96,12 +98,12 @@ 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);
|
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, color.a);
|
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction * nFactor, color.a);
|
||||||
|
|
||||||
encode_gbuffer(N, fragColor.rgb, 1, specular, shininess, emission, gl_FragCoord.z);
|
encode_gbuffer(N, fragColor.rgb, 1, specular, shininess, emission, gl_FragCoord.z);
|
||||||
}
|
}
|
|
@ -79,14 +79,15 @@ void main (void)
|
||||||
|
|
||||||
vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
|
vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
|
||||||
//color += Specular * vec4(vec3(0.5*shininess), 1.0) * nmap.a;
|
//color += Specular * vec4(vec3(0.5*shininess), 1.0) * nmap.a;
|
||||||
color += Specular * vec4(1.0) * nmap.a;
|
float nFactor = 1.0 - N.z;
|
||||||
|
color += Specular * vec4(1.0) * nmap.a * nFactor;
|
||||||
color.a = texel.a * alpha;
|
color.a = texel.a * alpha;
|
||||||
color = clamp(color, 0.0, 1.0);
|
color = clamp(color, 0.0, 1.0);
|
||||||
|
|
||||||
vec3 viewVec = normalize(vViewVec);
|
vec3 viewVec = normalize(vViewVec);
|
||||||
|
|
||||||
// Map a rainbowish color
|
// Map a rainbowish color
|
||||||
float v = dot(viewVec, normalize(VNormal));
|
float v = abs(dot(viewVec, normalize(VNormal)));
|
||||||
vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
|
vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
|
||||||
|
|
||||||
// Map a fresnel effect
|
// Map a fresnel effect
|
||||||
|
@ -115,18 +116,18 @@ void main (void)
|
||||||
|
|
||||||
// add fringing fresnel and rainbow effects and modulate by reflection
|
// add fringing fresnel and rainbow effects and modulate by reflection
|
||||||
vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v);
|
vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v);
|
||||||
reflcolor += Specular * nmap.a;
|
reflcolor += Specular * nmap.a * nFactor;
|
||||||
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);
|
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0);
|
||||||
raincolor += Specular * nmap.a;
|
raincolor += Specular * nmap.a * nFactor;
|
||||||
|
|
||||||
|
|
||||||
vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor); //* (1.0 - 0.5 * transparency_offset )
|
vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor); //* (1.0 - 0.5 * transparency_offset )
|
||||||
|
|
||||||
// the final reflection
|
// the final reflection
|
||||||
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction.rgb * (1.0 - refl_correction * (1.0 - 0.8 * lightness)), color.a);
|
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction.rgb * (1.0 - refl_correction * (1.0 - 0.8 * lightness)) * nFactor, color.a);
|
||||||
fragColor += Specular * nmap.a;
|
fragColor += Specular * nmap.a * nFactor;
|
||||||
|
|
||||||
fragColor.rgb = fog_Func(fragColor.rgb, fogType);
|
fragColor.rgb = fog_Func(fragColor.rgb, fogType);
|
||||||
gl_FragColor = fragColor;
|
gl_FragColor = fragColor;
|
||||||
|
|
|
@ -92,7 +92,7 @@ void main (void)
|
||||||
///END bump
|
///END bump
|
||||||
vec4 reflection = textureCube(Environment, reflVec * N);
|
vec4 reflection = textureCube(Environment, reflVec * N);
|
||||||
vec3 viewVec = normalize(vViewVec);
|
vec3 viewVec = normalize(vViewVec);
|
||||||
float v = dot(viewVec, normalize(VNormal));// Map a rainbowish color
|
float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color
|
||||||
vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));
|
vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));
|
||||||
vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
|
vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
|
||||||
vec4 color = gl_Color * gl_FrontMaterial.diffuse;
|
vec4 color = gl_Color * gl_FrontMaterial.diffuse;
|
||||||
|
|
|
@ -85,7 +85,7 @@ void main (void)
|
||||||
///END bump
|
///END bump
|
||||||
vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal));
|
vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal));
|
||||||
vec3 viewVec = normalize(vViewVec);
|
vec3 viewVec = normalize(vViewVec);
|
||||||
float v = dot(viewVec, normalize(VNormal));// Map a rainbowish color
|
float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color
|
||||||
vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));
|
vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));
|
||||||
vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
|
vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue