Page 1 of 1

Planet turns red during eclipse

Posted: 28.07.2008, 01:40
by PlutonianEmpire
When using Mie atmospheres on a planet around a binary star, the air turns red when a eclipse occurs.

Image

cel://Follow/DEL Tri:Belle Hades/2008-07-31T17:42:57.09833?x=JMBThKySDkDFE/o&y=4spHKLuYgwJLFXk&z=UNsjsicGyIkN2RH//////w&ow=0.893434&ox=0.114377&oy=-0.123250&oz=0.416537&select=DEL Tri:Belle Hades&fov=25.997908&ts=1.000000&ltd=0&p=1&rf=841655&lm=0&ver=2

SSC code for the planet

Code: Select all

"Belle Hades" "DEL Tri" {
   Texture "bellehades.png"
   NightTexture "bellehades-night.png"
   BumpMap "bellehades-bump.png"
   BumpHeight 0.8
   Color [ 0.90 0.90 1.00 ]
   HazeColor [ 0.40 0.60 1.00 ]
   HazeDensity 1.00
   Radius 8291.582

SpecularTexture "bellehades-spec.png"
   SpecularColor [ 1.00 1.00 0.75 ]
   SpecularPower 30

   Atmosphere {
      Height 82.91
      Lower [ 0.40 0.60 1.00 ]
      Upper [ 0.00 0.00 0.50 ]
      Sky   [ 0.20 0.40 1.00 ]
      CloudHeight 8.291
      CloudSpeed 19
      CloudMap "bellehades-clouds4.png"

      Mie 0.001
      MieAsymmetry -0.25
      Rayleigh [ 0.001 0.0025 0.006 ]
      MieScaleHeight 17
   }

   EllipticalOrbit {
      Period            1.0600456621004566210045662100457
      SemiMajorAxis     1.0550
      Eccentricity      0.0100
      Inclination       59.714
      AscendingNode     122.736
                ArgOfPericenter   28.474
      MeanAnomaly       286.4439
   }

   RotationPeriod          26.00
   EquatorAscendingNode   122.736
   Obliquity               39.928
   
   Albedo           0.32
}

"Lethe" "DEL Tri/Belle Hades" {
   Texture "lethe.png"
   BumpMap "lethe-bump.png"
   BumpHeight 1.61
   Radius 1200.00

   EllipticalOrbit {
      Period            3.1489
      SemiMajorAxis     120000.0000
      Eccentricity      0.0053
      Inclination       4.0750
      MeanAnomaly       44.4596
   }

   LunarLambert 1.0

   Obliquity        4.075
   RotationOffset   174.200

   Albedo         0.27
}


OS: Windows Vista Home Premium
Video card: Nvidia GeForce 6150SE nForce 430
Celestia: 1.5.1

Re: Planet turns red during eclipse

Posted: 28.07.2008, 10:22
by selden
Celestia draws planets red when the OpenGL runtime vertex shader compiler returns an error. Often this is when more vertex shaders are invoked than your graphics card can support. Please provide the contents of the file shaders.log, which is written to the current default directory. That's usually the desktop.

Re: Planet turns red during eclipse

Posted: 28.07.2008, 13:26
by duds26
It could be a good idea to let a text appear:
Error: more vertex shaders are invoked than your graphics card can support.

So the user knows it's something with his/her graphic card not having the capabilities to run stuff and that this is NOT a fault of CELESTIA.
Celestia 1.6 ?

Re: Planet turns red during eclipse

Posted: 28.07.2008, 14:32
by selden
Celestia has no way to know the exact cause of the error, only that the compilation failed.
Sometimes it is caused by a bug in the compiler.

You need to provide the contents of the log file so Chris can attempt to prevent that error in the source code.

Re: Planet turns red during eclipse

Posted: 31.07.2008, 22:59
by PlutonianEmpire
selden wrote:Celestia draws planets red when the OpenGL runtime vertex shader compiler returns an error. Often this is when more vertex shaders are invoked than your graphics card can support. Please provide the contents of the file shaders.log, which is written to the current default directory. That's usually the desktop.

EDIT: I discovered that this bug was at play when I had nightlights enabled.

