filterF.c 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. void main(
  2. float2 iTex0 : TEXCOORD0,
  3. out float4 oCol : COLOR,
  4. uniform samplerRECT refractTex,
  5. uniform float screenW,
  6. uniform float screenH,
  7. uniform float cursorX,
  8. uniform float cursorY
  9. )
  10. {
  11. /* Deform by screwing up the texcoords. There are
  12. millions of ways to do that. Here's one, the closer to the cursor,
  13. the more deformation */
  14. float distX = cursorX - iTex0.x;
  15. float distY = cursorY - iTex0.y;
  16. float dist = sqrt( distX*distX + distY*distY );
  17. iTex0.x *= screenW + dist * 200;
  18. iTex0.y *= screenH + dist * 200;
  19. /* And a little bit grayscale stuff. We want the surroundings
  20. of the cursor to be grayscaled, the bigger the distance,
  21. the more brownish grayscale */
  22. float3 pixel = texRECT( refractTex, iTex0.xy ).rgb;
  23. float grayScale = 0.3*pixel.r + 0.59*pixel.g + 0.11*pixel.b;
  24. oCol.rgb = lerp( pow(pixel,2)*3, grayScale * float3(0.31,0.28,0.21), sqrt( sqrt(dist)) ).rgb;
  25. oCol.a = 1;
  26. }