Guest User

7

a guest
Feb 14th, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. /*******
  2. bla
  3. *******/
  4.  
  5. uniform int bParallaxDoDepthCheck <
  6. ui_type = "drag";
  7. ui_min = 0; ui_max = 1;
  8. ui_label = "Depth Check";
  9. ui_tooltip = "EXPERIMENTAL! If enabled, shader compares parallax samples depth to avoid artifacts at object borders.";
  10. > = 0;
  11. uniform float fParallaxDepthCutoff <
  12. ui_type = "drag";
  13. ui_min = 0.0001; ui_max = 0.0100;
  14. ui_label = "Depth Cutoff";
  15. ui_tooltip = "Preserves object edges from getting artifacts. If pixel depth difference of parallax samples is higher than that, pixel gets skipped.";
  16. > = 0.0001;
  17. uniform float fParallaxPower <
  18. ui_type = "drag";
  19. ui_min = 0.100; ui_max = 2.000;
  20. ui_label = "Power";
  21. ui_tooltip = "Amount of parallax.";
  22. > = 0.666;
  23. uniform float fParallaxOffset <
  24. ui_type = "drag";
  25. ui_min = 0.0; ui_max = 5.000;
  26. ui_label = "Offset";
  27. ui_tooltip = "Pixel offset for parallax.";
  28. > = 2.0;
  29. uniform float iParallaxAngle <
  30. ui_type = "drag";
  31. ui_min = 0.0; ui_max = 360.000;
  32. ui_label = "Offset Angle";
  33. ui_tooltip = "Pixel offset angle for parallax.";
  34. > = 90.0;
  35. uniform float fParallaxFade <
  36. ui_type = "drag";
  37. ui_min = 0.0; ui_max = 1.000;
  38. ui_label = "Fadeout Distance";
  39. > = 0.4;
  40.  
  41. #include "ReShade.fxh"
  42.  
  43. float4 PS_Parallax(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  44. {
  45. float2 offset;
  46. sincos(radians( iParallaxAngle), offset.y, offset.x);
  47. offset *= ReShade::PixelSize*fParallaxOffset;
  48.  
  49. float centerdepth = ReShade::GetLinearizedDepth(texcoord);
  50. float3 centercolor = tex2D(ReShade::BackBuffer, texcoord).rgb;
  51.  
  52. offset /= centerdepth + 1;
  53.  
  54. float2 uv[2] = {texcoord - offset, texcoord + offset};
  55.  
  56. float3 colorA = tex2D(ReShade::BackBuffer, uv[0]).rgb;
  57. float3 colorB = tex2D(ReShade::BackBuffer, uv[1]).rgb;
  58. float depthA = ReShade::GetLinearizedDepth(uv[0]);
  59. float depthB = ReShade::GetLinearizedDepth(uv[1]);
  60.  
  61. float colDot = max(0, dot(centercolor * 2 - colorA - colorB, fParallaxPower));
  62. float luminance = dot(centercolor, float3(0.8,0.2,0.2));
  63.  
  64. colDot *= saturate(1 - luminance*luminance);
  65. colDot *= saturate(1.00001-centerdepth/fParallaxFade);
  66. colDot = (max(abs(depthA-centerdepth),abs(depthB-centerdepth)) > fParallaxDepthCutoff && bParallaxDoDepthCheck) ? 0 : colDot;
  67.  
  68.  
  69. float4 res;
  70. res.rgb = centercolor - colDot;
  71. res.w = 1.0;
  72. return res;
  73. }
  74.  
  75. technique Parallax_Tech
  76. {
  77. pass Parallax
  78. {
  79. VertexShader = PostProcessVS;
  80. PixelShader = PS_Parallax;
  81. }
  82. }
Add Comment
Please, Sign In to add comment