1
0
Fork 0

Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related)

AMD/ATI compiler requires proper float values for conditions/expressions.
This commit is contained in:
ThorstenB 2011-07-04 20:20:26 +02:00
parent 0ece95127c
commit 09062b72a9
14 changed files with 37 additions and 37 deletions

View file

@ -23,7 +23,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -61,7 +61,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(15000.0, 20000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(15000.0, 20000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -28,7 +28,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -63,7 +63,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(25000.0, 30000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(25000.0, 30000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -17,7 +17,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -54,7 +54,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(100.0, 300.0, fogCoord), 1 - smoothstep(40000.0, 45000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(100.0, 300.0, fogCoord), 1.0 - smoothstep(40000.0, 45000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -28,7 +28,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -63,7 +63,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(25000.0, 30000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(25000.0, 30000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -18,7 +18,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -54,7 +54,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(40000.0, 45000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(40000.0, 45000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -28,7 +28,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -63,7 +63,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(40000.0, 45000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(40000.0, 45000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -17,7 +17,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -54,7 +54,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(100.0, 300.0, fogCoord), 1 - smoothstep(40000.0, 45000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(100.0, 300.0, fogCoord), 1.0 - smoothstep(40000.0, 45000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -26,8 +26,8 @@ void main(void)
// map noise vectors
vec4 noisevec = texture3D(Noise, rawpos.xyz);
float noise0 = (noisevec.r * 2) - 1;
float noise1 =(noisevec.g * 2) - 1;
float noise0 = (noisevec.r * 2.0) - 1.0;
float noise1 =(noisevec.g * 2.0) - 1.0;
vec2 noise2 = noisevec.xy;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
@ -39,7 +39,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Scale
@ -50,11 +50,11 @@ void main(void)
gl_Position.xyz += gl_Vertex.z * w * scale_z;
// Adjust the position post-rotation and scaling
gl_Position.yz -= 3/2;
gl_Position.yz -= 3.0/2.0;
// Offset in y and z directions using a random noise factor
float offset_Y = (noise0 * offset_y) + offset_y/2;
float offset_Z = (noise0 * offset_z) + offset_z/2;
float offset_Y = (noise0 * offset_y) + offset_y/2.0;
float offset_Z = (noise0 * offset_z) + offset_z/2.0;
distanceFactor = 1.0 - clamp(abs(noise0), fade_min, fade_max);
// distanceFactor = 0.5;
@ -90,7 +90,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(60000.0, 80000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(60000.0, 80000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -137,39 +137,39 @@ void main (void)
c5a = mix(c3, c4a, 1.0);
if (vegetationlevel <= 2200) {
if (vegetationlevel <= 2200.0) {
c1 = mix(c2, c5, clamp(0.65, n*0.1, 0.5));
diffuse = gl_Color.rgb * max(0.7, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
if (vegetationlevel > 2200 && vegetationlevel < 2300) {
if (vegetationlevel > 2200.0 && vegetationlevel < 2300.0) {
c1 = mix(c2, c5, clamp(0.65, n*0.5, 0.35));
diffuse = gl_Color.rgb * max(0.7, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
if (vegetationlevel >= 2300 && vegetationlevel < 2480) {
if (vegetationlevel >= 2300.0 && vegetationlevel < 2480.0) {
c1 = mix(c2, c5a, clamp(0.65, n*0.5, 0.30));
diffuse = gl_Color.rgb * max(0.85, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
if (vegetationlevel >= 2480 && vegetationlevel < 2530) {
if (vegetationlevel >= 2480.0 && vegetationlevel < 2530.0) {
c1 = mix(c2, c5a, clamp(0.65, n*0.5, 0.20));
diffuse = gl_Color.rgb * max(0.85, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
if (vegetationlevel >= 2530 && vegetationlevel < 2670) {
if (vegetationlevel >= 2530.0 && vegetationlevel < 2670.0) {
c1 = mix(c2, c5, clamp(0.65, n*0.5, 0.10));
diffuse = gl_Color.rgb * max(0.85, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
if (vegetationlevel >= 2670) {
if (vegetationlevel >= 2670.0) {
c1 = mix(c2, c5, clamp(0.0, n*0.1, 0.4));
diffuse = gl_Color.rgb * max(0.85, dot(N, l)) * max(0.9, dot(VNormal, gl_LightSource[0].position.xyz));
}
//adding snow and permanent snow/glacier
if (vegetationlevel > snowlevel || vegetationlevel > 3100) {
if (vegetationlevel > snowlevel || vegetationlevel > 3100.0) {
c3 = mix(vec4(n+1.0, n+1.0, n+1.0, 0.0), c1, smoothstep(0.990, 0.965, abs(normalize(Normal).z)+nvL[2]*1.3));
c4 = mix(vec4(n+1.0, n+1.0, n+1.0, 0.0), c1, smoothstep(0.990, 0.965, abs(normalize(Normal).z)+nvL[2]*0.9));
c5 = mix(c3, c4, 1.0);

View file

@ -45,7 +45,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(100.0, 250.0, fogCoord), 1 - smoothstep(40000.0, 45000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(100.0, 250.0, fogCoord), 1.0 - smoothstep(40000.0, 45000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect rain as much as other objects.

View file

@ -88,14 +88,14 @@ void main (void)
float transparency_offset = clamp(refl_correction, -1.0, 1.0);
float reflFactor = 0.0;
if(reflect_map > 0){
if(reflect_map > 0.0){
// map the shininess of the object with user input
vec4 map = texture2D(Map, gl_TexCoord[0].st);
//float pam = (map.a * -2) + 1; //reverse map
reflFactor = map.a + transparency_offset;
} else {
// set the reflectivity proportional to shininess with user input
reflFactor = (gl_FrontMaterial.shininess / 128) * ns.a + transparency_offset;
reflFactor = (gl_FrontMaterial.shininess / 128.0) * ns.a + transparency_offset;
}
reflFactor = clamp(reflFactor, 0.0, 1.0);

View file

@ -81,7 +81,7 @@ void main (void)
float transparency_offset = clamp(refl_correction, -1.0, 1.0);
float reflFactor = 0.0;
if(reflect_map > 0){
if(reflect_map > 0.0){
// map the shininess of the object with user input
vec4 map = texture2D(Map, gl_TexCoord[0].st);
//float pam = (map.a * -2) + 1; //reverse map
@ -89,7 +89,7 @@ void main (void)
} else {
// set the reflectivity proportional to shininess with user
// input
reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset;
reflFactor = (gl_FrontMaterial.shininess / 128.0) + transparency_offset;
}
reflFactor = clamp(reflFactor, 0.0, 1.0);

View file

@ -47,7 +47,7 @@ void main(void)
// Find a rotation matrix that rotates 1,0,0 into u. u, r and w are
// the columns of that matrix.
vec3 absu = abs(u);
vec3 r = normalize(vec3(-u.y, u.x, 0));
vec3 r = normalize(vec3(-u.y, u.x, 0.0));
vec3 w = cross(u, r);
// Do the matrix multiplication by [ u r w pos]. Assume no
@ -82,7 +82,7 @@ void main(void)
gl_FrontColor += gl_FrontLightModelProduct.sceneColor;
// As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1 - smoothstep(15000.0, 20000.0, fogCoord));
gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(15000.0, 20000.0, fogCoord));
gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects.

View file

@ -77,9 +77,9 @@ void main (void)
float ReflectedEye = max(dot(Reflected, Eye), 0.0);
float eyeFact = pow(ReflectedEye, 20.0);
c1 += 0.3 * gl_LightSource[0].diffuse * (1.0-eyeFact) * bumpFact*bumpFact;
c1 += 0.4 * gl_LightSource[0].diffuse * eyeFact * 3*bumpFact;
c1 += 0.4 * gl_LightSource[0].diffuse * eyeFact * 3.0*bumpFact;
eyeFact = pow(eyeFact, 20.0);
c1 += gl_LightSource[0].specular * eyeFact * 4*bumpFact;
c1 += gl_LightSource[0].specular * eyeFact * 4.0*bumpFact;
vec4 finalColor = c1;
gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);