Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. /*
  2. Credits :: icelaglace, a.o => (ported from some blog, author unknown)
  3. Credits :: Pascal aka Marty McFly
  4. Amateur port by Insomnia
  5. */
  6.  
  7. uniform int iFisheyeMod <
  8. ui_type = "combo";
  9. ui_items = "Horizontal\0Vertical\0Combined\0";
  10. > = 0;
  11.  
  12. uniform float fFisheyeZoom <
  13. ui_type = "drag";
  14. ui_min = 0.5; ui_max = 1.0;
  15. ui_label = "Fish Eye Zoom";
  16. ui_tooltip = "Lens zoom to hide bugged edges due to texcoord modification";
  17. > = 0.55;
  18. uniform float fFisheyeDistortion <
  19. ui_type = "drag";
  20. ui_min = -0.300; ui_max = 0.300;
  21. ui_label = "Fisheye Distortion";
  22. ui_tooltip = "Distortion of image";
  23. > = 0.01;
  24. uniform float fFisheyeDistortionCubic <
  25. ui_type = "drag";
  26. ui_min = -0.300; ui_max = 0.300;
  27. ui_label = "Fisheye Distortion Cubic";
  28. ui_tooltip = "Distortion of image, cube based";
  29. > = 0.7;
  30. uniform float fFisheyeColorshift <
  31. ui_type = "drag";
  32. ui_min = -0.10; ui_max = 0.10;
  33. ui_label = "Colorshift";
  34. ui_tooltip = "Amount of color shifting";
  35. > = 0.002;
  36.  
  37. #include "ReShade.fxh"
  38.  
  39. float3 FISHEYE_CAPass(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
  40. {
  41. float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
  42.  
  43. float4 coord=0.0;
  44. coord.xy=texcoord.xy;
  45. coord.w=0.0;
  46.  
  47. color.rgb = 0.0;
  48.  
  49. float3 eta = float3(1.0+fFisheyeColorshift*0.9,1.0+fFisheyeColorshift*0.6,1.0+fFisheyeColorshift*0.3);
  50. float2 center;
  51. center.x = coord.x-0.5;
  52. center.y = coord.y-0.5;
  53. float LensZoom = 1.0/fFisheyeZoom;
  54.  
  55. float r2;// + (texcoord.y-0.5) * (texcoord.y-0.5);
  56.  
  57. if(iFisheyeMod == 0)
  58. {
  59. r2 = (texcoord.y-0.5) * (texcoord.y-0.5);
  60. }
  61. else if (iFisheyeMod == 1)
  62. {
  63. r2 = (texcoord.x-0.5) * (texcoord.x-0.5);
  64. }
  65. else
  66. {
  67. r2 = (texcoord.y-0.5) * (texcoord.y-0.5) + (texcoord.y-0.5) * (texcoord.y-0.5);
  68. }
  69.  
  70.  
  71. float f = 0;
  72.  
  73. if( fFisheyeDistortionCubic == 0.0){
  74. f = 1 + r2 * fFisheyeDistortion;
  75. }else{
  76. f = 1 + r2 * (fFisheyeDistortion + fFisheyeDistortionCubic * sqrt(r2));
  77. };
  78.  
  79. float x = f*LensZoom*(coord.x-0.5)+0.5;
  80. float y = f*LensZoom*(coord.y-0.5)+0.5;
  81. float2 rCoords = (f*eta.r)*LensZoom*(center.xy*0.5)+0.5;
  82. float2 gCoords = (f*eta.g)*LensZoom*(center.xy*0.5)+0.5;
  83. float2 bCoords = (f*eta.b)*LensZoom*(center.xy*0.5)+0.5;
  84.  
  85. color.x = tex2D(ReShade::BackBuffer,rCoords).r;
  86. color.y = tex2D(ReShade::BackBuffer,gCoords).g;
  87. color.z = tex2D(ReShade::BackBuffer,bCoords).b;
  88.  
  89. return color.rgb;
  90.  
  91. }
  92.  
  93.  
  94. technique FISHEYE_CA_HORIZONTAL
  95. {
  96. pass
  97. {
  98. VertexShader = PostProcessVS;
  99. PixelShader = FISHEYE_CAPass;
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement