Hello,

I've followed some tutorials on deferred rendering and searched a lot, but I don't get what's going wrong here. In the tutorials it works this way, and when I try it, it doesn't.

I'm getting the following error:

1 2 3 4 5 6 7
| Unable to create fragment shader: Fragment shader failed to compile with the following errors: WARNING: 0:20: warning(#402) Implicit truncation of vector from size 4 to size 1. ERROR: 0:21: error(#247) Function return is not matching type WARNING: 0:39: warning(#402) Implicit truncation of vector from size 4 to size 3. WARNING: 0:42: warning(#402) Implicit truncation of vector from size 4 to size 3. ERROR: error(#273) 1 compilation errors. No code generated |

The fragment shader I'm using with this test:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| uniform sampler2D tDiffuse; uniform sampler2D tPosition; uniform sampler2D tNormals; uniform sampler2D tShadowMap; uniform vec3 cameraPosition; uniform mat4 worldToLightViewMatrix; uniform mat4 lightViewToProjectionMatrix; uniform mat4 worldToCameraViewMatrix;
float readShadowMap(vec3 eyeDir) { mat4 cameraViewToWorldMatrix = inverse(worldToCameraViewMatrix); mat4 cameraViewToProjectedLightSpace = lightViewToProjectionMatrix * worldToLightViewMatrix * cameraViewToWorldMatrix; vec4 projectedEyeDir = cameraViewToProjectedLightSpace * vec4(eyeDir,1); projectedEyeDir = projectedEyeDir/projectedEyeDir.w;
vec2 textureCoordinates = projectedEyeDir.xy * vec2(0.5,0.5) + vec2(0.5,0.5);
const float bias = 0.0001; float depthValue = texture2D( tShadowMap, textureCoordinates ) - bias; return projectedEyeDir.z * 0.5 + 0.5 < depthValue; }
void main( void ) { vec4 image = texture2D( tDiffuse, gl_TexCoord[0].xy ); vec4 position = texture2D( tPosition, gl_TexCoord[0].xy ); vec4 normal = texture2D( tNormals, gl_TexCoord[0].xy ); mat4 lightViewToWolrdMatrix = inverse(worldToLightViewMatrix); vec3 light = lightViewToWolrdMatrix[3].xyz; vec3 lightDir = light - position.xyz; normal = normalize(normal); lightDir = normalize(lightDir); vec3 eyeDir = position.xyz - cameraPosition; vec3 reflectedEyeVector = normalize(reflect(eyeDir, normal)); float shadow = readShadowMap(eyeDir); float diffuseLight = max(dot(normal,lightDir),0) * shadow; float ambientLight = 0.1;
gl_FragColor = (diffuseLight + ambientLight ) * image + pow(max(dot(lightDir,reflectedEyeVector),0.0), 100) * 1.5 * shadow; } |

The solution or a push in the right direction would be welcome.