nightvision2.glsl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. uniform sampler2D samp9;
  2. out vec4 ocol0;
  3. in vec2 uv0;
  4. uniform vec4 resolution;
  5. void main()
  6. {
  7. //variables
  8. int internalresolution = 1278;
  9. float4 c0 = texture(samp9, uv0).rgba;
  10. //blur
  11. float4 blurtotal = float4(0, 0, 0, 0);
  12. float blursize = 1.5;
  13. blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
  14. blurtotal += texture(samp9, uv0 + float2(-blursize, blursize)*resolution.zw);
  15. blurtotal += texture(samp9, uv0 + float2( blursize, -blursize)*resolution.zw);
  16. blurtotal += texture(samp9, uv0 + float2( blursize, blursize)*resolution.zw);
  17. blurtotal += texture(samp9, uv0 + float2(-blursize, 0)*resolution.zw);
  18. blurtotal += texture(samp9, uv0 + float2( blursize, 0)*resolution.zw);
  19. blurtotal += texture(samp9, uv0 + float2( 0, -blursize)*resolution.zw);
  20. blurtotal += texture(samp9, uv0 + float2( 0, blursize)*resolution.zw);
  21. blurtotal *= 0.125;
  22. c0 = blurtotal;
  23. //greyscale
  24. float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
  25. // brighten
  26. grey = grey * 0.5 + 0.7;
  27. // darken edges
  28. float x = uv0.x * resolution.x;
  29. float y = uv0.y * resolution.y;
  30. if (x > internalresolution/2) x = internalresolution-x;
  31. if (y > internalresolution/2) y = internalresolution-y;
  32. if (x > internalresolution/2*0.95) x = internalresolution/2*0.95;
  33. if (y > internalresolution/2*0.95) y = internalresolution/2*0.95;
  34. x = -x+641;
  35. y = -y+641;
  36. /*****inline square root routines*****/
  37. // bit of a performance bottleneck.
  38. // neccessary to make the darkened area rounded
  39. // instead of rhombus-shaped.
  40. float sqrt=x/10;
  41. while((sqrt*sqrt) < x) sqrt+=0.1;
  42. x = sqrt;
  43. sqrt=y/10;
  44. while((sqrt*sqrt) < y) sqrt+=0.1;
  45. y = sqrt;
  46. /*****end of inline square root routines*****/
  47. x *= 2;
  48. y *= 2;
  49. grey -= x/200;
  50. grey -= y/200;
  51. // output
  52. ocol0 = float4(0, grey, 0, 1.0);
  53. }