1
0
Fork 0

Tidy up formatting after reinstating Rainbow effect

Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
Vivian Meazza 2013-04-28 09:25:17 +01:00
parent fa19905cce
commit f025dd3e32

View file

@ -85,14 +85,14 @@ uniform vec3 dirt_b_color;
// uniform mat4 osg_ViewMatrix;
float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
{
{
if (x > 30.0) {return e;}
if (x < -15.0) {return 0.0;}
return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
}
}
float fog_func (in float targ, in float altitude)
{
{
float fade_mix;
targ = 1.25 * targ * smoothstep(0.04,0.06,targ); // need to sync with the distance to which objects are drawn unfogged
@ -109,11 +109,11 @@ float fog_func (in float targ, in float altitude)
return exp(- targ * targ - pow(targ,4.0));
}
}
}
void main (void)
{
{
vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
vec4 nmap = texture2D(NormalTex, gl_TexCoord[0].st * nmap_tile);
vec4 reflmap = texture2D(ReflMapTex, gl_TexCoord[0].st);
@ -125,14 +125,14 @@ void main (void)
vec3 mixedcolor;
vec3 N = vec3(0.0,0.0,1.0);
float pf = 0.0;
///some generic light scattering parameters
///some generic light scattering parameters
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
float alt = eye_alt;
float effective_scattering = min(scattering, cloud_self_shading);
/// BEGIN geometry for light
/// BEGIN geometry for light
vec3 up = (gl_ModelViewMatrix * vec4(0.0,0.0,1.0,0.0)).xyz;
//vec4 worldPos3D = (osg_ViewMatrixInverse * vec4 (0.0,0.0,0.0, 1.0));
@ -177,10 +177,10 @@ void main (void)
float ct = dot(normalize(up), normalize(vertVec));
/// END geometry for light
/// END geometry for light
/// BEGIN light
/// BEGIN light
vec4 light_diffuse;
vec4 light_ambient;
float intensity;
@ -207,17 +207,17 @@ void main (void)
}
/// END light
/// END light
/// BEGIN grain overlay
/// BEGIN grain overlay
if (grain_texture_enabled > 0)
{
grainTexel = texture2D(GrainTex, gl_TexCoord[0].st * grain_magnification);
texel.rgb = mix(texel.rgb, grainTexel.rgb, grainTexel.a );
}
/// END grain overlay
/// END grain overlay
///BEGIN bump
///BEGIN bump
if (nmap_enabled > 0 && shader_qual > 2){
N = nmap.rgb * 2.0 - 1.0;
N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal);
@ -226,7 +226,7 @@ void main (void)
} else {
N = normalize(VNormal);
}
///END bump
///END bump
vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal));
vec3 viewVec = normalize(vViewVec);
float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color
@ -256,9 +256,9 @@ void main (void)
color += Specular * gl_FrontMaterial.specular * nmap.a;
color = clamp( color, 0.0, 1.0 );
////////////////////////////////////////////////////////////////////
//BEGIN reflect
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//BEGIN reflect
////////////////////////////////////////////////////////////////////
if (refl_enabled > 0 && shader_qual > 1){
float reflFactor = 0.0;
float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset
@ -325,9 +325,9 @@ void main (void)
fragColor += Specular * nmap.a;
//////////////////////////////////////////////////////////////////////
// BEGIN lightmap
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// BEGIN lightmap
//////////////////////////////////////////////////////////////////////
if ( lightmap_enabled >= 1 ) {
vec3 lightmapcolor = vec3(0.0);
vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor,
@ -343,24 +343,24 @@ void main (void)
}
fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor);
}
//////////////////////////////////////////////////////////////////////
// END lightmap
/////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// END lightmap
/////////////////////////////////////////////////////////////////////
/// BEGIN fog amount
/// BEGIN fog amount
float transmission;
float vAltitude;
float delta_zv;
float H;
float distance_in_layer;
float transmission_arg;
float eqColorFactor;
float transmission;
float vAltitude;
float delta_zv;
float H;
float distance_in_layer;
float transmission_arg;
float eqColorFactor;
float delta_z = hazeLayerAltitude - eye_alt;
float delta_z = hazeLayerAltitude - eye_alt;
if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
{
if (delta_z > 0.0) // we're inside the layer
{
@ -412,15 +412,15 @@ if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
transmission = fog_func(transmission_arg, alt);
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
}
else
else
{
eqColorFactor = 1.0;
transmission = 1.0;
}
/// END fog amount
/// END fog amount
/// BEGIN fog color
/// BEGIN fog color
vec3 hazeColor;
@ -458,9 +458,9 @@ else
}
/// END fog color
/// END fog color
fragColor = clamp(fragColor, 0.0, 1.0);
//fragColor = fragColor * smoothstep(-0.05, 0.05, ct);
fragColor.rgb = mix(eqColorFactor * hazeColor * fog_earthShade, fragColor.rgb,transmission);
gl_FragColor = fragColor;
}
}