1
0
Fork 0

Merge branch 'master' of git://mapserver.flightgear.org/fgdata

This commit is contained in:
Gijs de Rooy 2011-11-03 21:30:17 +01:00
commit ffadd311a5
6 changed files with 80 additions and 65 deletions

View file

@ -34,6 +34,21 @@
</axis>
</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>
<type>rotate</type>
<object-name>Roll</object-name>

View file

@ -251,10 +251,6 @@
<use>texture[6]/internal-format</use>
</internal-format>
</texture-unit>
<texture-unit>
<unit>9</unit>
<type>noise</type>
</texture-unit>
<program>
<vertex-shader>Shaders/water.vert</vertex-shader>
<fragment-shader>Shaders/water.frag</fragment-shader>
@ -366,11 +362,6 @@
<use>wind-from</use>
</value>
</uniform>
<uniform>
<name>Noise</name>
<type>sampler-3d</type>
<value type="int">9</value>
</uniform>
</pass>
</technique>
<technique n="9">

View file

@ -1,8 +1,9 @@
// -*-C++-*-
// Texture switching based on face slope and snow level
// default.frag (c) 2010 ??
// (c)2011 - Emilian Huminiuc, with ideas from crop.frag, forest.frag
// Texture switching based on face slope and snow level,with ideas from crop.frag, forest.frag
// © 2011 - Frederic Bouvier, Emilian Huminiuc, Tim Moore, Yves Sablonier
// Ambient term comes in gl_Color.rgb.
#version 120
varying vec4 diffuse_term, RawPos;
varying vec3 Vnormal, normal;
varying float fogCoord;
@ -28,7 +29,7 @@ void main()
Noise = texture3D(NoiseTex, RawPos.xyz*0.0011);
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);
L1 = 0.90 - 0.02 * MixFactor; //first transition slope
L2 = 0.78 + 0.04 * MixFactor; //Second transition slope
@ -44,8 +45,8 @@ void main()
NdotHV = max(dot(n, halfVector), 0.0);
if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = (gl_FrontMaterial.specular.rgb
* gl_LightSource[0].specular.rgb
* pow(NdotHV, gl_FrontMaterial.shininess));
* gl_LightSource[0].specular.rgb
* pow(NdotHV, gl_FrontMaterial.shininess));
}
color.a = diffuse_term.a;
@ -58,52 +59,57 @@ void main()
//Select texture based on slope
slope = normalize(normal).z;
//pull the texture fetch outside flow control to fix aliasing artefacts :(
vec4 baseTexel = texture2D(BaseTex, gl_TexCoord[0].st);
vec4 secondTexel = texture2D(SecondTex, gl_TexCoord[0].st);
vec4 thirdTexel = texture2D(ThirdTex, gl_TexCoord[0].st);
vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st * 2.0);
//Normal transition. For more abrupt faces apply another texture (or 2).
if (InverseSlope == 0.0) {
//Do we do an intermediate transition
if (Transitions >= 1.5) {
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 = texture2D(BaseTex, gl_TexCoord[0].st);
}
if (slope >= L2 && slope < L1){
texel = mix(texture2D(SecondTex, gl_TexCoord[0].st), texture2D(BaseTex, gl_TexCoord[0].st), smoothstep(L2, L1 - 0.06 * MixFactor, slope));
}
if (slope < L2){
texel = mix(texture2D(ThirdTex, gl_TexCoord[0].st), texture2D(SecondTex, gl_TexCoord[0].st), smoothstep(L2 - 0.13 * MixFactor, L2, slope));
}
// Just one transition
} else if (Transitions < 1.5) {
if (slope >= L1) {
texel = texture2D(BaseTex, gl_TexCoord[0].st);
}
if (slope < L1) {
texel = mix(texture2D(ThirdTex, gl_TexCoord[0].st), texture2D(BaseTex, gl_TexCoord[0].st), smoothstep(L2 - 0.13 * MixFactor, L1, slope));
}
}
//Do we do an intermediate transition
if (Transitions >= 1.5) {
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 = baseTexel;
}
if (slope >= L2 && slope < L1){
texel = mix(secondTexel, baseTexel, smoothstep(L2, L1 - 0.06 * MixFactor, slope));
}
if (slope < L2){
texel = mix(thirdTexel, secondTexel, smoothstep(L2 - 0.13 * MixFactor, L2, slope));
}
// Just one transition
} else if (Transitions < 1.5) {
if (slope >= L1) {
texel = baseTexel;
}
if (slope < L1) {
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) {
//Interemdiate transition ?
if (Transitions >= 1.5) {
if (slope >= L1 + 0.1) {
texel = texture2D(ThirdTex, gl_TexCoord[0].st);
}
if (slope >= L2 && slope < L1 + 0.1){
texel = mix(texture2D(SecondTex, gl_TexCoord[0].st), texture2D(ThirdTex, gl_TexCoord[0].st), smoothstep(L2 + 0.06 * MixFactor, L1 + 0.1, slope));
}
if (slope <= L2){
texel = mix(texture2D(BaseTex, gl_TexCoord[0].st), texture2D(SecondTex, gl_TexCoord[0].st), smoothstep(L2 - 0.06 * MixFactor, L2, slope));
}
//just one
} else if (Transitions < 1.5) {
if (slope > L1 + 0.1) {
texel = texture2D(ThirdTex, gl_TexCoord[0].st);
}
if (slope <= L1 + 0.1){
texel = mix(texture2D(BaseTex, gl_TexCoord[0].st), texture2D(ThirdTex, gl_TexCoord[0].st), smoothstep(L2 - 0.06 * MixFactor, L1 + 0.1, slope));
}
}
//Interemdiate transition ?
if (Transitions >= 1.5) {
if (slope >= L1 + 0.1) {
texel = thirdTexel;
}
if (slope >= L2 && slope < L1 + 0.1){
texel = mix(secondTexel, thirdTexel, smoothstep(L2 + 0.06 * MixFactor, L1 + 0.1, slope));
}
if (slope <= L2){
texel = mix(baseTexel, secondTexel, smoothstep(L2 - 0.06 * MixFactor, L2, slope));
}
//just one
} else if (Transitions < 1.5) {
if (slope > L1 + 0.1) {
texel = thirdTexel;
}
if (slope <= L1 + 0.1){
texel = mix(baseTexel, thirdTexel, smoothstep(L2 - 0.06 * MixFactor, L1 + 0.1, slope));
}
}
}
//darken textures with wetness
@ -114,18 +120,21 @@ void main()
//Snow texture for areas higher than SnowLevel
if (RawPos.z >= SnowLevel - (1000.0 * slope + 300 * MixFactor) && slope > L2 - 0.12) {
texel = mix(texel, mix(texel, texture2D(SnowTex, gl_TexCoord[0].st * 2), 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;
if(cover >= 2.5){
fragColor.rgb = fragColor.rgb * 1.2;
fragColor.rgb = fragColor.rgb * 1.2;
} else {
fragColor.rg = fragColor.rg * (0.6 + 0.2 * cover);
fragColor.b = fragColor.b * (0.5 + 0.25 * cover);
fragColor.rg = fragColor.rg * (0.6 + 0.2 * cover);
fragColor.b = fragColor.b * (0.5 + 0.25 * cover);
}
fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor);
}
}

View file

@ -8,6 +8,7 @@
// Diffuse colors come from the gl_Color, ambient from the material. This is
// equivalent to osg::Material::DIFFUSE.
#version 120
#define MODE_OFF 0
#define MODE_DIFFUSE 1
#define MODE_AMBIENT_AND_DIFFUSE 2

View file

@ -3,6 +3,7 @@
// available at http://forum.bonzaisoftware.com/viewthread.php?tid=10
// © Michael Horsch - 2005
#version 120
uniform sampler2D water_normalmap;
uniform sampler2D water_reflection;
uniform sampler2D water_dudvmap;
@ -37,7 +38,7 @@ void main(void)
const float water_shininess = 240.0;
// approximate cloud cover
float cover = 0;
float cover = 0.0;
cover = min(min(min(min(CloudCover0, CloudCover1),CloudCover2),CloudCover3),CloudCover4);
vec4 viewt = normalize(waterTex4);

View file

@ -14,8 +14,6 @@ uniform sampler2D water_reflection_grey;
uniform sampler2D sea_foam;
uniform sampler2D perlin_normalmap;
uniform sampler3D Noise;
uniform float saturation, Overcast, WindE, WindN;
uniform float CloudCover0, CloudCover1, CloudCover2, CloudCover3, CloudCover4;
uniform float osg_SimulationTime;