Code: Select all

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 eyePosition;
  7: varying vec2 diffTexCoord;
  8: varying vec2 normTexCoord;
  9: varying vec2 nightTexCoord;
 10: uniform float textureOffset;
 11: uniform vec3 atmosphereRadius;
 12: uniform float mieCoeff;
 13: uniform float mieH;
 14: uniform float mieK;
 15: uniform vec3 rayleighCoeff;
 16: uniform float rayleighH;
 17: uniform vec3 scatterCoeffSum;
 18: uniform vec3 invScatterCoeffSum;
 19: uniform vec3 extinctionCoeff;
 20: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 21: attribute vec3 tangent;
 22: varying vec3 lightDir_tan_0;
 23: varying vec3 eyeDir_tan;
 24: varying vec3 scatterEx;
 25: uniform float ringWidth;
 26: uniform float ringRadius;
 27: varying vec4 ringShadowTexCoord;
 28:
 29: void main(void)
 30: {
 31: float NL;
 32: vec3 bitangent = cross(gl_Normal, tangent);
 33: eyeDir_tan.x = dot(tangent, eyeDir);
 34: eyeDir_tan.y = dot(-bitangent, eyeDir);
 35: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 36: NL = max(0.0, dot(gl_Normal, light0_direction));
 37: lightDir_tan_0.x = dot(tangent, light0_direction);
 38: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 39: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 40: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 41: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 42: nightTexCoord = gl_MultiTexCoord2.st;
 43: vec3 ringShadowProj;
 44: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, gl_Vertex.y / -light0_direction.y);
 45: ringShadowTexCoord.x = (length(ringShadowProj) - ringRadius) * ringWidth;
 46: {
 47:     float rq = dot(eyePosition, eyeDir);
 48:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 49:     float d = sqrt(rq * rq - qq);
 50:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 51:     vec3 atmLeave = gl_Vertex.xyz;
 52:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 53:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 54:     rq = dot(atmSamplePointSun, light0_direction);
 55:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 56:     d = sqrt(rq * rq - qq);
 57:     float distSun = -rq + d;
 58:     float distAtm = length(atmEnter - atmLeave);
 59:     float density = 0.0;
 60:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 61:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 62:     density += exp(-h * mieH);
 63:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 64:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 65:     density += exp(-h * mieH);
 66:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 67:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 68:     float cosTheta = dot(eyeDir, light0_direction);
 69:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 70:     float phRayleigh = 1.0;
 71:     scatterEx = ex;
 72:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 73: }
 74: gl_Position = ftransform();
 75: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: uniform sampler2D nightTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: varying vec2 nightTexCoord;
  8: uniform vec3 ambientColor;
  9: uniform float opacity;
 10: vec4 diff = vec4(ambientColor, opacity);
 11: varying vec3 eyeDir_tan;
 12: vec4 spec = vec4(0.0);
 13: uniform float shininess;
 14: varying vec3 lightDir_tan_0;
 15: uniform vec3 lightcolor0;
 16: uniform vec3 lightspecColor0;
 17: varying vec3 scatterEx;
 18: uniform sampler2D ringTex;
 19: varying vec4 ringShadowTexCoord;
 20:
 21: void main(void)
 22: {
 23: vec4 color;
 24: float shadow;
 25: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 26: float l;
 27: vec3 V = normalize(eyeDir_tan);
 28: vec3 H;
 29: float NH;
 30: float NL;
 31: NL = dot(lightDir_tan_0, n);
 32: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 33: float totalLight = l;
 34: shadow = 1.0;
 35: shadow *= (1.0 - texture2D(ringTex, vec2(ringShadowTexCoord.x, 0.0)).a);
 36: diff.rgb += l * shadow * lightcolor0;
 37: H = normalize(eyeDir_tan + lightDir_tan_0);
 38: NH = max(0.0, dot(n, H));
 39: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor0;
 40: color = texture2D(diffTex, diffTexCoord.st);
 41: gl_FragColor = color * diff + float(color.a) * spec;
 42: totalLight = 1.0 - totalLight;
 43: totalLight = totalLight * totalLight * totalLight * totalLight;
 44: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 45: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 46: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 eyePosition;
  7: varying vec2 diffTexCoord;
  8: uniform float textureOffset;
  9: uniform vec3 atmosphereRadius;
 10: uniform float mieCoeff;
 11: uniform float mieH;
 12: uniform float mieK;
 13: uniform vec3 rayleighCoeff;
 14: uniform float rayleighH;
 15: uniform vec3 scatterCoeffSum;
 16: uniform vec3 invScatterCoeffSum;
 17: uniform vec3 extinctionCoeff;
 18: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 19: float NV = dot(gl_Normal, eyeDir);
 20: varying vec4 diffFactors;
 21: varying vec3 scatterEx;
 22: uniform float ringWidth;
 23: uniform float ringRadius;
 24: varying vec4 ringShadowTexCoord;
 25:
 26: void main(void)
 27: {
 28: float NL;
 29: NL = max(0.0, dot(gl_Normal, light0_direction));
 30: diffFactors.x = NL;
 31: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 32: vec3 ringShadowProj;
 33: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, gl_Vertex.y / -light0_direction.y);
 34: ringShadowTexCoord.x = (length(ringShadowProj) - ringRadius) * ringWidth;
 35: {
 36:     float rq = dot(eyePosition, eyeDir);
 37:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 38:     float d = sqrt(rq * rq - qq);
 39:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 40:     vec3 atmLeave = gl_Vertex.xyz;
 41:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 42:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 43:     rq = dot(atmSamplePointSun, light0_direction);
 44:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 45:     d = sqrt(rq * rq - qq);
 46:     float distSun = -rq + d;
 47:     float distAtm = length(atmEnter - atmLeave);
 48:     float density = 0.0;
 49:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 50:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 51:     density += exp(-h * mieH);
 52:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 53:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 54:     density += exp(-h * mieH);
 55:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 56:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 57:     float cosTheta = dot(eyeDir, light0_direction);
 58:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 59:     float phRayleigh = 1.0;
 60:     scatterEx = ex;
 61:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 62: }
 63: gl_Position = ftransform();
 64: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: varying vec2 diffTexCoord;
  4: uniform vec3 ambientColor;
  5: uniform float opacity;
  6: vec4 diff = vec4(ambientColor, opacity);
  7: varying vec4 diffFactors;
  8: uniform vec3 lightcolor0;
  9: varying vec3 scatterEx;
 10: uniform sampler2D ringTex;
 11: varying vec4 ringShadowTexCoord;
 12:
 13: void main(void)
 14: {
 15: vec4 color;
 16: float shadow;
 17: shadow = diffFactors.x;
 18: shadow *= (1.0 - texture2D(ringTex, vec2(ringShadowTexCoord.x, 0.0)).a);
 19: diff.rgb += shadow * lightcolor0;
 20: color = texture2D(diffTex, diffTexCoord.st);
 21: gl_FragColor = color * diff;
 22: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 23: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 eyePosition;
  7: varying vec4 diffFactors;
  8: varying vec2 diffTexCoord;
  9: varying vec3 position_obj;
 10: varying vec4 shadowDepths;
 11:
 12: void main(void)
 13: {
 14: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 15: diffFactors.x = (dot(light0_direction, eyeDir) + 1.0) * 0.5;
 16: diffTexCoord = gl_MultiTexCoord0.st;
 17: position_obj = gl_Vertex.xyz;
 18: shadowDepths.x = dot(gl_Vertex.xyz, light0_direction);
 19: gl_Position = ftransform();
 20: }

Fragment shader source:
  1: #version 110
  2: uniform vec3 ambientColor;
  3: vec4 diff = vec4(ambientColor, 1.0);
  4: uniform vec3 lightcolor0;
  5: varying vec4 diffFactors;
  6: varying vec2 diffTexCoord;
  7: uniform sampler2D diffTex;
  8: varying vec3 position_obj;
  9: varying vec4 shadowDepths;
 10: uniform vec4 shadowTexGenS0_0;
 11: uniform vec4 shadowTexGenT0_0;
 12: uniform float shadowScale0_0;
 13: uniform float shadowBias0_0;
 14:
 15: void main(void)
 16: {
 17: vec4 color;
 18: float shadow;
 19: vec2 shadowCenter;
 20: float shadowR;
 21: shadow = 1.0;
 22: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS0_0) - 0.5;
 23: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT0_0) - 0.5;
 24: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale0_0 + shadowBias0_0, 0.0, 1.0);
 25: shadow *= sqrt(shadowR);
 26: shadow = min(1.0, shadow + step(0.0, shadowDepths.x));
 27: diff.rgb += (shadow * diffFactors.x) * lightcolor0;
 28: color = texture2D(diffTex, diffTexCoord.st);
 29: gl_FragColor = color * diff;
 30: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 eyePosition;
  7: uniform vec3 atmosphereRadius;
  8: uniform float mieCoeff;
  9: uniform float mieH;
 10: uniform float mieK;
 11: uniform vec3 rayleighCoeff;
 12: uniform float rayleighH;
 13: uniform vec3 scatterCoeffSum;
 14: uniform vec3 invScatterCoeffSum;
 15: uniform vec3 extinctionCoeff;
 16: varying vec3 scatteredColor0;
 17: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 18: float NV = dot(gl_Normal, eyeDir);
 19: varying vec3 scatterEx;
 20: varying vec3 eyeDir_obj;
 21:
 22: void main(void)
 23: {
 24: float NL;
 25: {
 26:     float rq = dot(eyePosition, eyeDir);
 27:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 28:     float d = sqrt(rq * rq - qq);
 29:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 30:     vec3 atmLeave = gl_Vertex.xyz;
 31:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 32:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 33:     rq = dot(atmSamplePointSun, light0_direction);
 34:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 35:     d = sqrt(rq * rq - qq);
 36:     float distSun = -rq + d;
 37:     float distAtm = length(atmEnter - atmLeave);
 38:     float density = 0.0;
 39:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 40:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 41:     density += exp(-h * mieH);
 42:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 43:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 44:     density += exp(-h * mieH);
 45:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 46:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 47:     scatterEx = ex;
 48:     scatteredColor0 = sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 49: }
 50: eyeDir_obj = eyeDir;
 51: gl_Position = ftransform();
 52: }

