1
0
Fork 0

Merge branch 'master' of git://gitorious.org/fg/fgdata

This commit is contained in:
syd 2011-12-13 08:50:54 -07:00
commit 6348c04359
3 changed files with 14 additions and 13 deletions

View file

@ -1,7 +1,7 @@
// -*-C++-*- // -*-C++-*-
// Texture switching based on face slope and snow level // Texture switching based on face slope and snow level
// based on earlier work by Frederic Bouvier, Tim Moore, and Yves Sablonier. // based on earlier work by Frederic Bouvier, Tim Moore, and Yves Sablonier.
// Š Emilian Huminiuc 2011 // <EFBFBD> Emilian Huminiuc 2011
// Ambient term comes in gl_Color.rgb. // Ambient term comes in gl_Color.rgb.
varying vec4 diffuse_term, RawPos; varying vec4 diffuse_term, RawPos;
@ -35,7 +35,7 @@ void main()
Noise = texture3D(NoiseTex, RawPos.xyz*0.0011); Noise = texture3D(NoiseTex, RawPos.xyz*0.0011);
MixFactor = Noise.r * Noise.g * Noise.b; //Mixing Factor to create a more organic looking boundary MixFactor = Noise.r * Noise.g * Noise.b; //Mixing Factor to create a more organic looking boundary
MixFactor *= 300; MixFactor *= 300.0;
MixFactor = clamp(MixFactor, 0.0, 1.0); MixFactor = clamp(MixFactor, 0.0, 1.0);
L1 = 0.90 - 0.02 * MixFactor; //first transition slope L1 = 0.90 - 0.02 * MixFactor; //first transition slope
L2 = 0.78 + 0.04 * MixFactor; //Second transition slope L2 = 0.78 + 0.04 * MixFactor; //Second transition slope
@ -67,9 +67,9 @@ void main()
//pull the texture fetch outside flow control to fix aliasing artefacts :( //pull the texture fetch outside flow control to fix aliasing artefacts :(
vec4 baseTexel = texture2D(BaseTex, gl_TexCoord[0].st); vec4 baseTexel = texture2D(BaseTex, gl_TexCoord[0].st);
vec4 secondTexel = texture2D(SecondTex, gl_TexCoord[0].st); vec4 secondTexel = texture2D(SecondTex, gl_TexCoord[0].st);
vec4 thirdTexel = texture2D(ThirdTex, gl_TexCoord[0].st); vec4 thirdTexel = texture2D(ThirdTex, gl_TexCoord[0].st);
vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st * 2); vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st);
//Normal transition. For more abrupt faces apply another texture (or 2). //Normal transition. For more abrupt faces apply another texture (or 2).
if (InverseSlope == 0.0) { if (InverseSlope == 0.0) {
//Do we do an intermediate transition //Do we do an intermediate transition
@ -123,10 +123,10 @@ void main()
texel.rgb = texel.rgb * wetness; texel.rgb = texel.rgb * wetness;
float altitude = RawPos.z;
//Snow texture for areas higher than SnowLevel //Snow texture for areas higher than SnowLevel
if (RawPos.z >= SnowLevel - (1000.0 * slope + 300 * MixFactor) && slope > L2 - 0.12) { if (altitude >= SnowLevel - (1000.0 * slope + 300.0 * MixFactor) && slope > L2 - 0.12) {
texel = mix(texel, mix(texel, snowTexel, smoothstep(L2 - 0.09 * MixFactor, L2, slope)), smoothstep(SnowLevel - (1000.0 * slope + 300 * MixFactor), SnowLevel - (1000 * slope - 150 * MixFactor), RawPos.z)); texel = mix(texel, mix(texel, snowTexel, smoothstep(L2 - 0.09 * MixFactor, L2, slope)), smoothstep(SnowLevel - (1000.0 * slope + 300.0 * MixFactor), SnowLevel - (1000.0 * slope - 150.0 * MixFactor), altitude));
} }
fragColor = color * texel + specular; fragColor = color * texel + specular;
@ -139,7 +139,8 @@ void main()
} }
//fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); //fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
fragColor.rgb *= 1.2 - 0.4 * MixFactor;
fragColor.rgb = fog_Func(fragColor.rgb, fogType); fragColor.rgb = fog_Func(fragColor.rgb, fogType);
//gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); //gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor);
gl_FragColor = fragColor; gl_FragColor = fragColor;
} }

View file

@ -69,7 +69,7 @@ void main (void)
float pf; float pf;
///BEGIN bump ///BEGIN bump
if (nmap_enabled > 0 && shader_qual > 1){ if (nmap_enabled > 0 && shader_qual > 2){
N = nmap.rgb * 2.0 - 1.0; N = nmap.rgb * 2.0 - 1.0;
N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal); N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal);
if (nmap_dds > 0) if (nmap_dds > 0)
@ -107,7 +107,7 @@ void main (void)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
//BEGIN reflect //BEGIN reflect
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
if (refl_enabled > 0 && shader_qual > 0){ if (refl_enabled > 0 && shader_qual > 1){
float reflFactor; float reflFactor;
float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset
@ -115,7 +115,7 @@ void main (void)
// map the shininess of the object with user input // map the shininess of the object with user input
//float pam = (map.a * -2) + 1; //reverse map //float pam = (map.a * -2) + 1; //reverse map
reflFactor = reflmap.a + transparency_offset; reflFactor = reflmap.a + transparency_offset;
} else if (nmap_enabled > 0 && shader_qual > 1) { } else if (nmap_enabled > 0 && shader_qual > 2) {
// set the reflectivity proportional to shininess with user input // set the reflectivity proportional to shininess with user input
reflFactor = (gl_FrontMaterial.shininess / 128.0) * nmap.a + transparency_offset; reflFactor = (gl_FrontMaterial.shininess / 128.0) * nmap.a + transparency_offset;
} else { } else {

View file

@ -50,7 +50,7 @@ void main(void)
fog_Func(fogType); fog_Func(fogType);
VNormal = normalize(gl_NormalMatrix * gl_Normal); VNormal = normalize(gl_NormalMatrix * gl_Normal);
if (nmap_enabled > 0 && shader_qual > 1){ if (nmap_enabled > 0 && shader_qual > 2){
VTangent = normalize(gl_NormalMatrix * tangent); VTangent = normalize(gl_NormalMatrix * tangent);
VBinormal = normalize(gl_NormalMatrix * binormal); VBinormal = normalize(gl_NormalMatrix * binormal);
} else { } else {