Celestia 1.7.0 Development Thread

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #101by onetwothree » 14.01.2019, 20:37

I'm talking about Celestia's URLs. File->Copy URL (or Ctrl+C) in Qt version copies it into a clipboard so you can insert it here.

Just an example:

cel://Follow/Sol:Saturn/2019-01-14T20:37:42.39945 ... 459706263&lm=2052&tsrc=0&ver=4


It never was implemented in native windows version so users almost are not aware of it.

Avatar
LukeCEL
Posts: 373
Joined: 26.09.2017
With us: 6 years 11 months

Post #102by LukeCEL » 14.01.2019, 20:40

john71 wrote:What kind of web address do you want?

Cel URLs are basically strings of text that show a specific view. To save the current view, just do Ctrl+C, and to go to one, just do Ctrl+V.

For example, here's a view of Pluto that you can click: cel://Follow/Sol:Pluto/2019-01-14T20:38:39.60059? ... rf=3512279&lm=102&tsrc=0&ver=3

Edit: oops, looks like I was a tiny bit later than onetwothree. Oh well.

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #103by john71 » 15.01.2019, 13:00

I'm sorry, but the requested data won't make any sense for you because it is a totally fictional, vast multi-star system with many fictional planets on the other side of the Milky Way.

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Post #104by selden » 15.01.2019, 19:49

John,

If your addon is too big, please try to duplicate your problem with something simple, perhaps just using Celestia's solar system.

He wants Celestia URLs so he can tell Celestia to go immediately to exactly what you are looking at with the same settings as you are using so he can reproduce the problem and thus try to figure out how to fix it.

I've seen similar problems when I've turned up the "Ambient light" too much.

To generate a Celestia URL under Windows, run Celestia, goto the viewpoint, then type a Ctrl-C into Celestia's window. It'll write a Celestia URL into the computer's "clipboard".

You can then use a "Paste" command to write that URL into a Web page or other document. Under Windows, a Ctrl-V usually will do this. The Right-Mouse-Button popup menu usually includes a "Paste" command which does the same thing.

For example, here's a Celestia URL which takes you to Io:

cel://Follow/Sol:Jupiter:Io/2019-01-15T19:46:39.4 ... 0&rf=4456975&lm=9&tsrc=0&ver=3

and here's what I see when I use it:
Attachments
io.png
Celestia showing URL viewpoint
Selden

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #105by john71 » 16.01.2019, 09:46

OK, these are the solar system bugs:

red earth.png


black moon.png



cel://Follow/Sol:Earth/2019-01-18T06:38:08.54844? ... 579132347&lm=2198&tsrc=0&ver=4


cel://Follow/Sol:Earth:Moon/2019-01-18T06:40:45.2 ... 579132347&lm=2198&tsrc=0&ver=4

Added after 3 minutes 56 seconds:
Selden,

The Earth is red, the Moon is totally black from every angle.

I suspect it is not an ambient light problem, it is a texture problem.

There are no reflective surfaces.

Added after 1 hour 39 minutes:
Comparison: fictional planet with maximum ambient light in Alexell's version of Celestia

ambient.png


The same planet with the new build

white surface.jpg


Added after 17 minutes 15 seconds:
I suppose I don't have to use any files from the Celestia 1.6.1 version...?

Because I use the provided 7z file as it is.

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Post #106by selden » 16.01.2019, 15:03

Try turning off some of the Render View Options which are related to drawing planets to see if that makes any difference.

For example, objects are drawn red when Celestia v1.6.1 tries to use "too many" shader scripts. This often happens when a planet is orbiting more than one star so that multiple shadows have to be drawn. Disabling Cloud or Ring shadows might be sufficient.
Selden

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #107by john71 » 16.01.2019, 15:17

My fictional multi-star system is very complex, star barycenters are orbiting a black hole barycenter. But Celestia 1.6.1 and Alexell's 1.7 caused no problems at all.

It has nothing to do with cloud or other shadows, I tried it.

Maybe this is just an ambient light or tinted illumination bug after all, but it should not exist.

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #108by onetwothree » 16.01.2019, 17:09

john71, could you post here content of shaders.log? It looks like your system lacks some OpenGL extensions.


And another question: what renderer type do you use with 1.6.1 and Alexell's version? What video hardware and driver version do you have?

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #109by john71 » 16.01.2019, 17:25

I use OpenGL 2.0 on the other builds and I have an Nvidia GeForce 1050 Ti card, latest drivers.

Code: Select all

Vertex shader source:
  1: #version 120
  2: // static shader
  3: uniform sampler2D normTex;
  4: uniform float pointScale;
  5: attribute float pointSize;
  6: varying vec4 color;
  7:
  8: void main(void)
  9: {
 10:     gl_PointSize = pointSize;
 11:     color = gl_Color;
 12:     gl_Position = ftransform();
 13: }

Fragment shader source:
  1: #version 120
  2: uniform sampler2D normTex;
  3: varying vec4 color;
  4:
  5: void main(void)
  6: {
  7:     gl_FragColor = texture2D(normTex, gl_PointCoord) * color;
  8: }

Vertex shader source:
  1: #version 120
  2: uniform float opacity;
  3: uniform vec3 light0_diffuse;
  4:
  5: void main(void)
  6: {
  7:     gl_FrontColor = vec4(light0_diffuse, opacity);
  8:     gl_Position = ftransform();
  9: }

Fragment shader source:
  1: #version 120
  2:
  3: void main(void)
  4: {
  5:     gl_FragColor = gl_Color ;
  6: }