Fragment shader source:
  1: #version 110
  2: varying vec3 scatterEx;
  3: varying vec3 eyeDir_obj;
  4: uniform float mieK;
  5: uniform float mieCoeff;
  6: uniform vec3  rayleighCoeff;
  7: uniform vec3  invScatterCoeffSum;
  8: uniform vec3 light0_direction;
  9: varying vec3 scatteredColor0;
 10:
 11: void main(void)
 12: {
 13: vec3 color = vec3(0.0, 0.0, 0.0);
 14: vec3 V = normalize(eyeDir_obj);
 15:     float cosTheta = dot(V, light0_direction);
 16:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 17:     float phRayleigh = 1.0;
 18:     color += (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * scatteredColor0;
 19:     gl_FragColor = vec4(color, dot(scatterEx, vec3(0.333, 0.333, 0.333)));
 20: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: varying vec2 normTexCoord;
 13: varying vec2 specTexCoord;
 14: varying vec2 nightTexCoord;
 15: uniform float textureOffset;
 16: uniform vec3 atmosphereRadius;
 17: uniform float mieCoeff;
 18: uniform float mieH;
 19: uniform float mieK;
 20: uniform vec3 rayleighCoeff;
 21: uniform float rayleighH;
 22: uniform vec3 scatterCoeffSum;
 23: uniform vec3 invScatterCoeffSum;
 24: uniform vec3 extinctionCoeff;
 25: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 26: attribute vec3 tangent;
 27: varying vec3 lightDir_tan_0;
 28: varying vec3 lightDir_tan_1;
 29: varying vec3 eyeDir_tan;
 30: varying vec3 scatterEx;
 31:
 32: void main(void)
 33: {
 34: float NL;
 35: vec3 bitangent = cross(gl_Normal, tangent);
 36: eyeDir_tan.x = dot(tangent, eyeDir);
 37: eyeDir_tan.y = dot(-bitangent, eyeDir);
 38: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 39: NL = max(0.0, dot(gl_Normal, light0_direction));
 40: lightDir_tan_0.x = dot(tangent, light0_direction);
 41: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 42: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 43: NL = max(0.0, dot(gl_Normal, light1_direction));
 44: lightDir_tan_1.x = dot(tangent, light1_direction);
 45: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 46: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 47: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 48: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 49: specTexCoord = gl_MultiTexCoord2.st;
 50: nightTexCoord = gl_MultiTexCoord3.st;
 51: {
 52:     float rq = dot(eyePosition, eyeDir);
 53:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 54:     float d = sqrt(rq * rq - qq);
 55:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 56:     vec3 atmLeave = gl_Vertex.xyz;
 57:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 58:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 59:     rq = dot(atmSamplePointSun, light0_direction);
 60:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 61:     d = sqrt(rq * rq - qq);
 62:     float distSun = -rq + d;
 63:     float distAtm = length(atmEnter - atmLeave);
 64:     float density = 0.0;
 65:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 66:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 67:     density += exp(-h * mieH);
 68:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 69:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 70:     density += exp(-h * mieH);
 71:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 72:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 73:     float cosTheta = dot(eyeDir, light0_direction);
 74:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 75:     float phRayleigh = 1.0;
 76:     scatterEx = ex;
 77:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 78: }
 79: gl_Position = ftransform();
 80: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: uniform sampler2D specTex;
  5: uniform sampler2D nightTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: varying vec2 nightTexCoord;
 10: uniform vec3 ambientColor;
 11: uniform float opacity;
 12: vec4 diff = vec4(ambientColor, opacity);
 13: varying vec3 eyeDir_tan;
 14: vec4 spec = vec4(0.0);
 15: uniform float shininess;
 16: varying vec3 lightDir_tan_0;
 17: uniform vec3 lightcolor0;
 18: uniform vec3 lightspecColor0;
 19: varying vec3 lightDir_tan_1;
 20: uniform vec3 lightcolor1;
 21: uniform vec3 lightspecColor1;
 22: varying vec3 scatterEx;
 23:
 24: void main(void)
 25: {
 26: vec4 color;
 27: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 28: float l;
 29: vec3 V = normalize(eyeDir_tan);
 30: vec3 H;
 31: float NH;
 32: float NL;
 33: NL = dot(lightDir_tan_0, n);
 34: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 35: float totalLight = l;
 36: diff.rgb += l * lightcolor0;
 37: H = normalize(eyeDir_tan + lightDir_tan_0);
 38: NH = max(0.0, dot(n, H));
 39: spec.rgb += l * pow(NH, shininess) * lightspecColor0;
 40: NL = dot(lightDir_tan_1, n);
 41: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 42: totalLight += l;
 43: diff.rgb += l * lightcolor1;
 44: H = normalize(eyeDir_tan + lightDir_tan_1);
 45: NH = max(0.0, dot(n, H));
 46: spec.rgb += l * pow(NH, shininess) * lightspecColor1;
 47: color = texture2D(diffTex, diffTexCoord.st);
 48: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 49: totalLight = 1.0 - totalLight;
 50: totalLight = totalLight * totalLight * totalLight * totalLight;
 51: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 52: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 53: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: uniform float textureOffset;
 13: uniform vec3 atmosphereRadius;
 14: uniform float mieCoeff;
 15: uniform float mieH;
 16: uniform float mieK;
 17: uniform vec3 rayleighCoeff;
 18: uniform float rayleighH;
 19: uniform vec3 scatterCoeffSum;
 20: uniform vec3 invScatterCoeffSum;
 21: uniform vec3 extinctionCoeff;
 22: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 23: float NV = dot(gl_Normal, eyeDir);
 24: uniform vec3 ambientColor;
 25: uniform float opacity;
 26: varying vec4 diff;
 27: varying vec3 scatterEx;
 28:
 29: void main(void)
 30: {
 31: float NL;
 32: diff = vec4(ambientColor, opacity);
 33: NL = max(0.0, dot(gl_Normal, light0_direction));
 34: diff.rgb += light0_diffuse * NL;
 35: NL = max(0.0, dot(gl_Normal, light1_direction));
 36: diff.rgb += light1_diffuse * NL;
 37: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 38: {
 39:     float rq = dot(eyePosition, eyeDir);
 40:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 41:     float d = sqrt(rq * rq - qq);
 42:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 43:     vec3 atmLeave = gl_Vertex.xyz;
 44:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 45:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 46:     rq = dot(atmSamplePointSun, light0_direction);
 47:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 48:     d = sqrt(rq * rq - qq);
 49:     float distSun = -rq + d;
 50:     float distAtm = length(atmEnter - atmLeave);
 51:     float density = 0.0;
 52:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 53:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 54:     density += exp(-h * mieH);
 55:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 56:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 57:     density += exp(-h * mieH);
 58:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 59:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 60:     float cosTheta = dot(eyeDir, light0_direction);
 61:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 62:     float phRayleigh = 1.0;
 63:     scatterEx = ex;
 64:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 65: }
 66: gl_Position = ftransform();
 67: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: varying vec2 diffTexCoord;
  4: varying vec4 diff;
  5: varying vec3 scatterEx;
  6:
  7: void main(void)
  8: {
  9: vec4 color;
 10: color = texture2D(diffTex, diffTexCoord.st);
 11: gl_FragColor = color * diff;
 12: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 13: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: uniform vec3 atmosphereRadius;
 12: uniform float mieCoeff;
 13: uniform float mieH;
 14: uniform float mieK;
 15: uniform vec3 rayleighCoeff;
 16: uniform float rayleighH;
 17: uniform vec3 scatterCoeffSum;
 18: uniform vec3 invScatterCoeffSum;
 19: uniform vec3 extinctionCoeff;
 20: varying vec3 scatteredColor0;
 21: varying vec3 scatteredColor1;
 22: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 23: float NV = dot(gl_Normal, eyeDir);
 24: varying vec3 scatterEx;
 25: varying vec3 eyeDir_obj;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: {
 31:     float rq = dot(eyePosition, eyeDir);
 32:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 33:     float d = sqrt(rq * rq - qq);
 34:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 35:     vec3 atmLeave = gl_Vertex.xyz;
 36:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 37:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 38:     rq = dot(atmSamplePointSun, light0_direction);
 39:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 40:     d = sqrt(rq * rq - qq);
 41:     float distSun = -rq + d;
 42:     float distAtm = length(atmEnter - atmLeave);
 43:     float density = 0.0;
 44:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 45:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 46:     density += exp(-h * mieH);
 47:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 48:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 49:     density += exp(-h * mieH);
 50:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 51:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 52:     scatterEx = ex;
 53:     scatteredColor0 = sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 54: }
 55: eyeDir_obj = eyeDir;
 56: gl_Position = ftransform();
 57: }

Fragment shader source:
  1: #version 110
  2: varying vec3 scatterEx;
  3: varying vec3 eyeDir_obj;
  4: uniform float mieK;
  5: uniform float mieCoeff;
  6: uniform vec3  rayleighCoeff;
  7: uniform vec3  invScatterCoeffSum;
  8: uniform vec3 light0_direction;
  9: varying vec3 scatteredColor0;
 10: uniform vec3 light1_direction;
 11: varying vec3 scatteredColor1;
 12:
 13: void main(void)
 14: {
 15: vec3 color = vec3(0.0, 0.0, 0.0);
 16: vec3 V = normalize(eyeDir_obj);
 17:     float cosTheta = dot(V, light0_direction);
 18:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 19:     float phRayleigh = 1.0;
 20:     color += (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * scatteredColor0;
 21:     gl_FragColor = vec4(color, dot(scatterEx, vec3(0.333, 0.333, 0.333)));
 22: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: varying vec2 normTexCoord;
 13: varying vec2 specTexCoord;
 14: varying vec2 nightTexCoord;
 15: uniform float textureOffset;
 16: uniform vec3 atmosphereRadius;
 17: uniform float mieCoeff;
 18: uniform float mieH;
 19: uniform float mieK;
 20: uniform vec3 rayleighCoeff;
 21: uniform float rayleighH;
 22: uniform vec3 scatterCoeffSum;
 23: uniform vec3 invScatterCoeffSum;
 24: uniform vec3 extinctionCoeff;
 25: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 26: attribute vec3 tangent;
 27: varying vec3 lightDir_tan_0;
 28: varying vec3 lightDir_tan_1;
 29: varying vec3 eyeDir_tan;
 30: varying vec3 scatterEx;
 31: varying vec3 position_obj;
 32:
 33: void main(void)
 34: {
 35: float NL;
 36: vec3 bitangent = cross(gl_Normal, tangent);
 37: eyeDir_tan.x = dot(tangent, eyeDir);
 38: eyeDir_tan.y = dot(-bitangent, eyeDir);
 39: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 40: NL = max(0.0, dot(gl_Normal, light0_direction));
 41: lightDir_tan_0.x = dot(tangent, light0_direction);
 42: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 43: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 44: NL = max(0.0, dot(gl_Normal, light1_direction));
 45: lightDir_tan_1.x = dot(tangent, light1_direction);
 46: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 47: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 48: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 49: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 50: specTexCoord = gl_MultiTexCoord2.st;
 51: nightTexCoord = gl_MultiTexCoord3.st;
 52: {
 53:     float rq = dot(eyePosition, eyeDir);
 54:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 55:     float d = sqrt(rq * rq - qq);
 56:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 57:     vec3 atmLeave = gl_Vertex.xyz;
 58:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 59:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 60:     rq = dot(atmSamplePointSun, light0_direction);
 61:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 62:     d = sqrt(rq * rq - qq);
 63:     float distSun = -rq + d;
 64:     float distAtm = length(atmEnter - atmLeave);
 65:     float density = 0.0;
 66:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 67:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 68:     density += exp(-h * mieH);
 69:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 70:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 71:     density += exp(-h * mieH);
 72:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 73:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 74:     float cosTheta = dot(eyeDir, light0_direction);
 75:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 76:     float phRayleigh = 1.0;
 77:     scatterEx = ex;
 78:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 79: }
 80: position_obj = gl_Vertex.xyz;
 81: gl_Position = ftransform();
 82: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: uniform sampler2D specTex;
  5: uniform sampler2D nightTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: varying vec2 nightTexCoord;
 10: uniform vec3 ambientColor;
 11: uniform float opacity;
 12: vec4 diff = vec4(ambientColor, opacity);
 13: varying vec3 eyeDir_tan;
 14: vec4 spec = vec4(0.0);
 15: uniform float shininess;
 16: varying vec3 lightDir_tan_0;
 17: uniform vec3 lightcolor0;
 18: uniform vec3 lightspecColor0;
 19: varying vec3 lightDir_tan_1;
 20: uniform vec3 lightcolor1;
 21: uniform vec3 lightspecColor1;
 22: varying vec3 scatterEx;
 23: varying vec3 position_obj;
 24: uniform vec4 shadowTexGenS1_0;
 25: uniform vec4 shadowTexGenT1_0;
 26: uniform float shadowScale1_0;
 27: uniform float shadowBias1_0;
 28:
 29: void main(void)
 30: {
 31: vec4 color;
 32: float shadow;
 33: vec2 shadowCenter;
 34: float shadowR;
 35: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 36: float l;
 37: vec3 V = normalize(eyeDir_tan);
 38: vec3 H;
 39: float NH;
 40: float NL;
 41: NL = dot(lightDir_tan_0, n);
 42: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 43: float totalLight = l;
 44: diff.rgb += l * lightcolor0;
 45: H = normalize(eyeDir_tan + lightDir_tan_0);
 46: NH = max(0.0, dot(n, H));
 47: spec.rgb += l * pow(NH, shininess) * lightspecColor0;
 48: NL = dot(lightDir_tan_1, n);
 49: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 50: totalLight += l;
 51: shadow = 1.0;
 52: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS1_0) - 0.5;
 53: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT1_0) - 0.5;
 54: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale1_0 + shadowBias1_0, 0.0, 1.0);
 55: shadow *= sqrt(shadowR);
 56: diff.rgb += l * shadow * lightcolor1;
 57: H = normalize(eyeDir_tan + lightDir_tan_1);
 58: NH = max(0.0, dot(n, H));
 59: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor1;
 60: color = texture2D(diffTex, diffTexCoord.st);
 61: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 62: totalLight = 1.0 - totalLight;
 63: totalLight = totalLight * totalLight * totalLight * totalLight;
 64: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 65: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 66: }

Error linking shader program:
Fragment info
-------------
(23) : error C5041: cannot locate suitable resource to bind parameter "position_obj"
Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: varying vec2 normTexCoord;
 13: uniform float textureOffset;
 14: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 15: attribute vec3 tangent;
 16: varying vec3 lightDir_tan_0;
 17: varying vec3 lightDir_tan_1;
 18: varying vec3 eyeDir_tan;
 19:
 20: void main(void)
 21: {
 22: float NL;
 23: vec3 bitangent = cross(gl_Normal, tangent);
 24: eyeDir_tan.x = dot(tangent, eyeDir);
 25: eyeDir_tan.y = dot(-bitangent, eyeDir);
 26: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 27: NL = max(0.0, dot(gl_Normal, light0_direction));
 28: lightDir_tan_0.x = dot(tangent, light0_direction);
 29: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 30: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 31: NL = max(0.0, dot(gl_Normal, light1_direction));
 32: lightDir_tan_1.x = dot(tangent, light1_direction);
 33: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 34: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 35: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 36: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 37: gl_Position = ftransform();
 38: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: varying vec2 diffTexCoord;
  5: varying vec2 normTexCoord;
  6: uniform vec3 ambientColor;
  7: uniform float opacity;
  8: vec4 diff = vec4(ambientColor, opacity);
  9: varying vec3 eyeDir_tan;
 10: vec4 spec = vec4(0.0);
 11: uniform float shininess;
 12: uniform float lunarLambert;
 13: varying vec3 lightDir_tan_0;
 14: uniform vec3 lightcolor0;
 15: varying vec3 lightDir_tan_1;
 16: uniform vec3 lightcolor1;
 17:
 18: void main(void)
 19: {
 20: vec4 color;
 21: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 22: float l;
 23: vec3 V = normalize(eyeDir_tan);
 24: float NV = dot(n, V);
 25: float NL;
 26: NL = dot(lightDir_tan_0, n);
 27: NL = max(0.0, NL);
 28: l = mix(NL, (NL / (max(NV, 0.001) + NL)), lunarLambert) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 29: diff.rgb += l * lightcolor0;
 30: NL = dot(lightDir_tan_1, n);
 31: NL = max(0.0, NL);
 32: l = mix(NL, (NL / (max(NV, 0.001) + NL)), lunarLambert) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 33: diff.rgb += l * lightcolor1;
 34: color = texture2D(diffTex, diffTexCoord.st);
 35: gl_FragColor = color * diff;
 36: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: varying vec2 normTexCoord;
 13: varying vec2 specTexCoord;
 14: varying vec2 nightTexCoord;
 15: uniform float textureOffset;
 16: uniform vec3 atmosphereRadius;
 17: uniform float mieCoeff;
 18: uniform float mieH;
 19: uniform float mieK;
 20: uniform vec3 rayleighCoeff;
 21: uniform float rayleighH;
 22: uniform vec3 scatterCoeffSum;
 23: uniform vec3 invScatterCoeffSum;
 24: uniform vec3 extinctionCoeff;
 25: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 26: attribute vec3 tangent;
 27: varying vec3 lightDir_tan_0;
 28: varying vec3 lightDir_tan_1;
 29: varying vec3 eyeDir_tan;
 30: varying vec3 scatterEx;
 31: varying vec3 position_obj;
 32:
 33: void main(void)
 34: {
 35: float NL;
 36: vec3 bitangent = cross(gl_Normal, tangent);
 37: eyeDir_tan.x = dot(tangent, eyeDir);
 38: eyeDir_tan.y = dot(-bitangent, eyeDir);
 39: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 40: NL = max(0.0, dot(gl_Normal, light0_direction));
 41: lightDir_tan_0.x = dot(tangent, light0_direction);
 42: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 43: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 44: NL = max(0.0, dot(gl_Normal, light1_direction));
 45: lightDir_tan_1.x = dot(tangent, light1_direction);
 46: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 47: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 48: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 49: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 50: specTexCoord = gl_MultiTexCoord2.st;
 51: nightTexCoord = gl_MultiTexCoord3.st;
 52: {
 53:     float rq = dot(eyePosition, eyeDir);
 54:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 55:     float d = sqrt(rq * rq - qq);
 56:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 57:     vec3 atmLeave = gl_Vertex.xyz;
 58:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 59:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 60:     rq = dot(atmSamplePointSun, light0_direction);
 61:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 62:     d = sqrt(rq * rq - qq);
 63:     float distSun = -rq + d;
 64:     float distAtm = length(atmEnter - atmLeave);
 65:     float density = 0.0;
 66:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 67:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 68:     density += exp(-h * mieH);
 69:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 70:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 71:     density += exp(-h * mieH);
 72:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 73:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 74:     float cosTheta = dot(eyeDir, light0_direction);
 75:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 76:     float phRayleigh = 1.0;
 77:     scatterEx = ex;
 78:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 79: }
 80: position_obj = gl_Vertex.xyz;
 81: gl_Position = ftransform();
 82: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: uniform sampler2D specTex;
  5: uniform sampler2D nightTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: varying vec2 nightTexCoord;
 10: uniform vec3 ambientColor;
 11: uniform float opacity;
 12: vec4 diff = vec4(ambientColor, opacity);
 13: varying vec3 eyeDir_tan;
 14: vec4 spec = vec4(0.0);
 15: uniform float shininess;
 16: varying vec3 lightDir_tan_0;
 17: uniform vec3 lightcolor0;
 18: uniform vec3 lightspecColor0;
 19: varying vec3 lightDir_tan_1;
 20: uniform vec3 lightcolor1;
 21: uniform vec3 lightspecColor1;
 22: varying vec3 scatterEx;
 23: varying vec3 position_obj;
 24: uniform vec4 shadowTexGenS0_0;
 25: uniform vec4 shadowTexGenT0_0;
 26: uniform float shadowScale0_0;
 27: uniform float shadowBias0_0;
 28: uniform vec4 shadowTexGenS1_0;
 29: uniform vec4 shadowTexGenT1_0;
 30: uniform float shadowScale1_0;
 31: uniform float shadowBias1_0;
 32:
 33: void main(void)
 34: {
 35: vec4 color;
 36: float shadow;
 37: vec2 shadowCenter;
 38: float shadowR;
 39: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 40: float l;
 41: vec3 V = normalize(eyeDir_tan);
 42: vec3 H;
 43: float NH;
 44: float NL;
 45: NL = dot(lightDir_tan_0, n);
 46: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 47: float totalLight = l;
 48: shadow = 1.0;
 49: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS0_0) - 0.5;
 50: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT0_0) - 0.5;
 51: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale0_0 + shadowBias0_0, 0.0, 1.0);
 52: shadow *= sqrt(shadowR);
 53: diff.rgb += l * shadow * lightcolor0;
 54: H = normalize(eyeDir_tan + lightDir_tan_0);
 55: NH = max(0.0, dot(n, H));
 56: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor0;
 57: NL = dot(lightDir_tan_1, n);
 58: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 59: totalLight += l;
 60: shadow = 1.0;
 61: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS1_0) - 0.5;
 62: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT1_0) - 0.5;
 63: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale1_0 + shadowBias1_0, 0.0, 1.0);
 64: shadow *= sqrt(shadowR);
 65: diff.rgb += l * shadow * lightcolor1;
 66: H = normalize(eyeDir_tan + lightDir_tan_1);
 67: NH = max(0.0, dot(n, H));
 68: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor1;
 69: color = texture2D(diffTex, diffTexCoord.st);
 70: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 71: totalLight = 1.0 - totalLight;
 72: totalLight = totalLight * totalLight * totalLight * totalLight;
 73: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 74: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 75: }

Error linking shader program:
Fragment info
-------------
(23) : error C5041: cannot locate suitable resource to bind parameter "position_obj"
Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: varying vec2 normTexCoord;
 13: varying vec2 specTexCoord;
 14: varying vec2 nightTexCoord;
 15: uniform float textureOffset;
 16: uniform vec3 atmosphereRadius;
 17: uniform float mieCoeff;
 18: uniform float mieH;
 19: uniform float mieK;
 20: uniform vec3 rayleighCoeff;
 21: uniform float rayleighH;
 22: uniform vec3 scatterCoeffSum;
 23: uniform vec3 invScatterCoeffSum;
 24: uniform vec3 extinctionCoeff;
 25: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 26: attribute vec3 tangent;
 27: varying vec3 lightDir_tan_0;
 28: varying vec3 lightDir_tan_1;
 29: varying vec3 eyeDir_tan;
 30: varying vec3 scatterEx;
 31: varying vec3 position_obj;
 32:
 33: void main(void)
 34: {
 35: float NL;
 36: vec3 bitangent = cross(gl_Normal, tangent);
 37: eyeDir_tan.x = dot(tangent, eyeDir);
 38: eyeDir_tan.y = dot(-bitangent, eyeDir);
 39: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 40: NL = max(0.0, dot(gl_Normal, light0_direction));
 41: lightDir_tan_0.x = dot(tangent, light0_direction);
 42: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 43: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 44: NL = max(0.0, dot(gl_Normal, light1_direction));
 45: lightDir_tan_1.x = dot(tangent, light1_direction);
 46: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 47: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 48: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 49: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 50: specTexCoord = gl_MultiTexCoord2.st;
 51: nightTexCoord = gl_MultiTexCoord3.st;
 52: {
 53:     float rq = dot(eyePosition, eyeDir);
 54:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 55:     float d = sqrt(rq * rq - qq);
 56:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 57:     vec3 atmLeave = gl_Vertex.xyz;
 58:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 59:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 60:     rq = dot(atmSamplePointSun, light0_direction);
 61:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 62:     d = sqrt(rq * rq - qq);
 63:     float distSun = -rq + d;
 64:     float distAtm = length(atmEnter - atmLeave);
 65:     float density = 0.0;
 66:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 67:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 68:     density += exp(-h * mieH);
 69:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 70:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 71:     density += exp(-h * mieH);
 72:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 73:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 74:     float cosTheta = dot(eyeDir, light0_direction);
 75:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 76:     float phRayleigh = 1.0;
 77:     scatterEx = ex;
 78:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 79: }
 80: position_obj = gl_Vertex.xyz;
 81: gl_Position = ftransform();
 82: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: uniform sampler2D normTex;
  4: uniform sampler2D specTex;
  5: uniform sampler2D nightTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: varying vec2 nightTexCoord;
 10: uniform vec3 ambientColor;
 11: uniform float opacity;
 12: vec4 diff = vec4(ambientColor, opacity);
 13: varying vec3 eyeDir_tan;
 14: vec4 spec = vec4(0.0);
 15: uniform float shininess;
 16: varying vec3 lightDir_tan_0;
 17: uniform vec3 lightcolor0;
 18: uniform vec3 lightspecColor0;
 19: varying vec3 lightDir_tan_1;
 20: uniform vec3 lightcolor1;
 21: uniform vec3 lightspecColor1;
 22: varying vec3 scatterEx;
 23: varying vec3 position_obj;
 24: uniform vec4 shadowTexGenS0_0;
 25: uniform vec4 shadowTexGenT0_0;
 26: uniform float shadowScale0_0;
 27: uniform float shadowBias0_0;
 28:
 29: void main(void)
 30: {
 31: vec4 color;
 32: float shadow;
 33: vec2 shadowCenter;
 34: float shadowR;
 35: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 36: float l;
 37: vec3 V = normalize(eyeDir_tan);
 38: vec3 H;
 39: float NH;
 40: float NL;
 41: NL = dot(lightDir_tan_0, n);
 42: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 43: float totalLight = l;
 44: shadow = 1.0;
 45: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS0_0) - 0.5;
 46: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT0_0) - 0.5;
 47: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale0_0 + shadowBias0_0, 0.0, 1.0);
 48: shadow *= sqrt(shadowR);
 49: diff.rgb += l * shadow * lightcolor0;
 50: H = normalize(eyeDir_tan + lightDir_tan_0);
 51: NH = max(0.0, dot(n, H));
 52: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor0;
 53: NL = dot(lightDir_tan_1, n);
 54: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 55: totalLight += l;
 56: diff.rgb += l * lightcolor1;
 57: H = normalize(eyeDir_tan + lightDir_tan_1);
 58: NH = max(0.0, dot(n, H));
 59: spec.rgb += l * pow(NH, shininess) * lightspecColor1;
 60: color = texture2D(diffTex, diffTexCoord.st);
 61: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 62: totalLight = 1.0 - totalLight;
 63: totalLight = totalLight * totalLight * totalLight * totalLight;
 64: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 65: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 66: }

