1
0
Fork 0

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

This commit is contained in:
Durk Talsma 2011-10-30 21:22:39 +01:00
commit c49b97114d
2 changed files with 85 additions and 70 deletions

View file

@ -34,6 +34,21 @@
</axis> </axis>
</animation> </animation>
<animation>
<name>Horizon Offset</name>
<type>translate</type>
<object-name>Pitch</object-name>
<property>instrumentation/attitude-indicator/horizon-offset-deg</property>
<factor>-0.0007</factor>
<min-m>-0.01575</min-m>
<max-m>0.01575</max-m>
<axis>
<x>0.0</x>
<y>0.0</y>
<z>1.0</z>
</axis>
</animation>
<animation> <animation>
<type>rotate</type> <type>rotate</type>
<object-name>Roll</object-name> <object-name>Roll</object-name>

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,with ideas from crop.frag, forest.frag
// default.frag (c) 2010 ?? // © 2011 - Frederic Bouvier, Emilian Huminiuc, Tim Moore, Yves Sablonier
// (c)2011 - Emilian Huminiuc, with ideas from crop.frag, forest.frag
// Ambient term comes in gl_Color.rgb. // Ambient term comes in gl_Color.rgb.
#version 120 #version 120
varying vec4 diffuse_term, RawPos; varying vec4 diffuse_term, RawPos;
@ -45,8 +45,8 @@ void main()
NdotHV = max(dot(n, halfVector), 0.0); NdotHV = max(dot(n, halfVector), 0.0);
if (gl_FrontMaterial.shininess > 0.0) if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = (gl_FrontMaterial.specular.rgb specular.rgb = (gl_FrontMaterial.specular.rgb
* gl_LightSource[0].specular.rgb * gl_LightSource[0].specular.rgb
* pow(NdotHV, gl_FrontMaterial.shininess)); * pow(NdotHV, gl_FrontMaterial.shininess));
} }
color.a = diffuse_term.a; color.a = diffuse_term.a;
@ -59,78 +59,78 @@ void main()
//Select texture based on slope //Select texture based on slope
slope = normalize(normal).z; slope = normalize(normal).z;
//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.0); vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st * 2.0);
//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
if (Transitions >= 1.5) { if (Transitions >= 1.5) {
if (slope >= L1) { if (slope >= L1) {
//texel = mix(texture2D(SecondTex, gl_TexCoord[0].st), texture2D(BaseTex, gl_TexCoord[0].st), smoothstep(L1, L1 + 0.03 * MixFactor, slope)); //texel = mix(texture2D(SecondTex, gl_TexCoord[0].st), texture2D(BaseTex, gl_TexCoord[0].st), smoothstep(L1, L1 + 0.03 * MixFactor, slope));
texel = baseTexel; texel = baseTexel;
} }
if (slope >= L2 && slope < L1){ if (slope >= L2 && slope < L1){
texel = mix(secondTexel, baseTexel, smoothstep(L2, L1 - 0.06 * MixFactor, slope)); texel = mix(secondTexel, baseTexel, smoothstep(L2, L1 - 0.06 * MixFactor, slope));
} }
if (slope < L2){ if (slope < L2){
texel = mix(thirdTexel, secondTexel, smoothstep(L2 - 0.13 * MixFactor, L2, slope)); texel = mix(thirdTexel, secondTexel, smoothstep(L2 - 0.13 * MixFactor, L2, slope));
} }
// Just one transition // Just one transition
} else if (Transitions < 1.5) { } else if (Transitions < 1.5) {
if (slope >= L1) { if (slope >= L1) {
texel = baseTexel; texel = baseTexel;
} }
if (slope < L1) { if (slope < L1) {
texel = mix(thirdTexel, baseTexel, smoothstep(L2 - 0.13 * MixFactor, L1, slope)); texel = mix(thirdTexel, baseTexel, smoothstep(L2 - 0.13 * MixFactor, L1, slope));
} }
} }
//Invert the transition: keep original texture on abrupt slopes and switch to another on flatter terrain //Invert the transition: keep original texture on abrupt slopes and switch to another on flatter terrain
} else if (InverseSlope > 0.0) { } else if (InverseSlope > 0.0) {
//Interemdiate transition ? //Interemdiate transition ?
if (Transitions >= 1.5) { if (Transitions >= 1.5) {
if (slope >= L1 + 0.1) { if (slope >= L1 + 0.1) {
texel = thirdTexel; texel = thirdTexel;
} }
if (slope >= L2 && slope < L1 + 0.1){ if (slope >= L2 && slope < L1 + 0.1){
texel = mix(secondTexel, thirdTexel, smoothstep(L2 + 0.06 * MixFactor, L1 + 0.1, slope)); texel = mix(secondTexel, thirdTexel, smoothstep(L2 + 0.06 * MixFactor, L1 + 0.1, slope));
} }
if (slope <= L2){ if (slope <= L2){
texel = mix(baseTexel, secondTexel, smoothstep(L2 - 0.06 * MixFactor, L2, slope)); texel = mix(baseTexel, secondTexel, smoothstep(L2 - 0.06 * MixFactor, L2, slope));
} }
//just one //just one
} else if (Transitions < 1.5) { } else if (Transitions < 1.5) {
if (slope > L1 + 0.1) { if (slope > L1 + 0.1) {
texel = thirdTexel; texel = thirdTexel;
} }
if (slope <= L1 + 0.1){ if (slope <= L1 + 0.1){
texel = mix(baseTexel, thirdTexel, smoothstep(L2 - 0.06 * MixFactor, L1 + 0.1, slope)); texel = mix(baseTexel, thirdTexel, smoothstep(L2 - 0.06 * MixFactor, L1 + 0.1, slope));
} }
} }
} }
//darken textures with wetness //darken textures with wetness
wetness = 1.0 - 0.3 * RainNorm; wetness = 1.0 - 0.3 * RainNorm;
texel.rgb = texel.rgb * wetness; texel.rgb = texel.rgb * wetness;
//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 (RawPos.z >= SnowLevel - (1000.0 * slope + 300 * 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 * MixFactor), SnowLevel - (1000 * slope - 150 * MixFactor), RawPos.z));
} }
fragColor = color * texel + specular; fragColor = color * texel + specular;
if(cover >= 2.5){ if(cover >= 2.5){
fragColor.rgb = fragColor.rgb * 1.2; fragColor.rgb = fragColor.rgb * 1.2;
} else { } else {
fragColor.rg = fragColor.rg * (0.6 + 0.2 * cover); fragColor.rg = fragColor.rg * (0.6 + 0.2 * cover);
fragColor.b = fragColor.b * (0.5 + 0.25 * cover); fragColor.b = fragColor.b * (0.5 + 0.25 * cover);
} }
fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor);