Cool, I didnt think this would work, but it does!
And the error on edges caused by computing the normals from depth map is actually a feature, as it does a 'black edge highlighting' style thing.
Talk about waste of gpu cycles?
Code: Select all
vec2 up2 = gl_TexCoord[0].st + vec2(0 , inverseRY);
vec4 up4 = vec4(vec3(up2.xy, texture2D( tex0,up2 ).x) * 2.0 - 1.0 ,1);
up4 = viewProjectionInv * up4;
up4.xyz = up4.xyz / up4.w;
vec2 right2 = gl_TexCoord[0].st + vec2(inverseRY , 0);
vec4 right4 = vec4(vec3(right2.xy, texture2D( tex0,right2 ).x) * 2.0 - 1.0 ,1);
right4 = viewProjectionInv * right4;
right4.xyz = right4.xyz / right4.w;
vec4 here4 = vec4(vec3(gl_TexCoord[0].st, texture2D( tex0,gl_TexCoord[0].st ).x) * 2.0 - 1.0 ,1);
here4 = viewProjectionInv * here4;
here4.xyz = here4.xyz / here4.w;
vec4 herenormal4;
herenormal4.xyz = -1*normalize(cross( up4.xyz - here4.xyz, right4.xyz - here4.xyz));
float dist=length(lightpos.xyz - here4.xyz);
float cosphi=dot(herenormal4.xyz, lightpos.xyz - here4.xyz)/dist;
gl_FragColor=vec4(1,1,1, cosphi*(lightpos.w/(dist*dist)));
Does anyone know why stuff like healthbars and ETA timers get drawn before the bloom shader (which is at level -10000)?