Error linking shader program:
Fragment info
-------------
(23) : error C5041: cannot locate suitable resource to bind parameter "position_obj"
Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: uniform float textureOffset;
 13: uniform vec3 atmosphereRadius;
 14: uniform float mieCoeff;
 15: uniform float mieH;
 16: uniform float mieK;
 17: uniform vec3 rayleighCoeff;
 18: uniform float rayleighH;
 19: uniform vec3 scatterCoeffSum;
 20: uniform vec3 invScatterCoeffSum;
 21: uniform vec3 extinctionCoeff;
 22: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 23: float NV = dot(gl_Normal, eyeDir);
 24: varying vec4 diffFactors;
 25: varying vec3 scatterEx;
 26: varying vec3 position_obj;
 27:
 28: void main(void)
 29: {
 30: float NL;
 31: NL = max(0.0, dot(gl_Normal, light0_direction));
 32: diffFactors.x = NL;
 33: NL = max(0.0, dot(gl_Normal, light1_direction));
 34: diffFactors.y = NL;
 35: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 36: {
 37:     float rq = dot(eyePosition, eyeDir);
 38:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 39:     float d = sqrt(rq * rq - qq);
 40:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 41:     vec3 atmLeave = gl_Vertex.xyz;
 42:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 43:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 44:     rq = dot(atmSamplePointSun, light0_direction);
 45:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 46:     d = sqrt(rq * rq - qq);
 47:     float distSun = -rq + d;
 48:     float distAtm = length(atmEnter - atmLeave);
 49:     float density = 0.0;
 50:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 51:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 52:     density += exp(-h * mieH);
 53:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 54:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 55:     density += exp(-h * mieH);
 56:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 57:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 58:     float cosTheta = dot(eyeDir, light0_direction);
 59:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 60:     float phRayleigh = 1.0;
 61:     scatterEx = ex;
 62:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 63: }
 64: position_obj = gl_Vertex.xyz;
 65: gl_Position = ftransform();
 66: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: varying vec2 diffTexCoord;
  4: uniform vec3 ambientColor;
  5: uniform float opacity;
  6: vec4 diff = vec4(ambientColor, opacity);
  7: varying vec4 diffFactors;
  8: uniform vec3 lightcolor0;
  9: uniform vec3 lightcolor1;
 10: varying vec3 scatterEx;
 11: varying vec3 position_obj;
 12: uniform vec4 shadowTexGenS0_0;
 13: uniform vec4 shadowTexGenT0_0;
 14: uniform float shadowScale0_0;
 15: uniform float shadowBias0_0;
 16: uniform vec4 shadowTexGenS1_0;
 17: uniform vec4 shadowTexGenT1_0;
 18: uniform float shadowScale1_0;
 19: uniform float shadowBias1_0;
 20:
 21: void main(void)
 22: {
 23: vec4 color;
 24: float shadow;
 25: vec2 shadowCenter;
 26: float shadowR;
 27: shadow = diffFactors.x;
 28: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS0_0) - 0.5;
 29: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT0_0) - 0.5;
 30: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale0_0 + shadowBias0_0, 0.0, 1.0);
 31: shadow *= sqrt(shadowR);
 32: diff.rgb += shadow * lightcolor0;
 33: shadow = diffFactors.y;
 34: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS1_0) - 0.5;
 35: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT1_0) - 0.5;
 36: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale1_0 + shadowBias1_0, 0.0, 1.0);
 37: shadow *= sqrt(shadowR);
 38: diff.rgb += shadow * lightcolor1;
 39: color = texture2D(diffTex, diffTexCoord.st);
 40: gl_FragColor = color * diff;
 41: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 42: }

