ATI X1___ series gives this error when trying to link my terrain shader. It does not give any specific information about what is wrong. Any ideas?
Loading shader “abstract::terrain.vert”, “abstract::terrain.frag”…
Fragment shader was successfully compiled to run on hardware.
Vertex shader was successfully compiled to run on hardware.
Error: Failed to link shader program.
Fragment shader(s) failed to link, vertex shader(s) linked.
Fragment Shader not supported by HW
terrain.vert:
attribute float TerrainHeight;
varying vec3 texcoord0;
varying vec2 texcoord1;
varying vec3 VertexPosition;
varying vec4 ModelVertex;
varying vec3 T,B;
uniform vec2 TerrainSectorOffset;
uniform float TerrainSize;
uniform float Height;
uniform float TerrainAltitude;
void main(void) {
vec4 v = vec4( gl_Vertex.x+TerrainSectorOffset.x, TerrainHeight / 65536.0 * TerrainAltitude, gl_Vertex.y+TerrainSectorOffset.y, 1.0 );
ModelVertex = gl_ModelViewMatrix * v;
gl_Position = gl_ProjectionMatrix * ModelVertex;
//vec3 N = (gl_Normal + 1.0) * 0.5;
T = gl_NormalMatrix * vec3(1.0,0.0,0.0);
B = gl_NormalMatrix * vec3(0.0,0.0,-1.0);
gl_FrontColor = gl_Color;
texcoord0 = v.xyz;
texcoord0.z *= -1.0;
texcoord1 = (vec2(TerrainSectorOffset.x+gl_Vertex.x,-TerrainSectorOffset.y-gl_Vertex.y)) / TerrainSize + vec2(0.5/TerrainSize,-0.5/TerrainSize) + vec2(0.5,0.5);
VertexPosition = v.xyz;
if (gl_Fog.color.w>0.0) {
gl_FogFragCoord = max(-( gl_ModelViewMatrix * v ).z,0.0);
}
#ifdef __GLSL_CG_DATA_TYPES
gl_ClipVertex = gl_ModelViewMatrix * vec4( gl_Vertex.x+TerrainSectorOffset.x, TerrainHeight / 65536.0 * TerrainAltitude, gl_Vertex.y+TerrainSectorOffset.y, 1.0 );
#endif
}
terrain.frag:
uniform sampler2D texture0;// normal map
uniform sampler2D texture1;// alpha map
uniform sampler2D texture2;// texture0
uniform sampler2D texture3;// bumpmap0
uniform sampler2D texture4;// texture1
uniform sampler2D texture5;// bumpmap1
uniform sampler2D texture6;// texture2
uniform sampler2D texture7;// bumpmap2
//uniform sampler2D texture8;// texture3
//uniform sampler2D texture9;// bumpmap3
uniform sampler2DShadow texture8;
uniform sampler2DShadow texture9;
uniform sampler2DShadow texture10;
uniform sampler2DShadow texture11;
uniform sampler2DShadow texture12;
uniform sampler2DShadow texture13;
uniform sampler2DShadow texture14;
uniform sampler2DShadow texture15;
uniform sampler2DShadow texture16;
varying vec3 VertexPosition;
uniform vec3 CameraPosition;
uniform vec2 LayerPosition[ LW_TERRAINLAYERS ];
uniform vec2 LayerScale[ LW_TERRAINLAYERS ];
uniform float LayerRotation[ LW_TERRAINLAYERS ];
varying vec3 texcoord0;
varying vec2 texcoord1;
uniform mat4 LightMatrix[ LW_LIGHTMATRIXARRAYSIZE ];
varying vec4 ModelVertex;
varying vec3 T,B;
Include "light.glsl"
Include "DirectionalShadow.glsl"
Include "PointShadow.glsl"
Include "SpotShadow.glsl"
void main(void) {
vec4 AmbientLight = gl_LightSource[0].ambient;
float dirshadowoffset = 0.0;
vec4 lightcolor = vec4(0.0,0.0,0.0,0.0);
vec4 albedo;
vec4 alpha = texture2D(texture1,texcoord1);
vec4 bumpcolor;
vec3 normal;
vec3 worldNormal = normalize(((texture2D(texture0,texcoord1).xyz - 0.5) * 2.0).xyz);
vec3 N = normalize( gl_NormalMatrix * worldNormal);
vec3 bumpnormal = vec3(1.0,1.0,1.0);
float shininess = 0.0;
normal=N;
vec2 coord;
vec3 mix;
float sum = abs(worldNormal.x) + abs(worldNormal.y) + abs(worldNormal.z);
mix.x = abs(worldNormal.x) / sum;
mix.y = abs(worldNormal.y) / sum;
mix.z = abs(worldNormal.z) / sum;
albedo = vec4(1.0);
vec4 layerdiffuse;
vec4 layerdiffuse1;
int usebumpcolor;
// ====================================================================
// Texture 0
// ====================================================================
#ifdef LW_LAYER0
#ifdef LW_LAYER0_VERTICAL
layerdiffuse = texture2D(LW_LAYER0,texcoord0.xy / gl_LightSource[1].ambient.x) * mix.z;
layerdiffuse += texture2D(LW_LAYER0,texcoord0.zy / gl_LightSource[1].ambient.x) * mix.x;
layerdiffuse += texture2D(LW_LAYER0,texcoord0.xz / gl_LightSource[1].ambient.x) * mix.y;
layerdiffuse = clamp(layerdiffuse,0.0,1.0);
#endif
#ifndef LW_LAYER0_VERTICAL
layerdiffuse = texture2D(LW_LAYER0,texcoord0.xz / gl_LightSource[1].ambient.x);
#endif
albedo = layerdiffuse;
#endif
// ====================================================================
//
// ====================================================================
// ====================================================================
// Bumpmap 0
// ====================================================================
#ifdef LW_BUMPMAP0
#ifdef LW_LAYER0_VERTICAL
layerdiffuse = texture2D(LW_BUMPMAP0,texcoord0.xy / gl_LightSource[1].ambient.x) * abs(worldNormal.z);
layerdiffuse += (texture2D(LW_BUMPMAP0,texcoord0.zy / gl_LightSource[1].ambient.x) * abs(worldNormal.x));
layerdiffuse += (texture2D(LW_BUMPMAP0,texcoord0.xz / gl_LightSource[1].ambient.x) * abs(worldNormal.y));
//layerdiffuse = texture2D(LW_BUMPMAP0,texcoord0.xy / gl_LightSource[1].ambient.x);
//layerdiffuse1 = texture2D(LW_BUMPMAP0,texcoord0.zy / gl_LightSource[1].ambient.x);
//layerdiffuse = layerdiffuse*mix + layerdiffuse1*(1.0-mix);
#endif
#ifndef LW_LAYER0_VERTICAL
layerdiffuse = texture2D(LW_BUMPMAP0,texcoord0.xz / gl_LightSource[1].ambient.x);
#endif
bumpcolor = layerdiffuse;
#endif
#ifndef LW_BUMPMAP0
bumpcolor = vec4(0.5,0.5,1.0,1.0);//vec4(worldNormal*0.5+0.5,1.0);
#endif
// ====================================================================
//
// ====================================================================
// ====================================================================
// Texture 1
// ====================================================================
#ifdef LW_LAYER1
#ifdef LW_LAYER1_VERTICAL
layerdiffuse = texture2D(LW_LAYER1,texcoord0.xy / gl_LightSource[1].ambient.y) * mix.z;
layerdiffuse += texture2D(LW_LAYER1,texcoord0.zy / gl_LightSource[1].ambient.y) * mix.x;
layerdiffuse += texture2D(LW_LAYER1,texcoord0.xz / gl_LightSource[1].ambient.y) * mix.y;
#endif
#ifndef LW_LAYER1_VERTICAL
layerdiffuse = texture2D(LW_LAYER1,texcoord0.xz / gl_LightSource[1].ambient.y);
#endif
albedo = (1.0 - alpha.x) * albedo + (alpha.x * layerdiffuse);
#endif
// ====================================================================
//
// ====================================================================
// ====================================================================
// Bumpmap 1
// ====================================================================
#ifdef LW_BUMPMAP1
#ifdef LW_LAYER1_VERTICAL
layerdiffuse = texture2D(LW_BUMPMAP1,texcoord0.xy / gl_LightSource[1].ambient.y) * mix.z;
layerdiffuse += texture2D(LW_BUMPMAP1,texcoord0.zy / gl_LightSource[1].ambient.y) * mix.x;
layerdiffuse += texture2D(LW_BUMPMAP1,texcoord0.xz / gl_LightSource[1].ambient.y) * mix.y;
#endif
#ifndef LW_LAYER1_VERTICAL
layerdiffuse = texture2D(LW_BUMPMAP1,texcoord0.xz / gl_LightSource[1].ambient.y);
#endif
bumpcolor = (1.0 - alpha.x) * bumpcolor + (alpha.x * layerdiffuse);
#endif
// ====================================================================
//
// ====================================================================
bumpnormal = normalize(bumpcolor.xyz - 0.5);
normal = T * bumpnormal.x + B * bumpnormal.y + N * bumpnormal.z;
//#ifdef LW_LAYER2
// albedo = (1.0 - alpha.y) * albedo + (alpha.y * texture2D(texture6,texcoord0*0.5));
// bumpcolor = texture2D(texture7,texcoord0);
// normal = normalize(bumpcolor.xyz - 0.5);
// normal = normal * (1.0 - alpha.y) + (alpha.y * (T * normal.x + B * normal.y + N * normal.z));
//#endif
//#ifdef LW_LAYER3
// albedo = (1.0 - alpha.z) * albedo + (alpha.z * texture2D(texture8,texcoord0*0.5));
// bumpcolor = texture2D(texture9,texcoord0);
// normal = normalize(bumpcolor.xyz - 0.5);
// normal = normal * (1.0 - alpha.z) + (alpha.z * (T * normal.x + B * normal.y + N * normal.z));
//#endif
Include "ProcessLights.glsl"
vec4 finalcolor = albedo * AmbientLight + albedo * lightcolor;
//gl_FragColor = AmbientLight * 0.5 + lightcolor * 0.5;
//if (abs(worldNormal.x)>abs(worldNormal.z)) {
// gl_FragColor = vec4(1.0,0.0,0.0,1.0);
//}
//else {
// gl_FragColor = vec4(0.0,0.0,1.0,1.0);
//}
Include "Fog.glsl"
gl_FragColor = finalcolor;
//gl_FragColor=alpha;
//gl_FragColor = lightcolor;
}