Border.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*-----------------------------------------------------------.
  2. / Border /
  3. '-----------------------------------------------------------*/
  4. // Version 1.2
  5. /*
  6. Version 1.0 by Oomek
  7. - Fixes light, one pixel thick border in some games when forcing MSAA like i.e. Dishonored
  8. Version 1.1 by CeeJay.dk
  9. - Optimized the shader. It still does the same but now it runs faster.
  10. Version 1.2 by CeeJay.dk
  11. - Added border_width and border_color features
  12. Version 1.3 by CeeJay.dk
  13. - Optimized the performance further
  14. */
  15. #ifndef border_width
  16. #define border_width float2(1,0)
  17. #endif
  18. #ifndef border_color
  19. #define border_color float3(0, 0, 0)
  20. #endif
  21. float4 BorderPass( float4 colorInput, float2 tex )
  22. {
  23. float3 border_color_float = border_color / 255.0;
  24. float2 border = (pixel * border_width); //Translate integer pixel width to floating point
  25. float2 within_border = saturate((-tex * tex + tex) - (-border * border + border)); //becomes positive when inside the border and 0 when outside
  26. colorInput.rgb = all(within_border) ? colorInput.rgb : border_color_float ; //
  27. return colorInput; //return the pixel
  28. }