Vertex shader source:
  1: #version 110
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light0_specular;
  5: uniform vec3 light0_halfVector;
  6: uniform vec3 light1_direction;
  7: uniform vec3 light1_diffuse;
  8: uniform vec3 light1_specular;
  9: uniform vec3 light1_halfVector;
 10: uniform vec3 eyePosition;
 11: varying vec2 diffTexCoord;
 12: uniform float textureOffset;
 13: uniform vec3 atmosphereRadius;
 14: uniform float mieCoeff;
 15: uniform float mieH;
 16: uniform float mieK;
 17: uniform vec3 rayleighCoeff;
 18: uniform float rayleighH;
 19: uniform vec3 scatterCoeffSum;
 20: uniform vec3 invScatterCoeffSum;
 21: uniform vec3 extinctionCoeff;
 22: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 23: float NV = dot(gl_Normal, eyeDir);
 24: varying vec4 diffFactors;
 25: varying vec3 scatterEx;
 26: varying vec3 position_obj;
 27:
 28: void main(void)
 29: {
 30: float NL;
 31: NL = max(0.0, dot(gl_Normal, light0_direction));
 32: diffFactors.x = NL;
 33: NL = max(0.0, dot(gl_Normal, light1_direction));
 34: diffFactors.y = NL;
 35: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 36: {
 37:     float rq = dot(eyePosition, eyeDir);
 38:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 39:     float d = sqrt(rq * rq - qq);
 40:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 41:     vec3 atmLeave = gl_Vertex.xyz;
 42:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 43:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 44:     rq = dot(atmSamplePointSun, light0_direction);
 45:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 46:     d = sqrt(rq * rq - qq);
 47:     float distSun = -rq + d;
 48:     float distAtm = length(atmEnter - atmLeave);
 49:     float density = 0.0;
 50:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 51:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 52:     density += exp(-h * mieH);
 53:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 54:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 55:     density += exp(-h * mieH);
 56:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 57:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 58:     float cosTheta = dot(eyeDir, light0_direction);
 59:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 60:     float phRayleigh = 1.0;
 61:     scatterEx = ex;
 62:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 63: }
 64: position_obj = gl_Vertex.xyz;
 65: gl_Position = ftransform();
 66: }

