Hi folks,
I found a thread on here talking about a lens shader to create a bulge on the screen as if it's been distorted by a lens: http://www.gamedev.net/community/forums/topic.asp?topic_id=384166
In that thread there's two examples shown on how to create the effect but i can't get either to work properly and it's really doing my head in!
With the technique that uses the offset 'normal map' when i put in a zoom value of 0 i get the original un-bulged image as you'd expect but any other value just results in a black screen... (i've tried 1.0 all the way down to 0.0000000000000001). I did change the code slightly though to get the image showing at all with a 0 zoom:
float zoom = 1.0;
float3 normal = (tex2D(gOffsetTex, texCoord).rgb/256.0);// ranges from 0 to 1
frag_colour = tex2D(gBulgeTexScene, texCoord + (normal.xy*normal.z*zoom) );
frag_colour.a = 1.0;
For the original technique mentioned by the thread's poster i get the image swirled up really badly or with the centre blank depending on the strength i use, again the code differs slightly:
float strength = 0.5;
float ZoomValue = strength-sqrt( ((texCoord.x-0.5)*(texCoord.x-0.5)) + ((texCoord.y-0.5)*(texCoord.y-0.5)) );
float2 origin = float2(0.5,0.5);
texCoord.x = texCoord.x * ZoomValue + origin.x;
texCoord.y = texCoord.y * ZoomValue + origin.y;
frag_colour = tex2D(gBulgeTexScene, texCoord);
Has anyone got any advice on this at all?