small update: multiply the diffuse and ambient settings by the bump(map) value.
This commit is contained in:
parent
8556d3c1ea
commit
164effede9
1 changed files with 57 additions and 76 deletions
|
@ -13,7 +13,6 @@ uniform float osg_SimulationTime;
|
||||||
|
|
||||||
void main (void)
|
void main (void)
|
||||||
{
|
{
|
||||||
// const float snowlevel=2000.0;
|
|
||||||
vec4 noisevecS = texture3D(NoiseTex, (rawpos.xyz)*0.0126);
|
vec4 noisevecS = texture3D(NoiseTex, (rawpos.xyz)*0.0126);
|
||||||
vec4 nvLS = texture3D(NoiseTex, (rawpos.xyz)*-0.0003323417);
|
vec4 nvLS = texture3D(NoiseTex, (rawpos.xyz)*-0.0003323417);
|
||||||
|
|
||||||
|
@ -21,11 +20,17 @@ void main (void)
|
||||||
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212));
|
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212));
|
||||||
|
|
||||||
float fogFactor;
|
float fogFactor;
|
||||||
|
if (gl_Fog.density == 1.0)
|
||||||
|
{
|
||||||
|
fogFactor=1.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
float fogCoord = ecPosition.z;
|
float fogCoord = ecPosition.z;
|
||||||
const float LOG2 = 1.442695;
|
const float LOG2 = 1.442695;
|
||||||
fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
||||||
// float biasFactor = exp2(-0.00000002 * fogCoord * fogCoord * LOG2);
|
|
||||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
float a=1.0;
|
float a=1.0;
|
||||||
float n=0.00;
|
float n=0.00;
|
||||||
|
@ -55,49 +60,25 @@ void main (void)
|
||||||
a*=1.2;
|
a*=1.2;
|
||||||
na += noisevec[3]*a;
|
na += noisevec[3]*a;
|
||||||
|
|
||||||
// GOOD
|
|
||||||
|
|
||||||
vec4 c1;
|
vec4 c1;
|
||||||
c1 = vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0);
|
c1 = asin(vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0));
|
||||||
/*
|
|
||||||
|
|
||||||
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+nvL[2]*0.8)));
|
|
||||||
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, nvL[0]*1.4+nvL[1]*6.4+nvL[2]*16+noisevec[3]*3.3)*2.0-1.4);
|
|
||||||
vec3 bumped = max(dot(normalize(Normal), normalize(bump)), 0.0);
|
|
||||||
bumped=max(normalize(refract(lightVec, normalize(bump), 0.3)), 0.0);
|
|
||||||
*/
|
|
||||||
vec3 Eye = normalize(-ecPosition.xyz);
|
vec3 Eye = normalize(-ecPosition.xyz);
|
||||||
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24))));
|
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24))));
|
||||||
//Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal)));
|
|
||||||
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9);
|
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9);
|
||||||
vec3 bumped;
|
vec3 bumped = max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0);
|
||||||
// = max(dot(normalize(Normal.xyz), normalize(bump)), vec3(0.0, 0.0, 0.0));
|
|
||||||
bumped=max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0);
|
|
||||||
|
|
||||||
vec4 ambientColor = gl_LightSource[0].ambient;
|
vec4 ambientColor = gl_LightSource[0].ambient;
|
||||||
vec4 light = ambientColor;
|
vec4 light = ambientColor;
|
||||||
c1 *= light;
|
c1 *= light;
|
||||||
|
|
||||||
|
float bumpFact = (bumped.r+bumped.g+bumped.b);
|
||||||
// c1 += gl_LightSource[0].diffuse*0.5 * pow(max(dot(Reflected, Eye), 0.0), 2.0/*gl_FrontMaterial.shininess*/);
|
c1 += (vec4(0.3, 0.34, 0.4, 1.0)-0.1)*gl_LightSource[0].diffuse * bumpFact;
|
||||||
// c1 *= pow(max(Reflected.x+Reflected.y+Reflected.z, 0.0), 1.0/*gl_FrontMaterial.shininess*/);
|
|
||||||
// c1 *= 0.3;
|
|
||||||
// c1 = vec4(0.0);
|
|
||||||
// c1 = vec4(0.0);
|
|
||||||
//c1 += (vec3(0.0, 0.01, 0.01)*n) * pow(max(Reflected.x+Reflected.y+Reflected.z, 0.0), 9.0/*gl_FrontMaterial.shininess*/);
|
|
||||||
// c1 += gl_LightSource[0].specular*2.0 * pow(max(dot(bumped, Eye), 0.3), 89.0)/*gl_FrontMaterial.shininess*/;
|
|
||||||
|
|
||||||
|
|
||||||
// HERE IS GOOD
|
|
||||||
|
|
||||||
c1 += (vec4(0.3, 0.34, 0.4, 1.0)-0.1)*gl_LightSource[0].diffuse * (bumped.r+bumped.g+bumped.b);
|
|
||||||
float ReflectedEye = max(dot(Reflected, Eye), 0.0);
|
float ReflectedEye = max(dot(Reflected, Eye), 0.0);
|
||||||
c1 += gl_LightSource[0].diffuse*0.4 * pow(ReflectedEye, 20.0);
|
c1 += gl_LightSource[0].diffuse*0.4 * pow(ReflectedEye, 20.0) * 3*bumpFact;
|
||||||
c1 += gl_LightSource[0].specular * pow(ReflectedEye, 400.0/*gl_FrontMaterial.shininess*/);
|
c1 += gl_LightSource[0].specular * pow(ReflectedEye, 400.0) * 4*bumpFact;
|
||||||
|
|
||||||
vec4 finalColor = c1;
|
vec4 finalColor = c1;
|
||||||
|
|
||||||
if(gl_Fog.density == 1.0)
|
|
||||||
fogFactor=1.0;
|
|
||||||
|
|
||||||
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue