Now Saturn's rings show almost correctly except for the double shadow on the rings. Nothing else has changed
Here's the error log:
Code: Select all
Vertex shader source:
1: uniform struct {
2: vec3 direction;
3: vec3 diffuse;
4: vec3 specular;
5: vec3 halfVector;
6: } lights[1];
7: varying vec4 diffFactors;
8: varying vec2 diffTexCoord;
9: uniform float ringWidth;
10: uniform float ringRadius;
11: varying float ringShadowTexCoord0;
12:
13: void main(void)
14: {
15: float nDotVP;
16: nDotVP = max(0.0, dot(gl_Normal, lights[0].direction));
17: diffFactors.x = nDotVP;
18: diffTexCoord = gl_MultiTexCoord0.st;
19: vec3 ringShadowProj;
20: ringShadowProj = gl_Vertex.xyz + lights[0].direction * max(0, gl_Vertex.y / -lights[0].direction.y);
21: ringShadowTexCoord0 = length(ringShadowProj) * ringWidth - ringRadius;
22: gl_Position = ftransform();
23: }
Error compiling vertex shader:
ERROR: 0:20: 'max' : no matching overloaded function found
ERROR: 1 compilation errors. No code generated.
Fragment shader source:
1: uniform vec3 ambientColor;
2: vec4 diff = vec4(ambientColor, 1);
3: uniform vec3 lightcolor0;
4: varying vec4 diffFactors;
5: varying vec2 diffTexCoord;
6: uniform sampler2D diffTex;
7: uniform sampler2D ringTex;
8: varying float ringShadowTexCoord0;
9:
10: void main(void)
11: {
12: vec4 color;
13: float shadow;
14: shadow = diffFactors.x;
15: shadow *= (1.0 - texture2D(ringTex, vec2(ringShadowTexCoord0, 0.0)).a);
16: diff += shadow * vec4(lightcolor0, 0.0);
17: color = texture2D(diffTex, diffTexCoord.st);
18: gl_FragColor = color * diff;
19: }
Vertex shader source:
1: uniform struct {
2: vec3 direction;
3: vec3 diffuse;
4: vec3 specular;
5: vec3 halfVector;
6: } lights[1];
7: uniform vec3 eyePosition;
8: varying vec4 diffFactors;
9: varying vec2 diffTexCoord;
10: uniform vec4 shadowTexGenS0_0;
11: uniform vec4 shadowTexGenT0_0;
12: varying vec3 shadowTexCoord0_0;
13:
14: void main(void)
15: {
16: float nDotVP;
17: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
18: diffFactors.x = (dot(lights[0].direction, eyeDir) + 1.0) * 0.5;
19: diffTexCoord = gl_MultiTexCoord0.st;
20: shadowTexCoord0_0.x = dot(gl_Vertex, shadowTexGenS0_0);
21: shadowTexCoord0_0.y = dot(gl_Vertex, shadowTexGenT0_0);
22: shadowTexCoord0_0.z = dot(gl_Vertex.xyz, lights[0].direction);
23: gl_Position = ftransform();
24: }
Fragment shader source:
1: uniform vec3 ambientColor;
2: vec4 diff = vec4(ambientColor, 1);
3: uniform vec3 lightcolor0;
4: varying vec4 diffFactors;
5: varying vec2 diffTexCoord;
6: uniform sampler2D diffTex;
7: varying vec3 shadowTexCoord0_0;
8: uniform float shadowScale0_0;
9: uniform float shadowBias0_0;
10:
11: void main(void)
12: {
13: vec4 color;
14: float shadow;
15: vec2 shadowCenter;
16: float shadowR;
17: shadow = 1.0;
18: shadowCenter = shadowTexCoord0_0.st - vec2(0.5, 0.5);
19: shadowR = clamp(dot(shadowCenter, shadowCenter) * shadowScale0_0 + shadowBias0_0, 0.0, 1.0);
20: shadow *= sqrt(shadowR);
21: shadow = min(1.0, shadow + step(0.0, shadowTexCoord0_0.z));
22: diff += (shadow * diffFactors.x) * vec4(lightcolor0, 0.0);
23: color = texture2D(diffTex, diffTexCoord.st);
24: gl_FragColor = color * diff;
25: }
Vertex shader source:
1: uniform struct {
2: vec3 direction;
3: vec3 diffuse;
4: vec3 specular;
5: vec3 halfVector;
6: } lights[1];
7: uniform vec3 ambientColor;
8: varying vec4 diff;
9: varying vec2 diffTexCoord;
10:
11: void main(void)
12: {
13: float nDotVP;
14: diff = vec4(ambientColor, 1);
15: nDotVP = max(0.0, dot(gl_Normal, lights[0].direction));
16: diff += vec4(lights[0].diffuse * nDotVP, 1.0);
17: diffTexCoord = gl_MultiTexCoord0.st;
18: gl_Position = ftransform();
19: }
Fragment shader source:
1: varying vec4 diff;
2: varying vec2 diffTexCoord;
3: uniform sampler2D diffTex;
4:
5: void main(void)
6: {
7: vec4 color;
8: color = texture2D(diffTex, diffTexCoord.st);
9: gl_FragColor = color * diff;
10: }
Vertex shader source:
1: uniform struct {
2: vec3 direction;
3: vec3 diffuse;
4: vec3 specular;
5: vec3 halfVector;
6: } lights[1];
7: uniform float shininess;
8: uniform vec3 ambientColor;
9: varying vec4 diff;
10: varying vec4 spec;
11: varying vec2 diffTexCoord;
12:
13: void main(void)
14: {
15: float nDotVP;
16: float nDotHV;
17: diff = vec4(ambientColor, 1);
18: nDotVP = max(0.0, dot(gl_Normal, lights[0].direction));
19: nDotHV = max(0.0, dot(gl_Normal, lights[0].halfVector));
20: diff += vec4(lights[0].diffuse * nDotVP, 1.0);
21: spec += vec4(lights[0].specular * (pow(nDotHV, shininess) * nDotVP), 0.0);
22: diffTexCoord = gl_MultiTexCoord0.st;
23: gl_Position = ftransform();
24: }
Fragment shader source:
1: varying vec4 diff;
2: varying vec4 spec;
3: varying vec2 diffTexCoord;
4: uniform sampler2D diffTex;
5:
6: void main(void)
7: {
8: vec4 color;
9: color = texture2D(diffTex, diffTexCoord.st);
10: gl_FragColor = color * diff + color.a * spec;
11: }
Vertex shader source:
1: uniform struct {
2: vec3 direction;
3: vec3 diffuse;
4: vec3 specular;
5: vec3 halfVector;
6: } lights[1];
7: varying vec2 diffTexCoord;
8: varying vec2 normTexCoord;
9: varying vec3 lightDir0;
10: attribute vec3 tangent;
11:
12: void main(void)
13: {
14: float nDotVP;
15: nDotVP = max(0.0, dot(gl_Normal, lights[0].direction));
16: vec3 bitangent = cross(gl_Normal, tangent);
17: lightDir0.x = dot(tangent, lights[0].direction);
18: lightDir0.y = dot(-bitangent, lights[0].direction);
19: lightDir0.z = dot(gl_Normal, lights[0].direction);
20: diffTexCoord = gl_MultiTexCoord0.st;
21: normTexCoord = gl_MultiTexCoord1.st;
22: gl_Position = ftransform();
23: }
Fragment shader source:
1: uniform vec3 ambientColor;
2: vec4 diff = vec4(ambientColor, 1);
3: uniform vec3 lightcolor0;
4: varying vec2 diffTexCoord;
5: uniform sampler2D diffTex;
6: varying vec2 normTexCoord;
7: varying vec3 lightDir0;
8: uniform sampler2D normTex;
9:
10: void main(void)
11: {
12: vec4 color;
13: vec3 n = texture2D(normTex, normTexCoord.st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
14: float l;
15: l = max(0.0, dot(lightDir0, n)) * clamp(lightDir0.z * 8.0, 0.0, 1.0);
16: diff += vec4(l * lightcolor0, 0.0);
17: color = texture2D(diffTex, diffTexCoord.st);
18: gl_FragColor = color * diff;
19: }