Vertex shader source:
  1: #version 120
  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 light2_direction;
 11: uniform vec3 light2_diffuse;
 12: uniform vec3 light2_specular;
 13: uniform vec3 light2_halfVector;
 14: uniform vec3 light3_direction;
 15: uniform vec3 light3_diffuse;
 16: uniform vec3 light3_specular;
 17: uniform vec3 light3_halfVector;
 18: uniform vec3 eyePosition;
 19: varying vec2 diffTexCoord;
 20: varying vec2 normTexCoord;
 21: varying vec2 specTexCoord;
 22: uniform float textureOffset;
 23: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 24: attribute vec3 tangent;
 25: varying vec3 lightDir_tan_0;
 26: varying vec3 lightDir_tan_1;
 27: varying vec3 lightDir_tan_2;
 28: varying vec3 lightDir_tan_3;
 29: varying vec3 eyeDir_tan;
 30:
 31: void main(void)
 32: {
 33: float NL;
 34: vec3 bitangent = cross(gl_Normal, tangent);
 35: eyeDir_tan.x = dot(tangent, eyeDir);
 36: eyeDir_tan.y = dot(-bitangent, eyeDir);
 37: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 38: NL = max(0.0, dot(gl_Normal, light0_direction));
 39: lightDir_tan_0.x = dot(tangent, light0_direction);
 40: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 41: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 42: NL = max(0.0, dot(gl_Normal, light1_direction));
 43: lightDir_tan_1.x = dot(tangent, light1_direction);
 44: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 45: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 46: NL = max(0.0, dot(gl_Normal, light2_direction));
 47: lightDir_tan_2.x = dot(tangent, light2_direction);
 48: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 49: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 50: NL = max(0.0, dot(gl_Normal, light3_direction));
 51: lightDir_tan_3.x = dot(tangent, light3_direction);
 52: lightDir_tan_3.y = dot(-bitangent, light3_direction);
 53: lightDir_tan_3.z = dot(gl_Normal, light3_direction);
 54: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 55: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 56: specTexCoord = gl_MultiTexCoord2.st;
 57: gl_Position = ftransform();
 58: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: uniform sampler2D specTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: uniform vec3 ambientColor;
 10: uniform float opacity;
 11: vec4 diff = vec4(ambientColor, opacity);
 12: varying vec3 eyeDir_tan;
 13: vec4 spec = vec4(0.0);
 14: uniform float shininess;
 15: varying vec3 lightDir_tan_0;
 16: uniform vec3 lightcolor0;
 17: uniform vec3 lightspecColor0;
 18: varying vec3 lightDir_tan_1;
 19: uniform vec3 lightcolor1;
 20: uniform vec3 lightspecColor1;
 21: varying vec3 lightDir_tan_2;
 22: uniform vec3 lightcolor2;
 23: uniform vec3 lightspecColor2;
 24: varying vec3 lightDir_tan_3;
 25: uniform vec3 lightcolor3;
 26: uniform vec3 lightspecColor3;
 27:
 28: void main(void)
 29: {
 30: vec4 color;
 31: vec3 n;
 32: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 33: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 34: float l;
 35: vec3 V = normalize(eyeDir_tan);
 36: vec3 H;
 37: float NH;
 38: float NL;
 39: NL = dot(lightDir_tan_0, n);
 40: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 41: diff.rgb += l * lightcolor0;
 42: H = normalize(eyeDir_tan + lightDir_tan_0);
 43: NH = max(0.0, dot(n, H));
 44: spec.rgb += l * pow(NH, shininess) * lightspecColor0;
 45: NL = dot(lightDir_tan_1, n);
 46: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 47: diff.rgb += l * lightcolor1;
 48: H = normalize(eyeDir_tan + lightDir_tan_1);
 49: NH = max(0.0, dot(n, H));
 50: spec.rgb += l * pow(NH, shininess) * lightspecColor1;
 51: NL = dot(lightDir_tan_2, n);
 52: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 53: diff.rgb += l * lightcolor2;
 54: H = normalize(eyeDir_tan + lightDir_tan_2);
 55: NH = max(0.0, dot(n, H));
 56: spec.rgb += l * pow(NH, shininess) * lightspecColor2;
 57: NL = dot(lightDir_tan_3, n);
 58: l = max(0.0, dot(lightDir_tan_3, n)) * clamp(lightDir_tan_3.z * 8.0, 0.0, 1.0);
 59: diff.rgb += l * lightcolor3;
 60: H = normalize(eyeDir_tan + lightDir_tan_3);
 61: NH = max(0.0, dot(n, H));
 62: spec.rgb += l * pow(NH, shininess) * lightspecColor3;
 63: color = texture2D(diffTex, diffTexCoord.st);
 64: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 65: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: varying vec2 normTexCoord;
 11: uniform float textureOffset;
 12: attribute vec3 tangent;
 13: varying vec3 lightDir_tan_0;
 14: varying vec3 lightDir_tan_1;
 15: varying vec3 lightDir_tan_2;
 16:
 17: void main(void)
 18: {
 19: float NL;
 20: vec3 bitangent = cross(gl_Normal, tangent);
 21: NL = max(0.0, dot(gl_Normal, light0_direction));
 22: lightDir_tan_0.x = dot(tangent, light0_direction);
 23: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 24: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 25: NL = max(0.0, dot(gl_Normal, light1_direction));
 26: lightDir_tan_1.x = dot(tangent, light1_direction);
 27: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 28: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 29: NL = max(0.0, dot(gl_Normal, light2_direction));
 30: lightDir_tan_2.x = dot(tangent, light2_direction);
 31: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 32: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 33: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 34: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 35: gl_Position = ftransform();
 36: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: vec4 diff = vec4(ambientColor, opacity);
 10: varying vec3 lightDir_tan_0;
 11: uniform vec3 lightcolor0;
 12: varying vec3 lightDir_tan_1;
 13: uniform vec3 lightcolor1;
 14: varying vec3 lightDir_tan_2;
 15: uniform vec3 lightcolor2;
 16:
 17: void main(void)
 18: {
 19: vec4 color;
 20: vec3 n;
 21: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 22: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 23: float l;
 24: float NL;
 25: NL = dot(lightDir_tan_0, n);
 26: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 27: diff.rgb += l * lightcolor0;
 28: NL = dot(lightDir_tan_1, n);
 29: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 30: diff.rgb += l * lightcolor1;
 31: NL = dot(lightDir_tan_2, n);
 32: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 33: diff.rgb += l * lightcolor2;
 34: color = texture2D(diffTex, diffTexCoord.st);
 35: gl_FragColor = color * diff;
 36: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: uniform float textureOffset;
 11: uniform vec3 ambientColor;
 12: uniform float opacity;
 13: varying vec4 diff;
 14:
 15: void main(void)
 16: {
 17: float NL;
 18: diff = vec4(ambientColor, opacity);
 19: NL = max(0.0, dot(gl_Normal, light0_direction));
 20: diff.rgb += light0_diffuse * NL;
 21: NL = max(0.0, dot(gl_Normal, light1_direction));
 22: diff.rgb += light1_diffuse * NL;
 23: NL = max(0.0, dot(gl_Normal, light2_direction));
 24: diff.rgb += light2_diffuse * NL;
 25: diffTexCoord = gl_MultiTexCoord0.st;
 26: diffTexCoord.x += textureOffset;
 27: gl_Position = ftransform();
 28: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6:
  7: void main(void)
  8: {
  9: vec4 color;
 10: color = texture2D(diffTex, diffTexCoord.st);
 11: gl_FragColor = color * diff;
 12: }

Vertex shader source:
  1: #version 120
  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 light2_direction;
 11: uniform vec3 light2_diffuse;
 12: uniform vec3 light2_specular;
 13: uniform vec3 light2_halfVector;
 14: uniform vec3 eyePosition;
 15: varying vec2 diffTexCoord;
 16: varying vec2 normTexCoord;
 17: varying vec2 specTexCoord;
 18: uniform float textureOffset;
 19: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 20: attribute vec3 tangent;
 21: varying vec3 lightDir_tan_0;
 22: varying vec3 lightDir_tan_1;
 23: varying vec3 lightDir_tan_2;
 24: varying vec3 eyeDir_tan;
 25:
 26: void main(void)
 27: {
 28: float NL;
 29: vec3 bitangent = cross(gl_Normal, tangent);
 30: eyeDir_tan.x = dot(tangent, eyeDir);
 31: eyeDir_tan.y = dot(-bitangent, eyeDir);
 32: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 33: NL = max(0.0, dot(gl_Normal, light0_direction));
 34: lightDir_tan_0.x = dot(tangent, light0_direction);
 35: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 36: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 37: NL = max(0.0, dot(gl_Normal, light1_direction));
 38: lightDir_tan_1.x = dot(tangent, light1_direction);
 39: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 40: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 41: NL = max(0.0, dot(gl_Normal, light2_direction));
 42: lightDir_tan_2.x = dot(tangent, light2_direction);
 43: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 44: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 45: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 46: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 47: specTexCoord = gl_MultiTexCoord2.st;
 48: gl_Position = ftransform();
 49: }

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

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

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

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  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: varying vec3 scatteredColor0;
 19: varying vec3 scatteredColor1;
 20: varying vec3 scatteredColor2;
 21: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 22: float NV = dot(gl_Normal, eyeDir);
 23: varying vec3 scatterEx;
 24: varying vec3 eyeDir_obj;
 25:
 26: void main(void)
 27: {
 28: float NL;
 29: {
 30:     float rq = dot(eyePosition, eyeDir);
 31:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 32:     float d = sqrt(rq * rq - qq);
 33:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 34:     vec3 atmLeave = gl_Vertex.xyz;
 35:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 36:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 37:     rq = dot(atmSamplePointSun, light0_direction);
 38:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 39:     d = sqrt(rq * rq - qq);
 40:     float distSun = -rq + d;
 41:     float distAtm = length(atmEnter - atmLeave);
 42:     float density = 0.0;
 43:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 44:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 45:     density += exp(-h * mieH);
 46:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 47:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 48:     density += exp(-h * mieH);
 49:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 50:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 51:     scatterEx = ex;
 52:     scatteredColor0 = sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 53: }
 54: eyeDir_obj = eyeDir;
 55: gl_Position = ftransform();
 56: }

Fragment shader source:
  1: #version 120
  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: uniform vec3 light2_direction;
 13: varying vec3 scatteredColor2;
 14:
 15: void main(void)
 16: {
 17: vec3 color = vec3(0.0, 0.0, 0.0);
 18: vec3 V = normalize(eyeDir_obj);
 19:     float cosTheta = dot(V, light0_direction);
 20:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 21:     float phRayleigh = 1.0;
 22:     color += (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * scatteredColor0;
 23:     gl_FragColor = vec4(color, dot(scatterEx, vec3(0.333, 0.333, 0.333)));
 24: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 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: float NV = dot(gl_Normal, eyeDir);
 22: uniform vec3 ambientColor;
 23: uniform float opacity;
 24: varying vec4 diff;
 25: varying vec3 scatterEx;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: diff = vec4(ambientColor, opacity);
 31: NL = max(0.0, dot(gl_Normal, light0_direction));
 32: diff.rgb += light0_diffuse * NL;
 33: NL = max(0.0, dot(gl_Normal, light1_direction));
 34: diff.rgb += light1_diffuse * NL;
 35: NL = max(0.0, dot(gl_Normal, light2_direction));
 36: diff.rgb += light2_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 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6: varying vec3 scatterEx;
  7:
  8: void main(void)
  9: {
 10: vec4 color;
 11: color = texture2D(diffTex, diffTexCoord.st);
 12: gl_FragColor = color * diff;
 13: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 14: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: uniform float textureOffset;
 11: uniform vec3 ambientColor;
 12: uniform float opacity;
 13: varying vec4 diff;
 14:
 15: void main(void)
 16: {
 17: float NL;
 18: diff = vec4(ambientColor, opacity);
 19: NL = max(0.0, dot(gl_Normal, light0_direction));
 20: diff.rgb += light0_diffuse * NL;
 21: NL = max(0.0, dot(gl_Normal, light1_direction));
 22: diff.rgb += light1_diffuse * NL;
 23: NL = max(0.0, dot(gl_Normal, light2_direction));
 24: diff.rgb += light2_diffuse * NL;
 25: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 26: gl_Position = ftransform();
 27: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6:
  7: void main(void)
  8: {
  9: vec4 color;
 10: color = texture2D(diffTex, diffTexCoord.st);
 11: gl_FragColor = color * diff;
 12: }

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

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

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: uniform float textureOffset;
 11: varying vec4 diffFactors;
 12: uniform float ringWidth;
 13: uniform float ringRadius;
 14: uniform vec4 ringPlane;
 15: uniform vec3 ringCenter;
 16: varying vec4 ringShadowTexCoord;
 17:
 18: void main(void)
 19: {
 20: float NL;
 21: NL = max(0.0, dot(gl_Normal, light0_direction));
 22: diffFactors.x = NL;
 23: NL = max(0.0, dot(gl_Normal, light1_direction));
 24: diffFactors.y = NL;
 25: NL = max(0.0, dot(gl_Normal, light2_direction));
 26: diffFactors.z = NL;
 27: diffTexCoord = gl_MultiTexCoord0.st;
 28: diffTexCoord.x += textureOffset;
 29: vec3 ringShadowProj;
 30: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light0_direction, ringPlane.xyz));
 31: ringShadowTexCoord.x = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 32: ringShadowProj = gl_Vertex.xyz + light1_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light1_direction, ringPlane.xyz));
 33: ringShadowTexCoord.y = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 34: ringShadowProj = gl_Vertex.xyz + light2_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light2_direction, ringPlane.xyz));
 35: ringShadowTexCoord.z = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 36: gl_Position = ftransform();
 37: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: uniform vec3 ambientColor;
  6: uniform float opacity;
  7: vec4 diff = vec4(ambientColor, opacity);
  8: varying vec4 diffFactors;
  9: uniform vec3 lightcolor0;
 10: uniform vec3 lightcolor1;
 11: uniform vec3 lightcolor2;
 12: varying vec3 position_obj;
 13: uniform sampler2D ringTex;
 14: varying vec4 ringShadowTexCoord;
 15: uniform float ringShadowLOD0;
 16: uniform float ringShadowLOD1;
 17: uniform float ringShadowLOD2;
 18:
 19: void main(void)
 20: {
 21: vec4 color;
 22: float shadow;
 23: shadow = diffFactors.x;
 24: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 25: diff.rgb += shadow * lightcolor0;
 26: shadow = diffFactors.y;
 27: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 28: diff.rgb += shadow * lightcolor1;
 29: shadow = diffFactors.z;
 30: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 31: diff.rgb += shadow * lightcolor2;
 32: color = texture2D(diffTex, diffTexCoord.st);
 33: gl_FragColor = color * diff;
 34: }

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

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: uniform sampler2D specTex;
  6: uniform sampler2D nightTex;
  7: varying vec2 diffTexCoord;
  8: varying vec2 normTexCoord;
  9: varying vec2 specTexCoord;
 10: varying vec2 nightTexCoord;
 11: uniform vec3 ambientColor;
 12: uniform float opacity;
 13: vec4 diff = vec4(ambientColor, opacity);
 14: varying vec3 eyeDir_tan;
 15: vec4 spec = vec4(0.0);
 16: uniform float shininess;
 17: varying vec3 lightDir_tan_0;
 18: uniform vec3 lightcolor0;
 19: uniform vec3 lightspecColor0;
 20: uniform float lightbrightness0;
 21: varying vec3 lightDir_tan_1;
 22: uniform vec3 lightcolor1;
 23: uniform vec3 lightspecColor1;
 24: uniform float lightbrightness1;
 25: varying vec3 lightDir_tan_2;
 26: uniform vec3 lightcolor2;
 27: uniform vec3 lightspecColor2;
 28: uniform float lightbrightness2;
 29: varying vec3 scatterEx;
 30: varying vec3 position_obj;
 31: uniform sampler2D ringTex;
 32: varying vec4 ringShadowTexCoord;
 33: uniform float ringShadowLOD0;
 34: uniform float ringShadowLOD1;
 35: uniform float ringShadowLOD2;
 36:
 37: void main(void)
 38: {
 39: vec4 color;
 40: float shadow;
 41: vec3 n;
 42: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 43: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 44: float l;
 45: vec3 V = normalize(eyeDir_tan);
 46: vec3 H;
 47: float NH;
 48: float NL;
 49: NL = dot(lightDir_tan_0, n);
 50: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 51: float totalLight = l * lightbrightness0;
 52: shadow = 1.0;
 53: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 54: diff.rgb += l * shadow * lightcolor0;
 55: H = normalize(eyeDir_tan + lightDir_tan_0);
 56: NH = max(0.0, dot(n, H));
 57: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor0;
 58: NL = dot(lightDir_tan_1, n);
 59: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 60: totalLight += l * lightbrightness1;
 61: shadow = 1.0;
 62: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 63: diff.rgb += l * shadow * lightcolor1;
 64: H = normalize(eyeDir_tan + lightDir_tan_1);
 65: NH = max(0.0, dot(n, H));
 66: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor1;
 67: NL = dot(lightDir_tan_2, n);
 68: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 69: totalLight += l * lightbrightness2;
 70: shadow = 1.0;
 71: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 72: diff.rgb += l * shadow * lightcolor2;
 73: H = normalize(eyeDir_tan + lightDir_tan_2);
 74: NH = max(0.0, dot(n, H));
 75: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor2;
 76: color = texture2D(diffTex, diffTexCoord.st);
 77: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 78: totalLight = 1.0 - totalLight;
 79: totalLight = totalLight * totalLight * totalLight * totalLight;
 80: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 81: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 82: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: varying vec2 normTexCoord;
 11: uniform float textureOffset;
 12: attribute vec3 tangent;
 13: varying vec3 lightDir_tan_0;
 14: varying vec3 lightDir_tan_1;
 15: varying vec3 lightDir_tan_2;
 16: varying vec3 position_obj;
 17: uniform float ringWidth;
 18: uniform float ringRadius;
 19: uniform vec4 ringPlane;
 20: uniform vec3 ringCenter;
 21: varying vec4 ringShadowTexCoord;
 22: uniform float cloudShadowTexOffset;
 23: uniform float cloudHeight;
 24: varying vec2 cloudShadowTexCoord0;
 25: varying vec2 cloudShadowTexCoord1;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: vec3 bitangent = cross(gl_Normal, tangent);
 31: NL = max(0.0, dot(gl_Normal, light0_direction));
 32: lightDir_tan_0.x = dot(tangent, light0_direction);
 33: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 34: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 35: NL = max(0.0, dot(gl_Normal, light1_direction));
 36: lightDir_tan_1.x = dot(tangent, light1_direction);
 37: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 38: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 39: NL = max(0.0, dot(gl_Normal, light2_direction));
 40: lightDir_tan_2.x = dot(tangent, light2_direction);
 41: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 42: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 43: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 44: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 45: vec3 ringShadowProj;
 46: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light0_direction, ringPlane.xyz));
 47: ringShadowTexCoord.x = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 48: ringShadowProj = gl_Vertex.xyz + light1_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light1_direction, ringPlane.xyz));
 49: ringShadowTexCoord.y = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 50: ringShadowProj = gl_Vertex.xyz + light2_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light2_direction, ringPlane.xyz));
 51: ringShadowTexCoord.z = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 52: {
 53:     cloudShadowTexCoord0 = vec2(diffTexCoord.x + cloudShadowTexOffset, diffTexCoord.y);
 54: }
 55: {
 56:     cloudShadowTexCoord1 = vec2(diffTexCoord.x + cloudShadowTexOffset, diffTexCoord.y);
 57: }
 58: position_obj = gl_Vertex.xyz;
 59: gl_Position = ftransform();
 60: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: vec4 diff = vec4(ambientColor, opacity);
 10: varying vec3 lightDir_tan_0;
 11: uniform vec3 lightcolor0;
 12: varying vec3 lightDir_tan_1;
 13: uniform vec3 lightcolor1;
 14: varying vec3 lightDir_tan_2;
 15: uniform vec3 lightcolor2;
 16: varying vec3 position_obj;
 17: uniform vec4 shadowTexGenS0_0;
 18: uniform vec4 shadowTexGenT0_0;
 19: uniform float shadowFalloff0_0;
 20: uniform float shadowMaxDepth0_0;
 21: uniform vec4 shadowTexGenS1_0;
 22: uniform vec4 shadowTexGenT1_0;
 23: uniform float shadowFalloff1_0;
 24: uniform float shadowMaxDepth1_0;
 25: uniform vec4 shadowTexGenS2_0;
 26: uniform vec4 shadowTexGenT2_0;
 27: uniform float shadowFalloff2_0;
 28: uniform float shadowMaxDepth2_0;
 29: uniform sampler2D ringTex;
 30: varying vec4 ringShadowTexCoord;
 31: uniform float ringShadowLOD0;
 32: uniform float ringShadowLOD1;
 33: uniform float ringShadowLOD2;
 34: uniform sampler2D cloudShadowTex;
 35: varying vec2 cloudShadowTexCoord0;
 36: varying vec2 cloudShadowTexCoord1;
 37: varying vec2 cloudShadowTexCoord2;
 38:
 39: void main(void)
 40: {
 41: vec4 color;
 42: float shadow;
 43: vec2 shadowCenter;
 44: float shadowR;
 45: vec3 n;
 46: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 47: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 48: float l;
 49: float NL;
 50: NL = dot(lightDir_tan_0, n);
 51: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 52: shadow = 1.0;
 53: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 54: shadow *= 1.000000-texture2D(cloudShadowTex, cloudShadowTexCoord0).a*0.750000;
 55: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS0_0) - 0.5;
 56: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT0_0) - 0.5;
 57: shadowR = clamp((2.0 * sqrt(dot(shadowCenter, shadowCenter)) - 1.0) * shadowFalloff0_0, 0.0, shadowMaxDepth0_0);
 58: shadow *= 1.0 - shadowR;
 59: diff.rgb += l * shadow * lightcolor0;
 60: NL = dot(lightDir_tan_1, n);
 61: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 62: shadow = 1.0;
 63: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 64: shadow *= 1.000000-texture2D(cloudShadowTex, cloudShadowTexCoord1).a*0.750000;
 65: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS1_0) - 0.5;
 66: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT1_0) - 0.5;
 67: shadowR = clamp((2.0 * sqrt(dot(shadowCenter, shadowCenter)) - 1.0) * shadowFalloff1_0, 0.0, shadowMaxDepth1_0);
 68: shadow *= 1.0 - shadowR;
 69: diff.rgb += l * shadow * lightcolor1;
 70: NL = dot(lightDir_tan_2, n);
 71: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 72: shadow = 1.0;
 73: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 74: shadowCenter.s = dot(vec4(position_obj, 1.0), shadowTexGenS2_0) - 0.5;
 75: shadowCenter.t = dot(vec4(position_obj, 1.0), shadowTexGenT2_0) - 0.5;
 76: shadowR = clamp((2.0 * sqrt(dot(shadowCenter, shadowCenter)) - 1.0) * shadowFalloff2_0, 0.0, shadowMaxDepth2_0);
 77: shadow *= 1.0 - shadowR;
 78: diff.rgb += l * shadow * lightcolor2;
 79: color = texture2D(diffTex, diffTexCoord.st);
 80: gl_FragColor = color * diff;
 81: }

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #110by onetwothree » 16.01.2019, 18:06

That's weird. Basically our and Alexell's version in OpenGL2.0 mode both use the same renderer, the only difference is in star drawing.

Could you confirm that the log file was taken when you was seeing "the red Earth"?

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #111by john71 » 16.01.2019, 18:14

No, it was after the "white reflection planet".

Added after 6 minutes 7 seconds:
Well, it can be a star reflection bug in my opinion... :think:

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #112by onetwothree » 16.01.2019, 19:03

Could you provide the log of the red Earth?

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #113by john71 » 16.01.2019, 19:16

Code: Select all

Vertex shader source:
  1: #version 120
  2: // static shader
  3: uniform sampler2D normTex;
  4: uniform float pointScale;
  5: attribute float pointSize;
  6: varying vec4 color;
  7:
  8: void main(void)
  9: {
 10:     gl_PointSize = pointSize;
 11:     color = gl_Color;
 12:     gl_Position = ftransform();
 13: }

Fragment shader source:
  1: #version 120
  2: uniform sampler2D normTex;
  3: varying vec4 color;
  4:
  5: void main(void)
  6: {
  7:     gl_FragColor = texture2D(normTex, gl_PointCoord) * color;
  8: }

Vertex shader source:
  1: #version 120
  2: uniform float opacity;
  3: uniform vec3 light0_diffuse;
  4:
  5: void main(void)
  6: {
  7:     gl_FrontColor = vec4(light0_diffuse, opacity);
  8:     gl_Position = ftransform();
  9: }

Fragment shader source:
  1: #version 120
  2:
  3: void main(void)
  4: {
  5:     gl_FragColor = gl_Color ;
  6: }

Vertex shader source:
  1: #version 120
  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 light2_direction;
 11: uniform vec3 light2_diffuse;
 12: uniform vec3 light2_specular;
 13: uniform vec3 light2_halfVector;
 14: uniform vec3 light3_direction;
 15: uniform vec3 light3_diffuse;
 16: uniform vec3 light3_specular;
 17: uniform vec3 light3_halfVector;
 18: uniform vec3 eyePosition;
 19: varying vec2 diffTexCoord;
 20: varying vec2 normTexCoord;
 21: varying vec2 specTexCoord;
 22: uniform float textureOffset;
 23: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 24: attribute vec3 tangent;
 25: varying vec3 lightDir_tan_0;
 26: varying vec3 lightDir_tan_1;
 27: varying vec3 lightDir_tan_2;
 28: varying vec3 lightDir_tan_3;
 29: varying vec3 eyeDir_tan;
 30:
 31: void main(void)
 32: {
 33: float NL;
 34: vec3 bitangent = cross(gl_Normal, tangent);
 35: eyeDir_tan.x = dot(tangent, eyeDir);
 36: eyeDir_tan.y = dot(-bitangent, eyeDir);
 37: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 38: NL = max(0.0, dot(gl_Normal, light0_direction));
 39: lightDir_tan_0.x = dot(tangent, light0_direction);
 40: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 41: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 42: NL = max(0.0, dot(gl_Normal, light1_direction));
 43: lightDir_tan_1.x = dot(tangent, light1_direction);
 44: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 45: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 46: NL = max(0.0, dot(gl_Normal, light2_direction));
 47: lightDir_tan_2.x = dot(tangent, light2_direction);
 48: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 49: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 50: NL = max(0.0, dot(gl_Normal, light3_direction));
 51: lightDir_tan_3.x = dot(tangent, light3_direction);
 52: lightDir_tan_3.y = dot(-bitangent, light3_direction);
 53: lightDir_tan_3.z = dot(gl_Normal, light3_direction);
 54: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 55: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 56: specTexCoord = gl_MultiTexCoord2.st;
 57: gl_Position = ftransform();
 58: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: uniform sampler2D specTex;
  6: varying vec2 diffTexCoord;
  7: varying vec2 normTexCoord;
  8: varying vec2 specTexCoord;
  9: uniform vec3 ambientColor;
 10: uniform float opacity;
 11: vec4 diff = vec4(ambientColor, opacity);
 12: varying vec3 eyeDir_tan;
 13: vec4 spec = vec4(0.0);
 14: uniform float shininess;
 15: varying vec3 lightDir_tan_0;
 16: uniform vec3 lightcolor0;
 17: uniform vec3 lightspecColor0;
 18: varying vec3 lightDir_tan_1;
 19: uniform vec3 lightcolor1;
 20: uniform vec3 lightspecColor1;
 21: varying vec3 lightDir_tan_2;
 22: uniform vec3 lightcolor2;
 23: uniform vec3 lightspecColor2;
 24: varying vec3 lightDir_tan_3;
 25: uniform vec3 lightcolor3;
 26: uniform vec3 lightspecColor3;
 27:
 28: void main(void)
 29: {
 30: vec4 color;
 31: vec3 n;
 32: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 33: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 34: float l;
 35: vec3 V = normalize(eyeDir_tan);
 36: vec3 H;
 37: float NH;
 38: float NL;
 39: NL = dot(lightDir_tan_0, n);
 40: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 41: diff.rgb += l * lightcolor0;
 42: H = normalize(eyeDir_tan + lightDir_tan_0);
 43: NH = max(0.0, dot(n, H));
 44: spec.rgb += l * pow(NH, shininess) * lightspecColor0;
 45: NL = dot(lightDir_tan_1, n);
 46: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 47: diff.rgb += l * lightcolor1;
 48: H = normalize(eyeDir_tan + lightDir_tan_1);
 49: NH = max(0.0, dot(n, H));
 50: spec.rgb += l * pow(NH, shininess) * lightspecColor1;
 51: NL = dot(lightDir_tan_2, n);
 52: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 53: diff.rgb += l * lightcolor2;
 54: H = normalize(eyeDir_tan + lightDir_tan_2);
 55: NH = max(0.0, dot(n, H));
 56: spec.rgb += l * pow(NH, shininess) * lightspecColor2;
 57: NL = dot(lightDir_tan_3, n);
 58: l = max(0.0, dot(lightDir_tan_3, n)) * clamp(lightDir_tan_3.z * 8.0, 0.0, 1.0);
 59: diff.rgb += l * lightcolor3;
 60: H = normalize(eyeDir_tan + lightDir_tan_3);
 61: NH = max(0.0, dot(n, H));
 62: spec.rgb += l * pow(NH, shininess) * lightspecColor3;
 63: color = texture2D(diffTex, diffTexCoord.st);
 64: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 65: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: varying vec2 normTexCoord;
 11: uniform float textureOffset;
 12: attribute vec3 tangent;
 13: varying vec3 lightDir_tan_0;
 14: varying vec3 lightDir_tan_1;
 15: varying vec3 lightDir_tan_2;
 16: uniform float ringWidth;
 17: uniform float ringRadius;
 18: uniform vec4 ringPlane;
 19: uniform vec3 ringCenter;
 20: varying vec4 ringShadowTexCoord;
 21:
 22: void main(void)
 23: {
 24: float NL;
 25: vec3 bitangent = cross(gl_Normal, tangent);
 26: NL = max(0.0, dot(gl_Normal, light0_direction));
 27: lightDir_tan_0.x = dot(tangent, light0_direction);
 28: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 29: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 30: NL = max(0.0, dot(gl_Normal, light1_direction));
 31: lightDir_tan_1.x = dot(tangent, light1_direction);
 32: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 33: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 34: NL = max(0.0, dot(gl_Normal, light2_direction));
 35: lightDir_tan_2.x = dot(tangent, light2_direction);
 36: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 37: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 38: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 39: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 40: vec3 ringShadowProj;
 41: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light0_direction, ringPlane.xyz));
 42: ringShadowTexCoord.x = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 43: ringShadowProj = gl_Vertex.xyz + light1_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light1_direction, ringPlane.xyz));
 44: ringShadowTexCoord.y = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 45: ringShadowProj = gl_Vertex.xyz + light2_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light2_direction, ringPlane.xyz));
 46: ringShadowTexCoord.z = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 47: gl_Position = ftransform();
 48: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: vec4 diff = vec4(ambientColor, opacity);
 10: varying vec3 lightDir_tan_0;
 11: uniform vec3 lightcolor0;
 12: varying vec3 lightDir_tan_1;
 13: uniform vec3 lightcolor1;
 14: varying vec3 lightDir_tan_2;
 15: uniform vec3 lightcolor2;
 16: varying vec3 position_obj;
 17: uniform sampler2D ringTex;
 18: varying vec4 ringShadowTexCoord;
 19: uniform float ringShadowLOD0;
 20: uniform float ringShadowLOD1;
 21: uniform float ringShadowLOD2;
 22:
 23: void main(void)
 24: {
 25: vec4 color;
 26: float shadow;
 27: vec3 n;
 28: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 29: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 30: float l;
 31: float NL;
 32: NL = dot(lightDir_tan_0, n);
 33: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 34: shadow = 1.0;
 35: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 36: diff.rgb += l * shadow * lightcolor0;
 37: NL = dot(lightDir_tan_1, n);
 38: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 39: shadow = 1.0;
 40: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 41: diff.rgb += l * shadow * lightcolor1;
 42: NL = dot(lightDir_tan_2, n);
 43: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 44: shadow = 1.0;
 45: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 46: diff.rgb += l * shadow * lightcolor2;
 47: color = texture2D(diffTex, diffTexCoord.st);
 48: gl_FragColor = color * diff;
 49: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: uniform float textureOffset;
 11: varying vec4 diffFactors;
 12: uniform float ringWidth;
 13: uniform float ringRadius;
 14: uniform vec4 ringPlane;
 15: uniform vec3 ringCenter;
 16: varying vec4 ringShadowTexCoord;
 17:
 18: void main(void)
 19: {
 20: float NL;
 21: NL = max(0.0, dot(gl_Normal, light0_direction));
 22: diffFactors.x = NL;
 23: NL = max(0.0, dot(gl_Normal, light1_direction));
 24: diffFactors.y = NL;
 25: NL = max(0.0, dot(gl_Normal, light2_direction));
 26: diffFactors.z = NL;
 27: diffTexCoord = gl_MultiTexCoord0.st;
 28: diffTexCoord.x += textureOffset;
 29: vec3 ringShadowProj;
 30: ringShadowProj = gl_Vertex.xyz + light0_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light0_direction, ringPlane.xyz));
 31: ringShadowTexCoord.x = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 32: ringShadowProj = gl_Vertex.xyz + light1_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light1_direction, ringPlane.xyz));
 33: ringShadowTexCoord.y = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 34: ringShadowProj = gl_Vertex.xyz + light2_direction * max(0.0, -(dot(gl_Vertex.xyz, ringPlane.xyz) + ringPlane.w) / dot(light2_direction, ringPlane.xyz));
 35: ringShadowTexCoord.z = (length(ringShadowProj - ringCenter) - ringRadius) * ringWidth;
 36: gl_Position = ftransform();
 37: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: uniform vec3 ambientColor;
  6: uniform float opacity;
  7: vec4 diff = vec4(ambientColor, opacity);
  8: varying vec4 diffFactors;
  9: uniform vec3 lightcolor0;
 10: uniform vec3 lightcolor1;
 11: uniform vec3 lightcolor2;
 12: varying vec3 position_obj;
 13: uniform sampler2D ringTex;
 14: varying vec4 ringShadowTexCoord;
 15: uniform float ringShadowLOD0;
 16: uniform float ringShadowLOD1;
 17: uniform float ringShadowLOD2;
 18:
 19: void main(void)
 20: {
 21: vec4 color;
 22: float shadow;
 23: shadow = diffFactors.x;
 24: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 25: diff.rgb += shadow * lightcolor0;
 26: shadow = diffFactors.y;
 27: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 28: diff.rgb += shadow * lightcolor1;
 29: shadow = diffFactors.z;
 30: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 31: diff.rgb += shadow * lightcolor2;
 32: color = texture2D(diffTex, diffTexCoord.st);
 33: gl_FragColor = color * diff;
 34: }

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

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: uniform sampler2D specTex;
  6: uniform sampler2D nightTex;
  7: varying vec2 diffTexCoord;
  8: varying vec2 normTexCoord;
  9: varying vec2 specTexCoord;
 10: varying vec2 nightTexCoord;
 11: uniform vec3 ambientColor;
 12: uniform float opacity;
 13: vec4 diff = vec4(ambientColor, opacity);
 14: varying vec3 eyeDir_tan;
 15: vec4 spec = vec4(0.0);
 16: uniform float shininess;
 17: varying vec3 lightDir_tan_0;
 18: uniform vec3 lightcolor0;
 19: uniform vec3 lightspecColor0;
 20: uniform float lightbrightness0;
 21: varying vec3 lightDir_tan_1;
 22: uniform vec3 lightcolor1;
 23: uniform vec3 lightspecColor1;
 24: uniform float lightbrightness1;
 25: varying vec3 lightDir_tan_2;
 26: uniform vec3 lightcolor2;
 27: uniform vec3 lightspecColor2;
 28: uniform float lightbrightness2;
 29: varying vec3 scatterEx;
 30: varying vec3 position_obj;
 31: uniform sampler2D ringTex;
 32: varying vec4 ringShadowTexCoord;
 33: uniform float ringShadowLOD0;
 34: uniform float ringShadowLOD1;
 35: uniform float ringShadowLOD2;
 36:
 37: void main(void)
 38: {
 39: vec4 color;
 40: float shadow;
 41: vec3 n;
 42: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 43: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 44: float l;
 45: vec3 V = normalize(eyeDir_tan);
 46: vec3 H;
 47: float NH;
 48: float NL;
 49: NL = dot(lightDir_tan_0, n);
 50: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 51: float totalLight = l * lightbrightness0;
 52: shadow = 1.0;
 53: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.x, 0.000000), ringShadowLOD0).a;
 54: diff.rgb += l * shadow * lightcolor0;
 55: H = normalize(eyeDir_tan + lightDir_tan_0);
 56: NH = max(0.0, dot(n, H));
 57: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor0;
 58: NL = dot(lightDir_tan_1, n);
 59: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 60: totalLight += l * lightbrightness1;
 61: shadow = 1.0;
 62: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.y, 0.000000), ringShadowLOD1).a;
 63: diff.rgb += l * shadow * lightcolor1;
 64: H = normalize(eyeDir_tan + lightDir_tan_1);
 65: NH = max(0.0, dot(n, H));
 66: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor1;
 67: NL = dot(lightDir_tan_2, n);
 68: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 69: totalLight += l * lightbrightness2;
 70: shadow = 1.0;
 71: shadow *= 1.000000-texture2DLod(ringTex, vec2(ringShadowTexCoord.z, 0.000000), ringShadowLOD2).a;
 72: diff.rgb += l * shadow * lightcolor2;
 73: H = normalize(eyeDir_tan + lightDir_tan_2);
 74: NH = max(0.0, dot(n, H));
 75: spec.rgb += l * shadow * pow(NH, shininess) * lightspecColor2;
 76: color = texture2D(diffTex, diffTexCoord.st);
 77: gl_FragColor = color * diff + texture2D(specTex, specTexCoord.st) * spec;
 78: totalLight = 1.0 - totalLight;
 79: totalLight = totalLight * totalLight * totalLight * totalLight;
 80: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 81: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 82: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 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: float NV = dot(gl_Normal, eyeDir);
 22: uniform vec3 ambientColor;
 23: uniform float opacity;
 24: varying vec4 diff;
 25: varying vec3 scatterEx;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: diff = vec4(ambientColor, opacity);
 31: NL = max(0.0, dot(gl_Normal, light0_direction));
 32: diff.rgb += light0_diffuse * NL;
 33: NL = max(0.0, dot(gl_Normal, light1_direction));
 34: diff.rgb += light1_diffuse * NL;
 35: NL = max(0.0, dot(gl_Normal, light2_direction));
 36: diff.rgb += light2_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 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6: varying vec3 scatterEx;
  7:
  8: void main(void)
  9: {
 10: vec4 color;
 11: color = texture2D(diffTex, diffTexCoord.st);
 12: gl_FragColor = color * diff;
 13: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 14: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: varying vec2 normTexCoord;
 11: uniform float textureOffset;
 12: attribute vec3 tangent;
 13: varying vec3 lightDir_tan_0;
 14: varying vec3 lightDir_tan_1;
 15: varying vec3 lightDir_tan_2;
 16:
 17: void main(void)
 18: {
 19: float NL;
 20: vec3 bitangent = cross(gl_Normal, tangent);
 21: NL = max(0.0, dot(gl_Normal, light0_direction));
 22: lightDir_tan_0.x = dot(tangent, light0_direction);
 23: lightDir_tan_0.y = dot(-bitangent, light0_direction);
 24: lightDir_tan_0.z = dot(gl_Normal, light0_direction);
 25: NL = max(0.0, dot(gl_Normal, light1_direction));
 26: lightDir_tan_1.x = dot(tangent, light1_direction);
 27: lightDir_tan_1.y = dot(-bitangent, light1_direction);
 28: lightDir_tan_1.z = dot(gl_Normal, light1_direction);
 29: NL = max(0.0, dot(gl_Normal, light2_direction));
 30: lightDir_tan_2.x = dot(tangent, light2_direction);
 31: lightDir_tan_2.y = dot(-bitangent, light2_direction);
 32: lightDir_tan_2.z = dot(gl_Normal, light2_direction);
 33: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 34: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 35: gl_Position = ftransform();
 36: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: vec4 diff = vec4(ambientColor, opacity);
 10: varying vec3 lightDir_tan_0;
 11: uniform vec3 lightcolor0;
 12: varying vec3 lightDir_tan_1;
 13: uniform vec3 lightcolor1;
 14: varying vec3 lightDir_tan_2;
 15: uniform vec3 lightcolor2;
 16:
 17: void main(void)
 18: {
 19: vec4 color;
 20: vec3 n;
 21: n.xy = texture2D(normTex, normTexCoord.st).ag * 2.0 - vec2(1.0, 1.0);
 22: n.z = sqrt(1.0 - n.x * n.x - n.y * n.y);
 23: float l;
 24: float NL;
 25: NL = dot(lightDir_tan_0, n);
 26: l = max(0.0, dot(lightDir_tan_0, n)) * clamp(lightDir_tan_0.z * 8.0, 0.0, 1.0);
 27: diff.rgb += l * lightcolor0;
 28: NL = dot(lightDir_tan_1, n);
 29: l = max(0.0, dot(lightDir_tan_1, n)) * clamp(lightDir_tan_1.z * 8.0, 0.0, 1.0);
 30: diff.rgb += l * lightcolor1;
 31: NL = dot(lightDir_tan_2, n);
 32: l = max(0.0, dot(lightDir_tan_2, n)) * clamp(lightDir_tan_2.z * 8.0, 0.0, 1.0);
 33: diff.rgb += l * lightcolor2;
 34: color = texture2D(diffTex, diffTexCoord.st);
 35: gl_FragColor = color * diff;
 36: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 light0_direction;
  3: uniform vec3 light0_diffuse;
  4: uniform vec3 light1_direction;
  5: uniform vec3 light1_diffuse;
  6: uniform vec3 light2_direction;
  7: uniform vec3 light2_diffuse;
  8: uniform vec3 eyePosition;
  9: varying vec2 diffTexCoord;
 10: uniform float textureOffset;
 11: uniform vec3 ambientColor;
 12: uniform float opacity;
 13: varying vec4 diff;
 14:
 15: void main(void)
 16: {
 17: float NL;
 18: diff = vec4(ambientColor, opacity);
 19: NL = max(0.0, dot(gl_Normal, light0_direction));
 20: diff.rgb += light0_diffuse * NL;
 21: NL = max(0.0, dot(gl_Normal, light1_direction));
 22: diff.rgb += light1_diffuse * NL;
 23: NL = max(0.0, dot(gl_Normal, light2_direction));
 24: diff.rgb += light2_diffuse * NL;
 25: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 26: gl_Position = ftransform();
 27: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6:
  7: void main(void)
  8: {
  9: vec4 color;
 10: color = texture2D(diffTex, diffTexCoord.st);
 11: gl_FragColor = color * diff;
 12: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 eyePosition;
  3: varying vec2 diffTexCoord;
  4: varying vec2 nightTexCoord;
  5: uniform float textureOffset;
  6: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
  7: float NV = dot(gl_Normal, eyeDir);
  8: varying vec4 diffFactors;
  9: varying vec3 normal;
 10:
 11: void main(void)
 12: {
 13: float NL;
 14: normal = gl_Normal;
 15: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 16: nightTexCoord = gl_MultiTexCoord1.st;
 17: gl_Position = ftransform();
 18: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D nightTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 nightTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: varying vec4 diffFactors;
 10: vec4 diff = vec4(ambientColor, opacity);
 11: varying vec3 normal;
 12: vec4 spec = vec4(0.0);
 13: uniform float shininess;
 14:
 15: void main(void)
 16: {
 17: vec4 color;
 18: float NH;
 19: vec3 n = normalize(normal);
 20: color = texture2D(diffTex, diffTexCoord.st);
 21: gl_FragColor = color * diff + float(color.a) * spec;
 22: float totalLight = 0.0f
 23: totalLight = 1.0 - totalLight;
 24: totalLight = totalLight * totalLight * totalLight * totalLight;
 25: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 26: }

Error compiling fragment shader:
0(23) : error C0000: syntax error, unexpected identifier, expecting ',' or ';' at token "totalLight"
Vertex shader source:
  1: #version 120
  2: uniform vec3 eyePosition;
  3: varying vec2 diffTexCoord;
  4: uniform float textureOffset;
  5: uniform vec3 ambientColor;
  6: uniform float opacity;
  7: varying vec4 diff;
  8:
  9: void main(void)
 10: {
 11: float NL;
 12: diff = vec4(ambientColor, opacity);
 13: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 14: gl_Position = ftransform();
 15: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: varying vec2 diffTexCoord;
  5: varying vec4 diff;
  6:
  7: void main(void)
  8: {
  9: vec4 color;
 10: color = texture2D(diffTex, diffTexCoord.st);
 11: gl_FragColor = color * diff;
 12: }

Vertex shader source:
  1: #version 120
  2: uniform vec3 eyePosition;
  3: varying vec2 diffTexCoord;
  4: varying vec2 normTexCoord;
  5: uniform float textureOffset;
  6: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
  7: attribute vec3 tangent;
  8: varying vec3 eyeDir_tan;
  9:
 10: void main(void)
 11: {
 12: float NL;
 13: vec3 bitangent = cross(gl_Normal, tangent);
 14: eyeDir_tan.x = dot(tangent, eyeDir);
 15: eyeDir_tan.y = dot(-bitangent, eyeDir);
 16: eyeDir_tan.z = dot(gl_Normal, eyeDir);
 17: diffTexCoord = gl_MultiTexCoord0.st + vec2(textureOffset, 0.0);
 18: normTexCoord = gl_MultiTexCoord1.st + vec2(textureOffset, 0.0);
 19: gl_Position = ftransform();
 20: }

Fragment shader source:
  1: #version 120
  2: #extension GL_ARB_shader_texture_lod : enable
  3: uniform sampler2D diffTex;
  4: uniform sampler2D normTex;
  5: varying vec2 diffTexCoord;
  6: varying vec2 normTexCoord;
  7: uniform vec3 ambientColor;
  8: uniform float opacity;
  9: vec4 diff = vec4(ambientColor, opacity);
 10: varying vec3 eyeDir_tan;
 11: vec4 spec = vec4(0.0);
 12: uniform float shininess;
 13: uniform float lunarLambert;
 14:
 15: void main(void)
 16: {
 17: vec4 color;
 18: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
 19: float l;
 20: vec3 V = normalize(eyeDir_tan);
 21: float NV = dot(n, V);
 22: float NL;
 23: color = texture2D(diffTex, diffTexCoord.st);
 24: gl_FragColor = color * diff;
 25: }

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #114by onetwothree » 16.01.2019, 20:38

Thank you. I have found the error that causes the red Earth.

But the question is why do you have no light sources?

Another question - does your Alexell's copy reports it's git commit (Help->About)?

john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 1 month

Post #115by john71 » 17.01.2019, 07:14

https://celestia.alexell.ru//1.7.0/x64/

It is the last 2018 06 06 version, I did not find a git commit number...

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #116by cartrite » 18.01.2019, 22:50

I've tried to build the current master on vs 2015 and no go. First, I got 2 build errors. In samporbit.cpp, around line 830, a typo. Win32 needed to be _Win32. In winsplash.cpp, ULW_ALPHA needed to be defined.
Then after all files built, I get about 22 link errors. Not sure why but suspect Lau.
The project files needed updates, so I'm not sure if I did it right. Curveplot had to be moved from thirdparty. Fmod lib needed removing from lib list. Fmt had to be added, etc. Any ideas for the link errors. They are 2001, unresolved external symbol. They were in a number of files, they are celestiacore, celx, celx_celestia, celx_object, stardb, solarsys, dsodb, globular, and body.obj.
cartrite

Added after 24 minutes 46 seconds:
Seen there was an update in github. Not sure if it would help with link errors but at least the samporbit.cpp build issue was addressed. That should work?
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #117by onetwothree » 19.01.2019, 08:28

Hi cartrite,

We don't use that provided VS project file any more (and will remove it, because 3 build systems beat everything), we use CMake + vcpkg instead, please see .appveyor.yml.

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #118by cartrite » 19.01.2019, 16:46

Ok. Was able to build and run the win32 version. But no menus. Was able to navigate with the keyboard but no menu toolbar. Built with cmake + vcpkg with qt5 = off.
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4

Topic author
onetwothree
Site Admin
Posts: 705
Joined: 22.09.2018
With us: 5 years 11 months

Post #119by onetwothree » 19.01.2019, 16:59

It seems that I forgot push some recent changes :)

Avatar
cartrite
Posts: 1978
Joined: 15.09.2005
With us: 19 years
Location: Pocono Mountains, Pennsylvania, USA Greate Grandfother from Irshava, Zakarpattia Oblast Ukraine

Post #120by cartrite » 20.01.2019, 14:12

Baby steps. :smile:
Adding the menus was relatively easy with Visual Studio. But I couldn't add the menus with cmake via CmakeLists.txt. It will be interesting to see how you are going to do it. I got a new appreciation for what Janus did to the view option dialog box. I tried to repair it and all attempts failed. :sad: With the gui. In the past I would edit celestia.rc with a text editor. One thing I did notice was adding celestia.rc caused a link error for a duplicate resource. The celestia.manifest entry had to be removed from celestia.rc to get it to work.
cartrite
VivoBook_ASUSLaptop X712JA_S712JA Intel(R) UHD Graphics 8gb ram. Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz, 1190 Mhz, 4 Core(s), 8 Logical Processor(s) 8 GB ram. Running on Windows 11 and OpenSuse 15.4


Return to “Development”