Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Copyright (C) 2015 Ganossa (mediehawk@gmail.com)
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5.  * this software and associated documentation files (the "Software"), to deal in
  6.  * the Software with restriction, including without limitation the rights to
  7.  * use and/or sell copies of the Software, and to permit persons to whom the Software
  8.  * is furnished to do so, subject to the following conditions:
  9.  *
  10.  * The above copyright notice and the permission notices (this and below) shall
  11.  * be included in all copies or substantial portions of the Software.
  12.  *
  13.  * Permission needs to be specifically granted by the author of the software to any
  14.  * person obtaining a copy of this software and associated documentation files
  15.  * (the "Software"), to deal in the Software without restriction, including without
  16.  * limitation the rights to copy, modify, merge, publish, distribute, and/or
  17.  * sublicense the Software, and subject to the following conditions:
  18.  *
  19.  * The above copyright notice and the permission notices (this and above) shall
  20.  * be included in all copies or substantial portions of the Software.
  21.  *
  22.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25.  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28.  * SOFTWARE.
  29.  */
  30.  
  31. /**
  32.  * This version of AmbientLight.fx has been modified to allow the "dither" effect
  33.  * to be toggled on and off.
  34.  */
  35.  
  36. uniform bool alDebug <
  37.     ui_tooltip = "Activates debug mode of AL, upper bar shows detected light, lower bar shows adaptation";
  38. > = false;
  39. uniform float alInt <
  40.     ui_type = "drag";
  41.     ui_min = 0.0; ui_max = 20.0;
  42.     ui_tooltip = "Base intensity of AL";
  43. > = 10.15;
  44. uniform float alThreshold <
  45.     ui_type = "drag";
  46.     ui_min = 0.0; ui_max = 100.0;
  47.     ui_tooltip = "Reduces intensity for not bright light";
  48. > = 15.00;
  49. uniform bool AL_Dither <
  50.     ui_tooltip = "Applies dither - may cause diagonal stripes";
  51. > = true;
  52.  
  53. uniform bool AL_Adaptation <
  54.     ui_tooltip = "Activates adaptation algorithm";
  55. > = true;
  56. uniform float alAdapt <
  57.     ui_type = "drag";
  58.     ui_min = 0.0; ui_max = 4.0;
  59.     ui_tooltip = "Intensity of AL correction for bright light";
  60. > = 0.70;
  61. uniform float alAdaptBaseMult <
  62.     ui_type = "drag";
  63.     ui_min = 0.0; ui_max = 4.0;
  64.     ui_tooltip = "Multiplier for adaption applied to the original image";
  65. > = 1.00;
  66. uniform int alAdaptBaseBlackLvL <
  67.     ui_type = "drag";
  68.     ui_min = 0; ui_max = 4;
  69.     ui_tooltip = "Distinction level of black and white (lower => less distinct)";
  70. > = 2;
  71.  
  72. uniform bool AL_Dirt <
  73. > = true;
  74. uniform bool AL_DirtTex <
  75.     ui_tooltip = "Defines if dirt texture is used as overlay";
  76. > = false;
  77. uniform bool AL_Vibrance <
  78.     ui_tooltip = "Vibrance of dirt effect";
  79. > = false;
  80. uniform int AL_Adaptive <
  81.     ui_type = "combo";
  82.     ui_min = 0; ui_max = 2;
  83.     ui_items = "Warm\0Cold\0Light Dependent\0";
  84. > = 0;
  85. uniform float alDirtInt <
  86.     ui_type = "drag";
  87.     ui_min = 0.0; ui_max = 2.0;
  88.     ui_tooltip = "Intensity of dirt effect";
  89. > = 1.0;
  90. uniform float alDirtOVInt <
  91.     ui_type = "drag";
  92.     ui_min = 0.0; ui_max = 2.0;
  93.     ui_tooltip = "Intensity of colored dirt effect";
  94. > = 1.0;
  95. uniform bool AL_Lens <
  96.     ui_tooltip = "Lens effect based on AL";
  97. > = false;
  98. uniform float alLensThresh <
  99.     ui_type = "drag";
  100.     ui_min = 0.0; ui_max = 1.0;
  101.     ui_tooltip = "Reduces intensity of lens effect for not bright light";
  102. > = 0.5;
  103. uniform float alLensInt <
  104.     ui_type = "drag";
  105.     ui_min = 0.0; ui_max = 10.0;
  106.     ui_tooltip = "Intensity of lens effect";
  107. > = 2.0;
  108.  
  109. #include "ReShade.fxh"
  110.  
  111. uniform float2 AL_t < source = "pingpong"; min = 0.0f; max = 6.28f; step = float2(0.1f, 0.2f); >;
  112.  
  113. #define GEMFX_PIXEL_SIZE float2(1.0f / (BUFFER_WIDTH / 16.0f), 1.0f / (BUFFER_HEIGHT / 16.0f))
  114.  
  115. texture alInTex  { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA32F; };
  116. texture alOutTex { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA32F; };
  117. texture detectIntTex { Width = 32; Height = 32; Format = RGBA8; };
  118. sampler detectIntColor { Texture = detectIntTex; };
  119. texture detectLowTex { Width = 1; Height = 1; Format = RGBA8; };
  120. sampler detectLowColor { Texture = detectLowTex; };
  121.  
  122. texture dirtTex    < source = "Dirt.png";    > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  123. texture dirtOVRTex < source = "DirtOVR.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  124. texture dirtOVBTex < source = "DirtOVB.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  125. texture lensDBTex  < source = "LensDB.png";  > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  126. texture lensDB2Tex < source = "LensDB2.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  127. texture lensDOVTex < source = "LensDOV.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  128. texture lensDUVTex < source = "LensDUV.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
  129.  
  130. sampler alInColor { Texture = alInTex; };
  131. sampler alOutColor { Texture = alOutTex; };
  132. sampler dirtSampler { Texture = dirtTex; };
  133. sampler dirtOVRSampler { Texture = dirtOVRTex; };
  134. sampler dirtOVBSampler { Texture = dirtOVBTex; };
  135. sampler lensDBSampler { Texture = lensDBTex; };
  136. sampler lensDB2Sampler { Texture = lensDB2Tex; };
  137. sampler lensDOVSampler { Texture = lensDOVTex; };
  138. sampler lensDUVSampler { Texture = lensDUVTex; };
  139.  
  140. void PS_AL_DetectInt(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 detectInt : SV_Target0)
  141. {
  142.     detectInt = tex2D(ReShade::BackBuffer, texcoord);
  143. }
  144.  
  145. void PS_AL_DetectLow(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 detectLow : SV_Target0)
  146. {
  147.     detectLow = 0;
  148.  
  149.     if (texcoord.x != 0.5 && texcoord.y != 0.5)
  150.         discard;
  151.  
  152.     [loop]
  153.     for (float i = 0.0; i <= 1; i += 0.03125)
  154.     {
  155.         [unroll]
  156.         for (float j = 0.0; j <= 1; j += 0.03125)
  157.         {
  158.             detectLow.xyz += tex2D(detectIntColor, float2(i, j)).xyz;
  159.         }
  160.     }
  161.  
  162.     detectLow.xyz /= 32 * 32;
  163. }
  164.  
  165. void PS_AL_DetectHigh(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 x : SV_Target)
  166. {
  167.     x = tex2D(ReShade::BackBuffer, texcoord);
  168.     x = float4(x.rgb * pow(abs(max(x.r, max(x.g, x.b))), 2.0), 1.0f);
  169.  
  170.     float base = (x.r + x.g + x.b); base /= 3;
  171.    
  172.     float nR = (x.r * 2) - base;
  173.     float nG = (x.g * 2) - base;
  174.     float nB = (x.b * 2) - base;
  175.  
  176.     [flatten]
  177.     if (nR < 0)
  178.     {
  179.         nG += nR / 2;
  180.         nB += nR / 2;
  181.         nR = 0;
  182.     }
  183.     [flatten]
  184.     if (nG < 0)
  185.     {
  186.         nB += nG / 2;
  187.         [flatten] if (nR > -nG / 2) nR += nG / 2; else nR = 0;
  188.         nG = 0;
  189.     }
  190.     [flatten]
  191.     if (nB < 0)
  192.     {
  193.         [flatten] if (nR > -nB / 2) nR += nB / 2; else nR = 0;
  194.         [flatten] if (nG > -nB / 2) nG += nB / 2; else nG = 0;
  195.         nB = 0;
  196.     }
  197.  
  198.     [flatten]
  199.     if (nR > 1)
  200.     {
  201.         nG += (nR - 1) / 2;
  202.         nB += (nR - 1) / 2;
  203.         nR = 1;
  204.     }
  205.     [flatten]
  206.     if (nG > 1)
  207.     {
  208.         nB += (nG - 1) / 2;
  209.         [flatten] if (nR + (nG - 1) < 1) nR += (nG - 1) / 2; else nR = 1;
  210.         nG = 1;
  211.     }
  212.     [flatten]
  213.     if (nB > 1)
  214.     {
  215.         [flatten] if (nR + (nB - 1) < 1) nR += (nB - 1) / 2; else nR = 1;
  216.         [flatten] if (nG + (nB - 1) < 1) nG += (nB - 1) / 2; else nG = 1;
  217.         nB = 1;
  218.     }
  219.  
  220.     x.r = nR; x.g = nG; x.b = nB;
  221. }
  222.  
  223. void PS_AL_HGB(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 hgb : SV_Target)
  224. {
  225.     const float sampleOffsets[5] = { 0.0, 2.4347826, 4.3478260, 6.2608695, 8.1739130 };
  226.     const float sampleWeights[5] = { 0.16818994, 0.27276957, 0.111690125, 0.024067905, 0.0021112196 };
  227.  
  228.     hgb = tex2D(alInColor, texcoord) * sampleWeights[0];
  229.     hgb = float4(max(hgb.rgb - alThreshold, 0.0), hgb.a);
  230.     float step = 1.08 + (AL_t.x / 100) * 0.02;
  231.  
  232.     [flatten]
  233.     if ((texcoord.x + sampleOffsets[1] * GEMFX_PIXEL_SIZE.x) < 1.05)
  234.         hgb += tex2D(alInColor, texcoord + float2(sampleOffsets[1] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[1] * step;
  235.     [flatten]
  236.     if ((texcoord.x - sampleOffsets[1] * GEMFX_PIXEL_SIZE.x) > -0.05)
  237.         hgb += tex2D(alInColor, texcoord - float2(sampleOffsets[1] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[1] * step;
  238.  
  239.     [flatten]
  240.     if ((texcoord.x + sampleOffsets[2] * GEMFX_PIXEL_SIZE.x) < 1.05)
  241.         hgb += tex2D(alInColor, texcoord + float2(sampleOffsets[2] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[2] * step;
  242.     [flatten]
  243.     if ((texcoord.x - sampleOffsets[2] * GEMFX_PIXEL_SIZE.x) > -0.05)
  244.         hgb += tex2D(alInColor, texcoord - float2(sampleOffsets[2] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[2] * step;
  245.  
  246.     [flatten]
  247.     if ((texcoord.x + sampleOffsets[3] * GEMFX_PIXEL_SIZE.x) < 1.05)
  248.         hgb += tex2D(alInColor, texcoord + float2(sampleOffsets[3] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[3] * step;
  249.     [flatten]
  250.     if ((texcoord.x - sampleOffsets[3] * GEMFX_PIXEL_SIZE.x) > -0.05)
  251.         hgb += tex2D(alInColor, texcoord - float2(sampleOffsets[3] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[3] * step;
  252.  
  253.     [flatten]
  254.     if ((texcoord.x + sampleOffsets[4] * GEMFX_PIXEL_SIZE.x) < 1.05)
  255.         hgb += tex2D(alInColor, texcoord + float2(sampleOffsets[4] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[4] * step;
  256.     [flatten]
  257.     if ((texcoord.x - sampleOffsets[4] * GEMFX_PIXEL_SIZE.x) > -0.05)
  258.         hgb += tex2D(alInColor, texcoord - float2(sampleOffsets[4] * GEMFX_PIXEL_SIZE.x, 0.0)) * sampleWeights[4] * step;
  259. }
  260.  
  261. void PS_AL_VGB(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 vgb : SV_Target)
  262. {
  263.     const float sampleOffsets[5] = { 0.0, 2.4347826, 4.3478260, 6.2608695, 8.1739130 };
  264.     const float sampleWeights[5] = { 0.16818994, 0.27276957, 0.111690125, 0.024067905, 0.0021112196 };
  265.  
  266.     vgb = tex2D(alOutColor, texcoord) * sampleWeights[0];
  267.     vgb = float4(max(vgb.rgb - alThreshold, 0.0), vgb.a);
  268.     float step = 1.08 + (AL_t.x / 100) * 0.02;
  269.    
  270.     [flatten]
  271.     if ((texcoord.y + sampleOffsets[1] * GEMFX_PIXEL_SIZE.y) < 1.05)
  272.         vgb += tex2D(alOutColor, texcoord + float2(0.0, sampleOffsets[1] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[1] * step;
  273.     [flatten]
  274.     if ((texcoord.y - sampleOffsets[1] * GEMFX_PIXEL_SIZE.y) > -0.05)
  275.         vgb += tex2D(alOutColor, texcoord - float2(0.0, sampleOffsets[1] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[1] * step;
  276.    
  277.     [flatten]
  278.     if ((texcoord.y + sampleOffsets[2] * GEMFX_PIXEL_SIZE.y) < 1.05)
  279.         vgb += tex2D(alOutColor, texcoord + float2(0.0, sampleOffsets[2] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[2] * step;
  280.     [flatten]
  281.     if ((texcoord.y - sampleOffsets[2] * GEMFX_PIXEL_SIZE.y) > -0.05)
  282.         vgb += tex2D(alOutColor, texcoord - float2(0.0, sampleOffsets[2] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[2] * step;
  283.  
  284.     [flatten]
  285.     if ((texcoord.y + sampleOffsets[3] * GEMFX_PIXEL_SIZE.y) < 1.05)
  286.         vgb += tex2D(alOutColor, texcoord + float2(0.0, sampleOffsets[3] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[3] * step;
  287.     [flatten]
  288.     if ((texcoord.y - sampleOffsets[3] * GEMFX_PIXEL_SIZE.y) > -0.05)
  289.         vgb += tex2D(alOutColor, texcoord - float2(0.0, sampleOffsets[3] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[3] * step;
  290.  
  291.     [flatten]
  292.     if ((texcoord.y + sampleOffsets[4] * GEMFX_PIXEL_SIZE.y) < 1.05)
  293.         vgb += tex2D(alOutColor, texcoord + float2(0.0, sampleOffsets[4] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[4] * step;
  294.     [flatten]
  295.     if ((texcoord.y - sampleOffsets[4] * GEMFX_PIXEL_SIZE.y) > -0.05)
  296.         vgb += tex2D(alOutColor, texcoord - float2(0.0, sampleOffsets[4] * GEMFX_PIXEL_SIZE.y)) * sampleWeights[4] * step;
  297. }
  298.  
  299. float4 PS_AL_Magic(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  300. {
  301.     float4 base = tex2D(ReShade::BackBuffer, texcoord);
  302.     float4 high = tex2D(alInColor, texcoord);
  303.     float adapt = 0;
  304.  
  305. #if __RENDERER__ < 0xa000 && !__RESHADE_PERFORMANCE_MODE__
  306.     [flatten]
  307. #endif
  308.  
  309.     if (AL_Adaptation)
  310.     {
  311.         //DetectLow
  312.         float4 detectLow = tex2D(detectLowColor, 0.5) / 4.215;
  313.         float low = sqrt(0.241 * detectLow.r * detectLow.r + 0.691 * detectLow.g * detectLow.g + 0.068 * detectLow.b * detectLow.b);
  314.         //.DetectLow
  315.  
  316.         low = pow(low * 1.25f, 2);
  317.         adapt = low * (low + 1.0f) * alAdapt * alInt * 5.0f;
  318.  
  319.         if (alDebug)
  320.         {
  321.             float mod = (texcoord.x * 1000.0f) % 1.001f;
  322.             //mod = abs(mod - texcoord.x / 4.0f);
  323.  
  324.             if (texcoord.y < 0.01f && (texcoord.x < low * 10f && mod < 0.3f))
  325.                 return float4(1f, 0.5f, 0.3f, 0f);
  326.  
  327.             if (texcoord.y > 0.01f && texcoord.y < 0.02f && (texcoord.x < adapt / (alInt * 1.5) && mod < 0.3f))
  328.                 return float4(0.2f, 1f, 0.5f, 0f);
  329.         }
  330.     }
  331.  
  332.     high = min(0.0325f, high) * 1.15f;
  333.     float4 highOrig = high;
  334.  
  335.     float2 flipcoord = 1.0f - texcoord;
  336.     float4 highFlipOrig = tex2D(alInColor, flipcoord);
  337.     highFlipOrig = min(0.03f, highFlipOrig) * 1.15f;
  338.  
  339.     float4 highFlip = highFlipOrig;
  340.     float4 highLensSrc = high;
  341.  
  342. #if __RENDERER__ < 0xa000 && !__RESHADE_PERFORMANCE_MODE__
  343.     [flatten]
  344. #endif
  345.  
  346.     if (AL_Dirt)
  347.     {
  348.         float4 dirt = tex2D(dirtSampler, texcoord);
  349.         float4 dirtOVR = tex2D(dirtOVRSampler, texcoord);
  350.         float4 dirtOVB = tex2D(dirtOVBSampler, texcoord);
  351.  
  352.         float maxhigh = max(high.r, max(high.g, high.b));
  353.         float threshDiff = maxhigh - 3.2f;
  354.  
  355.         [flatten]
  356.         if (threshDiff > 0)
  357.         {
  358.             high.r = (high.r / maxhigh) * 3.2f;
  359.             high.g = (high.g / maxhigh) * 3.2f;
  360.             high.b = (high.b / maxhigh) * 3.2f;
  361.         }
  362.  
  363.         float4 highDirt = AL_DirtTex ? highOrig * dirt * alDirtInt : highOrig * high * alDirtInt;
  364.  
  365.         if (AL_Vibrance)
  366.         {
  367.             highDirt *= 1.0f + 0.5f * sin(AL_t.x);
  368.         }
  369.  
  370.         float highMix = highOrig.r + highOrig.g + highOrig.b;
  371.         float red = highOrig.r / highMix;
  372.         float green = highOrig.g / highMix;
  373.         float blue = highOrig.b / highMix;
  374.         highOrig = highOrig + highDirt;
  375.  
  376.         if (AL_Adaptive == 2)
  377.         {
  378.             high = high + high * dirtOVR * alDirtOVInt * green;
  379.             high = high + highDirt;
  380.             high = high + highOrig * dirtOVB * alDirtOVInt * blue;
  381.             high = high + highOrig * dirtOVR * alDirtOVInt* red;
  382.         }
  383.         else if (AL_Adaptive == 1)
  384.         {
  385.             high = high + highDirt;
  386.             high = high + highOrig * dirtOVB * alDirtOVInt;
  387.         }
  388.         else
  389.         {
  390.             high = high + highDirt;
  391.             high = high + highOrig * dirtOVR * alDirtOVInt;
  392.         }
  393.  
  394.         highLensSrc = high * 85f * pow(1.25f - (abs(texcoord.x - 0.5f) + abs(texcoord.y - 0.5f)), 2);
  395.     }
  396.  
  397.     float origBright = max(highLensSrc.r, max(highLensSrc.g, highLensSrc.b));
  398.     float maxOrig = max((1.8f * alLensThresh) - pow(origBright * (0.5f - abs(texcoord.x - 0.5f)), 4), 0.0f);
  399.     float smartWeight = maxOrig * max(abs(flipcoord.x - 0.5f), 0.3f * abs(flipcoord.y - 0.5f)) * (2.2 - 1.2 * (abs(flipcoord.x - 0.5f))) * alLensInt;
  400.     smartWeight = min(0.85f, max(0, AL_Adaptation ? smartWeight - adapt : smartWeight));
  401.  
  402. #if __RENDERER__ < 0xa000 && !__RESHADE_PERFORMANCE_MODE__
  403.     [flatten]
  404. #endif
  405.  
  406.     if (AL_Lens)
  407.     {
  408.         float4 lensDB = tex2D(lensDBSampler, texcoord);
  409.         float4 lensDB2 = tex2D(lensDB2Sampler, texcoord);
  410.         float4 lensDOV = tex2D(lensDOVSampler, texcoord);
  411.         float4 lensDUV = tex2D(lensDUVSampler, texcoord);
  412.  
  413.         float4 highLens = highFlip * lensDB * 0.7f * smartWeight;
  414.         high += highLens;
  415.  
  416.         highLens = highFlipOrig * lensDUV * 1.15f * smartWeight;
  417.         highFlipOrig += highLens;
  418.         high += highLens;
  419.  
  420.         highLens = highFlipOrig * lensDB2 * 0.7f * smartWeight;
  421.         highFlipOrig += highLens;
  422.         high += highLens;
  423.  
  424.         highLens = highFlipOrig * lensDOV * 1.15f * smartWeight / 2f + highFlipOrig * smartWeight / 2f;
  425.         highFlipOrig += highLens;
  426.         high += highLens;
  427.     }
  428.  
  429.     float dither = 0.15 * (1.0 / (pow(2, 10.0) - 1.0));
  430.     dither = lerp(2.0 * dither, -2.0 * dither, frac(dot(texcoord, ReShade::ScreenSize * float2(1.0 / 16.0, 10.0 / 36.0)) + 0.25));
  431.  
  432.     if (all(base.xyz == 1.0))
  433.     {
  434.         return 1.0;
  435.     }
  436.  
  437. #if __RENDERER__ < 0xa000 && !__RESHADE_PERFORMANCE_MODE__
  438.     [flatten]
  439. #endif
  440.  
  441.     if (AL_Adaptation && AL_Dither)
  442.     {
  443.         base.xyz *= max(0.0f, (1.0f - adapt * 0.75f * alAdaptBaseMult * pow((1.0f - (base.x + base.y + base.z) / 3), alAdaptBaseBlackLvL)));
  444.         float4 highSampleMix = (1.0 - ((1.0 - base) * (1.0 - high * 1.0))) + dither;
  445.         float4 baseSample = lerp(base, highSampleMix, max(0.0f, alInt - adapt));
  446.         float baseSampleMix = baseSample.r + baseSample.g + baseSample.b;
  447.         return baseSampleMix > 0.008 ? baseSample : lerp(base, highSampleMix, max(0.0f, (alInt - adapt) * 0.85f) * baseSampleMix);
  448.     }
  449.  
  450.     if (AL_Adaptation)
  451.     {
  452.         base.xyz *= max(0.0f, (1.0f - adapt * 0.75f * alAdaptBaseMult * pow((1.0f - (base.x + base.y + base.z) / 3), alAdaptBaseBlackLvL)));
  453.         float4 highSampleMix = (1.0 - ((1.0 - base) * (1.0 - high * 1.0)));
  454.         float4 baseSample = lerp(base, highSampleMix, max(0.0f, alInt - adapt));
  455.         float baseSampleMix = baseSample.r + baseSample.g + baseSample.b;
  456.         return baseSampleMix > 0.008 ? baseSample : lerp(base, highSampleMix, max(0.0f, (alInt - adapt) * 0.85f) * baseSampleMix);
  457.     }
  458.  
  459.     if (AL_Dither)
  460.     {
  461.         float4 highSampleMix = (1.0 - ((1.0 - base) * (1.0 - high * 1.0))) + dither + adapt;
  462.         float4 baseSample = lerp(base, highSampleMix, alInt);
  463.         float baseSampleMix = baseSample.r + baseSample.g + baseSample.b;
  464.         return baseSampleMix > 0.008 ? baseSample : lerp(base, highSampleMix, max(0.0f, alInt * 0.85f) * baseSampleMix);
  465.     }
  466.  
  467.     float4 highSampleMix = (1.0 - ((1.0 - base) * (1.0 - high * 1.0))) + adapt;
  468.     float4 baseSample = lerp(base, highSampleMix, alInt);
  469.     float baseSampleMix = baseSample.r + baseSample.g + baseSample.b;
  470.     return baseSampleMix > 0.008 ? baseSample : lerp(base, highSampleMix, max(0.0f, alInt * 0.85f) * baseSampleMix);
  471.  
  472. }
  473.  
  474. technique AmbientLight
  475. {
  476.     pass AL_DetectInt
  477.     {
  478.         VertexShader = PostProcessVS;
  479.         PixelShader = PS_AL_DetectInt;
  480.         RenderTarget = detectIntTex;
  481.     }
  482.     pass AL_DetectLow
  483.     {
  484.         VertexShader = PostProcessVS;
  485.         PixelShader = PS_AL_DetectLow;
  486.         RenderTarget = detectLowTex;
  487.     }
  488.     pass AL_DetectHigh
  489.     {
  490.         VertexShader = PostProcessVS;
  491.         PixelShader = PS_AL_DetectHigh;
  492.         RenderTarget = alInTex;
  493.     }
  494.  
  495. #define PASS_AL_H(i) \
  496.     pass AL_H##i \
  497.     { \
  498.         VertexShader = PostProcessVS; \
  499.         PixelShader = PS_AL_HGB; \
  500.         RenderTarget = alOutTex; \
  501.     }
  502. #define PASS_AL_V(i) \
  503.     pass AL_V##i \
  504.     { \
  505.         VertexShader = PostProcessVS; \
  506.         PixelShader = PS_AL_VGB; \
  507.         RenderTarget = alInTex; \
  508.     }
  509.  
  510.     PASS_AL_H(1)
  511.     PASS_AL_V(1)
  512.     PASS_AL_H(2)
  513.     PASS_AL_V(2)
  514.     PASS_AL_H(3)
  515.     PASS_AL_V(3)
  516.     PASS_AL_H(4)
  517.     PASS_AL_V(4)
  518.     PASS_AL_H(5)
  519.     PASS_AL_V(5)
  520.     PASS_AL_H(6)
  521.     PASS_AL_V(6)
  522.     PASS_AL_H(7)
  523.     PASS_AL_V(7)
  524.     PASS_AL_H(8)
  525.     PASS_AL_V(8)
  526.     PASS_AL_H(9)
  527.     PASS_AL_V(9)
  528.     PASS_AL_H(10)
  529.     PASS_AL_V(10)
  530.     PASS_AL_H(11)
  531.     PASS_AL_V(11)
  532.     PASS_AL_H(12)
  533.     PASS_AL_V(12)
  534.  
  535.     pass AL_Magic
  536.     {
  537.         VertexShader = PostProcessVS;
  538.         PixelShader = PS_AL_Magic;
  539.     }
  540. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement