Guest User

Untitled

a guest
Sep 13th, 2015
1,232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. // ReShade effect file
  3. // visit facebook.com/MartyMcModding for news/updates
  4. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5. // Advanced Depth of Field lite by Marty McFly
  6. // For private use only!
  7. // Copyright © 2008-2015 Marty McFly
  8. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  9.  
  10. #define iADOF_ImageChromaHues 25 //[2 to 20] Amount of samples through the light spectrum to get a smooth gradient.
  11. #define fADOF_ImageChromaCurve 1.0 //[0.5 to 2.0] Image chromatic aberration curve. Higher means less chroma at screen center areas.
  12. #define fADOF_ImageChromaAmount 100.0 //[5.0 to 200.0] Linearly increases image chromatic aberration amount.
  13.  
  14.  
  15. /////////////////////////TEXTURES / INTERNAL PARAMETERS/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  16. /////////////////////////TEXTURES / INTERNAL PARAMETERS/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17.  
  18.  
  19. #define ScreenSize float4(BUFFER_WIDTH, BUFFER_RCP_WIDTH, float(BUFFER_WIDTH) / float(BUFFER_HEIGHT), float(BUFFER_HEIGHT) / float(BUFFER_WIDTH)) //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  20. #define PixelSize float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
  21. uniform float Timer < source = "timer"; >;
  22.  
  23. texture2D texColor : COLOR;
  24.  
  25. sampler2D SamplerColor
  26. {
  27. Texture = texColor;
  28. MinFilter = LINEAR;
  29. MagFilter = LINEAR;
  30. MipFilter = LINEAR;
  31. AddressU = Clamp;
  32. AddressV = Clamp;
  33. };
  34.  
  35. /////////////////////////VERTEX SHADER//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. /////////////////////////VERTEX SHADER//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37.  
  38. struct VS_OUTPUT_POST
  39. {
  40. float4 vpos : POSITION;
  41. float2 txcoord : TEXCOORD0;
  42. };
  43.  
  44. VS_OUTPUT_POST VS_PostProcess(in uint id : SV_VertexID)
  45. {
  46. VS_OUTPUT_POST OUT;
  47. OUT.txcoord.x = (id == 2) ? 2.0 : 0.0;
  48. OUT.txcoord.y = (id == 1) ? 2.0 : 0.0;
  49. OUT.vpos = float4(OUT.txcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  50. return OUT;
  51. }
  52.  
  53. /////////////////////////PIXEL SHADERS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  54. /////////////////////////PIXEL SHADERS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  55.  
  56.  
  57. float4 PS_Chroma(VS_OUTPUT_POST IN) : COLOR
  58. {
  59. float4 scenecolor = 0;
  60.  
  61. float2 coord=IN.txcoord.xy*2.0-1.0;
  62. float offsetfact=length(IN.txcoord.xy*2.0-1.0);
  63. offsetfact=pow(offsetfact,fADOF_ImageChromaCurve)*fADOF_ImageChromaAmount*BUFFER_RCP_WIDTH;
  64.  
  65. float3 chromaweight = 0.0;
  66.  
  67. [unroll]
  68. for (float c=0; c<iADOF_ImageChromaHues && c < 90; c++)
  69. {
  70. float temphue = c/iADOF_ImageChromaHues;
  71. float3 tempchroma = saturate(float3(abs(temphue * 6.0 - 3.0) - 1.0,2.0 - abs(temphue * 6.0 - 2.0),2.0 - abs(temphue * 6.0 - 4.0)));
  72. float tempoffset = (c + 0.5)/iADOF_ImageChromaHues - 0.5;
  73. float3 tempsample = tex2Dlod(SamplerColor, float4(coord.xy*(1.0+offsetfact*tempoffset)*0.5+0.5,0,0)).xyz;
  74. scenecolor.xyz += tempsample.xyz*tempchroma.xyz;
  75. chromaweight += tempchroma;
  76. }
  77. //not all hues have the same brightness, FF0000 and FFFF00 are obviously differently bright but are just different hues.
  78. //there is no generic way to make it work for all different hue options. Sometimes / samples * 0.5 works, then * 0.666, then something completely different.
  79. scenecolor.xyz /= dot(chromaweight.xyz, 0.333);
  80.  
  81. return scenecolor;
  82. }
  83.  
  84. /////////////////////////TECHNIQUES/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  85. /////////////////////////TECHNIQUES/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  86.  
  87. technique DepthOfField < bool enabled = 1; toggle=0x20; >
  88. {
  89. pass Chroma
  90. {
  91. VertexShader = VS_PostProcess;
  92. PixelShader = PS_Chroma;
  93. }
  94. }
RAW Paste Data