Ported the specular lightning from combined shader to ALS interior detailed shader, to make the spot independent of view direction.
This commit is contained in:
parent
a206b3cb51
commit
3283e9721f
2 changed files with 16 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
||||||
varying vec4 diffuse_term;
|
varying vec4 diffuse_term;
|
||||||
varying vec3 normal;
|
varying vec3 normal;
|
||||||
varying vec3 relPos;
|
varying vec3 relPos;
|
||||||
|
varying vec3 rawpos;
|
||||||
|
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
@ -111,7 +112,7 @@ void main()
|
||||||
vec3 halfVector = gl_LightSource[0].halfVector.xyz;
|
vec3 halfVector = gl_LightSource[0].halfVector.xyz;
|
||||||
vec4 texel;
|
vec4 texel;
|
||||||
vec4 fragColor;
|
vec4 fragColor;
|
||||||
vec4 specular = vec4(0.0);
|
vec3 specular = vec3(0.0);
|
||||||
float intensity;
|
float intensity;
|
||||||
|
|
||||||
float effective_scattering = min(scattering, cloud_self_shading);
|
float effective_scattering = min(scattering, cloud_self_shading);
|
||||||
|
@ -153,11 +154,16 @@ void main()
|
||||||
|
|
||||||
diffuse.rgb += 2.0 * diffuse.rgb * (1.0 - opacity.a);
|
diffuse.rgb += 2.0 * diffuse.rgb * (1.0 - opacity.a);
|
||||||
color += diffuse * NdotL * opacity;
|
color += diffuse * NdotL * opacity;
|
||||||
NdotHV = max(dot(n, halfVector), 0.0);
|
|
||||||
if (gl_FrontMaterial.shininess > 0.0)
|
//NdotHV = max(dot(n, halfVector), 0.0);
|
||||||
specular.rgb = (gl_FrontMaterial.specular.rgb
|
if (gl_FrontMaterial.shininess > 0.0) {
|
||||||
* light_specular.rgb
|
vec3 ecViewDir = (gl_ModelViewMatrix * (ep - vec4(rawpos, 1.0))).xyz;
|
||||||
* pow(NdotHV, gl_FrontMaterial.shininess));
|
vec3 HV = normalize(normalize(gl_LightSource[0].position.xyz) + normalize(ecViewDir));
|
||||||
|
NdotHV = max(0.0, dot(n,HV));
|
||||||
|
specular = (gl_FrontMaterial.specular.rgb
|
||||||
|
* (light_specular.rgb+2.0*light_specular.rgb*(1.0-opacity.a))
|
||||||
|
* pow(NdotHV, gl_FrontMaterial.shininess)*opacity.rgb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
color.a = diffuse.a;
|
color.a = diffuse.a;
|
||||||
// This shouldn't be necessary, but our lighting becomes very
|
// This shouldn't be necessary, but our lighting becomes very
|
||||||
|
@ -187,7 +193,8 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fragColor = color * texel + specular;
|
fragColor = color * texel;
|
||||||
|
fragColor.rgb += specular.rgb;
|
||||||
|
|
||||||
// implicit lightmap - the user gets to select a color which is then made emissive
|
// implicit lightmap - the user gets to select a color which is then made emissive
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
varying vec4 diffuse_term;
|
varying vec4 diffuse_term;
|
||||||
varying vec3 normal;
|
varying vec3 normal;
|
||||||
varying vec3 relPos;
|
varying vec3 relPos;
|
||||||
|
varying vec3 rawpos;
|
||||||
|
|
||||||
varying float yprime_alt;
|
varying float yprime_alt;
|
||||||
varying float mie_angle;
|
varying float mie_angle;
|
||||||
|
@ -66,7 +67,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
rawpos = gl_Vertex.xyz;
|
||||||
vec4 light_diffuse;
|
vec4 light_diffuse;
|
||||||
vec4 light_ambient;
|
vec4 light_ambient;
|
||||||
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
|
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
|
||||||
|
|
Loading…
Add table
Reference in a new issue