Fragment shader source:
  1: #version 110
  2: uniform sampler2D diffTex;
  3: varying vec2 diffTexCoord;
  4: uniform vec3 ambientColor;
  5: uniform float opacity;
  6: vec4 diff = vec4(ambientColor, opacity);
  7: varying vec4 diffFactors;
  8: uniform vec3 lightcolor0;
  9: uniform vec3 lightcolor1;
 10: varying vec3 scatterEx;
 11: varying vec3 position_obj;
 12: uniform vec4 shadowTexGenS1_0;
 13: uniform vec4 shadowTexGenT1_0;
 14: uniform float shadowScale1_0;
 15: uniform float shadowBias1_0;
 16:
 17: void main(void)
 18: {
 19: vec4 color;
 20: float shadow;
 21: vec2 shadowCenter;
 22: float shadowR;
 23: shadow = diffFactors.x;
 24: diff.rgb += shadow * lightcolor0;
 25: shadow = diffFactors.y;
 26: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS1_0) - 0.5;
 27: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT1_0) - 0.5;
 28: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale1_0 + shadowBias1_0, 0.0, 1.0);
 29: shadow *= sqrt(shadowR);
 30: diff.rgb += shadow * lightcolor1;
 31: color = texture2D(diffTex, diffTexCoord.st);
 32: gl_FragColor = color * diff;
 33: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 34: }