topical media & game development
Web3D/VR
shader(s) -- gray-ofs
// gray offset
// (c) 2005 Holger Grahn
float time=0;
float sampleDist = 1.0f/512.0f; // distance one pixel in u/v
float displaceAmount=0.2;
sampler2D image : register(s0);
float4 main(
float4 Pos : POSITION,
float2 texCoord: TEXCOORD0) : COLOR
{
float4 img = tex2D(image, texCoord);
// convert to gray
float2 sum;
sum.x = dot(img, float4(0.90f, 0.4, 0.2f, 0.0f))-0.5;
sum.y = dot(img, float4(0.2f, 0.4f, 0.9f, 1.0f))-0.5;
float fac=displaceAmount;
//fac *= pow(sin(time*3.1414)-0.5,1.7);
fac *= pow(time,1.7);
//img = tex2D(image, float2(texCoord.x+exp(fac*sum.x),texCoord.y+fac*sum.y));
img = tex2D(image, float2(texCoord.x+(fac*sum.x),texCoord.y+fac*sum.y));
return img;
}
(C) Æliens
20/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.