Paste will expire never.
- sampler2D baseMap;
- float4 main(float2 tc : TEXCOORD0) : COLOR0
- {
- float2 size = float2(512, 512);
- float2 isize = 1.0 / size;
- //We need this to correctly address all eight texels
- float2 ssize = frac(tc * size);
- tc -= ssize*isize;
- tc.x *= 8.0;
- ssize *= 0.5;
- float4 eq[8];
- for(int i = 0; i < 8; i++)
- eq[i] = tex2D(baseMap, tc+float2(i,0.0)*isize);
- float wind = 1.0;
- for(int i = 0; i < 8; i++)
- {
- float mult = -1.0;
- if(ssize.y <= eq[i].x) //check if point is above line segment
- mult = 1.0;
- if(ssize.y > eq[i].w) //or below
- mult = 1.0;
- //find x coordinate of intersection point
- float ty = ssize.y - eq[i].x;
- float ty2 = eq[i].w - eq[i].x;
- float rel = ty / ty2;
- float resx = lerp(eq[i].z, eq[i].y, rel);
- if(resx > ssize.x) //if intersection point lies on the ray
- wind *= mult;
- }
- return wind;
- }
Editing is locked.