daily pastebin goal
34%
SHARE
TWEET

MXAO 1.5.7r

a guest Oct 8th, 2016 1,165 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. // Ambient Obscurance with Indirect Lighting "MXAO" 1.5.7r by Marty McFly
  6. // Copyright © 2008-2016 Marty McFly
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8.  
  9. #define fMXAOAmbientOcclusionAmount     1.0 //[0.0 to 2.0]   Linearly increases AO intensity. Can cause pitch black clipping if set too high.
  10. #define bMXAOIndirectLightingEnable     0   //[0 or 1]   Enables Indirect Lighting calculation. Will cause a major fps hit.
  11. #define fMXAOIndirectLightingAmount     1.0 //[0.0 to 8.0]   Linearly increases IL intensity.
  12. #define fMXAOIndirectLightingSaturation     1.0 //[0.0 to 3.0]   Boosts IL saturation for more pronounced effect.
  13.  
  14. #define fMXAOSampleRadius           4.5 //[0.5 to 20.0]  Sample radius of GI, higher values drop performance. Heavily depending on game, GTASA: 10 = GTA V: 40ish
  15. #define iMXAOSampleCount            36  //[16 to 254]    Amount of MXAO samples. Higher means more accurate and less noisy AO at the cost of fps.
  16. #define bMXAOSmartSamplingEnable        0   //[0 or 1]   Enables smart sample count reduction for far areas. May look ugly when low sample count (16 or less) is used, turn it off then.
  17. #define iMXAOBayerDitherLevel           7   //[2 to 8]   2^ditherlevel: size of AO sampling pattern size. Lower values mean less distinctive sample dirs and haloing.
  18. #define fMXAONormalBias             0.2 //[0.0 to 0.4]   Normals bias to reduce self-occlusion of surfaces that have a low angle to each other.
  19. #define bMXAOPerPixelNormalsEnable      1   //[0 or 1]   TEST! Enables per pixel normals derived from color input so surfaces get some relief instead of being 100% flat.
  20. #define bMXAOBackfaceCheckEnable        0   //[0 or 1]   For indirect lighting only! Enables back face check so surfaces facing away from the source position don't cast light. It comes with a slight fps drop.
  21. #define bMXAOBoundaryCheckEnable        0   //[0 or 1]   Enables screen boundary check for samples. Can be useful to remove odd behaviour with too high sample radius / objects very close to camera. It comes with a slight fps drop.
  22. #define bMXAOLowPrecisionEnable         1   //[0 or 1]   Enables lower bit mode for AO source texture (R32F vs R16F). This will improve performance but may introduce some artifacts at distant objects.
  23. #define fMXAOBlurSharpness          1.0 //[0.0 to 3.0]   AO sharpness, higher means more sharp geometry edges but noisier AO, less means smoother AO but blurry in the distance.
  24. #define fMXAOBlurSteps              3   //[2 to 7]   Offset count for AO smoothening. Higher means more smooth AO but also blurrier AO.
  25. #define fMXAOMipLevelIL             2   //[0 to 4]       Miplevel of IL texture. 0 = fullscreen, 1 = 1/2 screen width/height, 2 = 1/4 screen width/height and so forth.
  26. #define fMXAOMipLevelAO             0   //[0 to 2]   Miplevel of AO texture. 0 = fullscreen, 1 = 1/2 screen width/height, 2 = 1/4 screen width/height and so forth. Best results: IL MipLevel = AO MipLevel + 2
  27.  
  28. #define bMXAODebugViewEnable            0   //[0 or 1]   Enables raw AO/IL output for debugging and tuning purposes.
  29.  
  30. //custom variables, depleted after Framework implementation.
  31. #define AO_FADE____START        0.6     //[0.0 to 1.0]   Depth at which AO starts to fade out. 0.0 = camera, 1.0 = sky. Must be lower than AO fade end.
  32. #define AO_FADE____END          0.9     //[0.0 to 1.0]   Depth at which AO completely fades out. 0.0 = camera, 1.0 = sky. Must be higher than AO fade start.
  33. #define MXAO_TOGGLEKEY          0x20        //SPACEBAR
  34.  
  35. #pragma reshade showfps
  36.  
  37. uniform float  Timer < source = "timer"; >;
  38.  
  39. #define PixelSize   float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
  40. //textures
  41. texture2D texColor : COLOR;
  42. texture2D texDepth : DEPTH;
  43. texture2D texLOD    { Width = BUFFER_WIDTH;               Height = BUFFER_HEIGHT;               Format = RGBA8; MipLevels = 5+fMXAOMipLevelIL;};
  44.  
  45. #if(bMXAOLowPrecisionEnable != 0)
  46. texture2D texDepthLOD   { Width = BUFFER_WIDTH;               Height = BUFFER_HEIGHT;               Format = R16F;  MipLevels = 5+fMXAOMipLevelAO;};
  47. #else
  48. texture2D texDepthLOD   { Width = BUFFER_WIDTH;               Height = BUFFER_HEIGHT;               Format = R32F;  MipLevels = 5+fMXAOMipLevelAO;};
  49. #endif
  50.  
  51. #if(bMXAOBackfaceCheckEnable != 0)
  52. texture2D texNormal { Width = BUFFER_WIDTH;                           Height = BUFFER_HEIGHT;                   Format = RGBA8; MipLevels = 5+fMXAOMipLevelIL;};
  53. #else
  54. texture2D texNormal { Width = BUFFER_WIDTH;                           Height = BUFFER_HEIGHT;                   Format = RGBA8;                   };
  55. #endif
  56.  
  57. texture2D texSSAO   { Width = BUFFER_WIDTH;                   Height = BUFFER_HEIGHT;                       Format = RGBA8;                   };
  58.  
  59. sampler2D SamplerColor
  60. {
  61.     Texture = texColor;
  62.     MinFilter = LINEAR;
  63.     MagFilter = LINEAR;
  64.     MipFilter = LINEAR;
  65.     AddressU = Clamp;
  66.     AddressV = Clamp;
  67. };
  68.  
  69. sampler2D SamplerDepth
  70. {
  71.     Texture = texDepth;
  72.     MinFilter = LINEAR;
  73.     MagFilter = LINEAR;
  74.     MipFilter = LINEAR;
  75.     AddressU = Clamp;
  76.     AddressV = Clamp;
  77. };
  78.  
  79. sampler2D SamplerLOD
  80. {
  81.     Texture = texLOD;
  82.     MinFilter = LINEAR;
  83.     MagFilter = LINEAR;
  84.     MipFilter = LINEAR;
  85.     AddressU = Clamp;
  86.     AddressV = Clamp;
  87. };
  88.  
  89. sampler2D SamplerDepthLOD
  90. {
  91.     Texture = texDepthLOD;
  92.     MinFilter = POINT;
  93.     MagFilter = POINT;
  94.     MipFilter = POINT;
  95.     AddressU = Clamp;
  96.     AddressV = Clamp;
  97. };
  98.  
  99. sampler2D SamplerNormal
  100. {
  101.     Texture = texNormal;
  102.     MinFilter = LINEAR;
  103.     MagFilter = LINEAR;
  104.     MipFilter = LINEAR;
  105.     AddressU = Clamp;
  106.     AddressV = Clamp;
  107. };
  108.  
  109. sampler2D SamplerSSAO
  110. {
  111.     Texture = texSSAO;
  112.     MinFilter = LINEAR;
  113.     MagFilter = LINEAR;
  114.     MipFilter = LINEAR;
  115.     AddressU = Clamp;
  116.     AddressV = Clamp;
  117. };
  118.  
  119. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  120. //
  121. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  122.  
  123. void VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
  124. {
  125.     texcoord.x = (id == 2) ? 2.0 : 0.0;
  126.     texcoord.y = (id == 1) ? 2.0 : 0.0;
  127.     pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  128. }
  129.  
  130. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  131. //
  132. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  133.  
  134. #define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0
  135.  
  136. float GetLinearDepth(float2 coords)
  137. {
  138.     float depth = tex2Dlod(SamplerDepth, float4(coords.xy,0,0)).x;
  139.     depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * RESHADE_DEPTH_LINEARIZATION_FAR_PLANE + depth;
  140.     return depth;
  141. }
  142.  
  143. float3 GetPosition(float2 coords)
  144. {
  145.     float EyeDepth = GetLinearDepth(coords.xy)*RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
  146.     return float3((coords.xy * 2.0 - 1.0)*EyeDepth,EyeDepth);
  147. }
  148.  
  149. float3 GetPositionLOD(float2 coords, int mipLevel)
  150. {
  151.     float EyeDepth = tex2Dlod(SamplerDepthLOD, float4(coords.xy,0,mipLevel)).x;
  152.     return float3((coords.xy * 2.0 - 1.0)*EyeDepth,EyeDepth);
  153. }
  154.  
  155. float3 GetNormalFromDepth(float2 coords)
  156. {
  157.     float3 centerPos = GetPosition(coords.xy);
  158.     float2 offs = PixelSize.xy*1.0;
  159.     float3 ddx1 = GetPosition(coords.xy + float2(offs.x, 0)) - centerPos;
  160.     float3 ddx2 = centerPos - GetPosition(coords.xy + float2(-offs.x, 0));
  161.  
  162.     float3 ddy1 = GetPosition(coords.xy + float2(0, offs.y)) - centerPos;
  163.     float3 ddy2 = centerPos - GetPosition(coords.xy + float2(0, -offs.y));
  164.  
  165.     ddx1 = lerp(ddx1, ddx2, abs(ddx1.z) > abs(ddx2.z));
  166.     ddy1 = lerp(ddy1, ddy2, abs(ddy1.z) > abs(ddy2.z));
  167.  
  168.     float3 normal = cross(ddy1, ddx1);
  169.    
  170.     return normalize(normal);
  171. }
  172.  
  173. float3 GetNormalFromColor(float2 coords, float2 offset, float scale, float sharpness)
  174. {
  175.     const float3 lumCoeff = float3(0.299,0.587,0.114);
  176.  
  177.         float hpx = dot(tex2Dlod(SamplerColor, float4(coords + float2(offset.x,0.0),0,0)).xyz,lumCoeff) * scale;
  178.         float hmx = dot(tex2Dlod(SamplerColor, float4(coords - float2(offset.x,0.0),0,0)).xyz,lumCoeff) * scale;
  179.         float hpy = dot(tex2Dlod(SamplerColor, float4(coords + float2(0.0,offset.y),0,0)).xyz,lumCoeff) * scale;
  180.         float hmy = dot(tex2Dlod(SamplerColor, float4(coords - float2(0.0,offset.y),0,0)).xyz,lumCoeff) * scale;
  181.  
  182.         float dpx = GetLinearDepth(coords + float2(offset.x,0.0));
  183.         float dmx = GetLinearDepth(coords - float2(offset.x,0.0));
  184.         float dpy = GetLinearDepth(coords + float2(0.0,offset.y));
  185.         float dmy = GetLinearDepth(coords - float2(0.0,offset.y));
  186.  
  187.     float2 xymult = float2(abs(dmx - dpx), abs(dmy - dpy)) * sharpness;
  188.     xymult = max(0.0, 1.0 - xymult);
  189.        
  190.         float ddx = (hmx - hpx) / (2.0 * offset.x) * xymult.x;
  191.         float ddy = (hmy - hpy) / (2.0 * offset.y) * xymult.y;
  192.    
  193.         return normalize(float3(ddx, ddy, 1.0));
  194. }
  195.  
  196. float3 GetBlendedNormals(float3 n1, float3 n2)
  197. {
  198.     //return normalize(float3(n1.xy*n2.z + n2.xy*n1.z, n1.z*n2.z));
  199.     n1 += float3( 0, 0, 1);
  200.     n2 *= float3(-1, -1, 1);
  201.     return n1*dot(n1, n2)/n1.z - n2;
  202. }
  203.  
  204. float4 GetBlurFactors(float2 coords)
  205. {
  206.     return float4(tex2Dlod(SamplerNormal, float4(coords.xy,0,0)).xyz*2.0-1.0,GetLinearDepth(coords.xy));
  207. }
  208.  
  209. float GetBlurWeight(float O, float4 z, float4 z0)
  210. {
  211.     //GFSDK with my normal angle consideration
  212.     const float BlurSigma       = fMXAOBlurSteps+1.0;
  213.     const float BlurFalloff     = 1.0 / (2.0*BlurSigma*BlurSigma);
  214.           float BlurFresnelFactor   = saturate(min(-z0.z,-z.z));
  215.  
  216.     //we don't need any sigma etc for normals, angle is important
  217.     float DeltaN = (1.0 + dot(-z.xyz,z0.xyz))*100.0*fMXAOBlurSharpness;
  218.     float DeltaZ = (z.w-z0.w)*1000.0*BlurFresnelFactor*fMXAOBlurSharpness;
  219.     return exp2(-O*O*BlurFalloff - DeltaZ*DeltaZ - DeltaN*DeltaN);
  220. }
  221.  
  222. float GetBayerFromCoordLevel(float2 pixelpos, int maxLevel)
  223. {
  224.     float finalBayer = 0.0;
  225.  
  226.     for(float i = 1-maxLevel; i<= 0; i++)
  227.     {
  228.         float bayerSize = exp2(i);
  229.             float2 bayerCoord = floor(pixelpos * bayerSize) % 2.0;
  230.         float bayer = 2.0 * bayerCoord.x - 4.0 * bayerCoord.x * bayerCoord.y + 3.0 * bayerCoord.y;
  231.         finalBayer += exp2(2.0*(i+maxLevel))* bayer;
  232.     }
  233.  
  234.     float finalDivisor = exp2(2.0 * maxLevel + 2.0)- 4.0;
  235.     return finalBayer/ finalDivisor;
  236. }
  237.  
  238. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  239. //
  240. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  241.  
  242. void PS_AO_Pre(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 color : SV_Target0, out float4 depth : SV_Target1, out float4 normal : SV_Target2)
  243. {
  244.     color = tex2D(SamplerColor, texcoord.xy);
  245.     depth = GetLinearDepth(texcoord.xy)*RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
  246.     normal.xyz = GetNormalFromDepth(texcoord.xy).xyz;
  247.  
  248.     #if(bMXAOPerPixelNormalsEnable != 0)
  249.         float3 ppnormal = GetNormalFromColor(texcoord.xy, 70.0 * PixelSize.xy / depth.x, 0.005, 1000.0);
  250.         normal.xyz = GetBlendedNormals(normal.xyz,ppnormal.xyz);
  251.     #endif
  252.  
  253.     normal.xyz = normal.xyz * 0.5 + 0.5;
  254.     normal.w = GetBayerFromCoordLevel(vpos.xy,iMXAOBayerDitherLevel);
  255. }
  256.  
  257. void PS_AO_Gen(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
  258. {
  259.     float4 normalSample = tex2D(SamplerNormal, texcoord.xy);
  260.     float3 ScreenSpaceNormals = normalSample.xyz * 2.0 - 1.0;
  261.     float3 ScreenSpacePosition = GetPositionLOD(texcoord.xy, 0);
  262.  
  263.     float scenedepth = ScreenSpacePosition.z / RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
  264.     ScreenSpacePosition += ScreenSpaceNormals * scenedepth;
  265.  
  266. #if(bMXAOSmartSamplingEnable != 0)
  267.     float numSamples = lerp(iMXAOSampleCount,12,scenedepth / AO_FADE____END);
  268. #else
  269.     float numSamples = iMXAOSampleCount;
  270. #endif
  271.  
  272.     float SampleRadiusScaled  = fMXAOSampleRadius / (numSamples * ScreenSpacePosition.z * 0.625);
  273.  
  274.     float rotAngle = normalSample.w;
  275.     float mipFactor = SampleRadiusScaled * numSamples * 19.7392088;
  276.        
  277.     float2 currentVector;
  278.     sincos(6.283*rotAngle, currentVector.y, currentVector.x);
  279.     currentVector *= SampleRadiusScaled;
  280.     static const float fNegInvR2 = -1.0/(fMXAOSampleRadius*fMXAOSampleRadius);
  281.     static const float Aspect = PixelSize.y/PixelSize.x;
  282.  
  283.     res = 0.0;
  284.     [loop]
  285.         for (int iSample=1; iSample <= numSamples; iSample++)  
  286.     {
  287.         currentVector = mul(currentVector.xy, float2x2(0.575,0.81815,-0.81815,0.575)); 
  288.         float2 currentOffset = texcoord.xy + currentVector.xy * iSample;
  289.  
  290.         #if(bMXAOBoundaryCheckEnable != 0)
  291.         [branch]
  292.         if(all(saturate(-currentOffset * currentOffset + currentOffset)))
  293.         {
  294.         #endif
  295.             float mipLevel = clamp((int)floor(log2(mipFactor*iSample)) - 3, fMXAOMipLevelAO, 5);
  296.  
  297.             float3 occlVec      = -ScreenSpacePosition + GetPositionLOD(currentOffset.xy, mipLevel);
  298.             occlVec.x          *= Aspect;
  299.             float occlDistanceRcp   = rsqrt(dot(occlVec,occlVec));
  300.             float SurfaceAngle  = dot(occlVec, ScreenSpaceNormals)*occlDistanceRcp;
  301.            
  302.             float fAO = saturate(1.0 + fNegInvR2/occlDistanceRcp)  * saturate(SurfaceAngle - fMXAONormalBias);
  303.  
  304.             #if(bMXAOIndirectLightingEnable != 0)
  305.                 float3 fIL = tex2Dlod(SamplerLOD, float4(currentOffset,0,mipLevel + fMXAOMipLevelIL)).xyz;
  306.                 #if(bMXAOBackfaceCheckEnable != 0)
  307.                     float3 offsetNormals = tex2Dlod(SamplerNormal, float4(currentOffset,0,mipLevel + fMXAOMipLevelIL)).xyz * 2.0 - 1.0;
  308.                     float facingtoSource = dot(-occlVec,offsetNormals)*occlDistanceRcp;
  309.                     fIL *=smoothstep(-0.5,0.0,facingtoSource);
  310.                 #endif
  311.                 res.w += fAO*saturate(1-dot(fIL,float3(0.299,0.587,0.114)));
  312.                 res.xyz += fIL*fAO;
  313.             #else
  314.                 res.w += fAO;
  315.             #endif
  316.  
  317.         #if(bMXAOBoundaryCheckEnable != 0)
  318.         }
  319.         #endif 
  320.     }
  321.  
  322.     res = (AO_FADE____END < scenedepth) ? 0.0 : res / (0.05 * (1.0-fMXAONormalBias)*numSamples*fMXAOSampleRadius);
  323. }
  324.  
  325. void PS_AO_Blur1(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
  326. {
  327.     //discrete sampling, I could either make this one *1.0 and in the loop every sample * 2.0
  328.     //or do it like this and save that multiplication inside the loop.
  329.     float4 total_ao         = tex2D(SamplerSSAO, texcoord.xy) * 0.5;
  330.     float total_weight      = 0.5;
  331.     float4 center_factor        = GetBlurFactors(texcoord.xy);
  332.  
  333.     [unroll]
  334.     for(float x = 1.0; x <= fMXAOBlurSteps; x++)
  335.     {
  336.         float2 blurdir = float2(2.0 * x - 0.5,0.0);
  337.         float2 blurcoord =  blurdir * PixelSize.xy + texcoord.xy;
  338.  
  339.         float4 temp_ao = tex2Dlod(SamplerSSAO, float4(blurcoord,0,0)); 
  340.         float4 temp_factor = GetBlurFactors(blurcoord);
  341.  
  342.         float temp_weight = GetBlurWeight(blurdir.x, temp_factor, center_factor);
  343.         total_ao += temp_ao * temp_weight;
  344.         total_weight += temp_weight;
  345.  
  346.         blurcoord =  -blurdir * PixelSize.xy + texcoord.xy;
  347.         temp_ao = tex2Dlod(SamplerSSAO, float4(blurcoord,0,0));
  348.         temp_factor = GetBlurFactors(blurcoord);
  349.  
  350.         temp_weight = GetBlurWeight(blurdir.x, temp_factor, center_factor);
  351.         total_ao += temp_ao * temp_weight;
  352.         total_weight += temp_weight;
  353.     }
  354.  
  355.     total_ao /= total_weight;
  356.     res = total_ao;
  357. }
  358.  
  359. void PS_AO_Blur2(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
  360. {
  361.     float4 total_ao         = tex2D(SamplerColor, texcoord.xy) * 0.5;
  362.     float total_weight      = 0.5;
  363.     float4 center_factor        = GetBlurFactors(texcoord.xy);
  364.  
  365.     [unroll]
  366.     for(float y = 1.0; y <= fMXAOBlurSteps; y++)
  367.     {
  368.         float2 blurdir = float2(0.0, 2.0 * y - 0.5);
  369.         float2 blurcoord = blurdir * PixelSize.xy + texcoord.xy;
  370.  
  371.         float4 temp_ao = tex2Dlod(SamplerColor, float4(blurcoord,0,0));
  372.         float4 temp_factor = GetBlurFactors(blurcoord);
  373.  
  374.         float temp_weight = GetBlurWeight(blurdir.y, temp_factor, center_factor);
  375.         total_ao += temp_ao * temp_weight;
  376.         total_weight += temp_weight;
  377.  
  378.         blurcoord = -blurdir * PixelSize.xy + texcoord.xy;
  379.         temp_ao = tex2Dlod(SamplerColor, float4(blurcoord,0,0));   
  380.         temp_factor = GetBlurFactors(blurcoord);
  381.  
  382.         temp_weight = GetBlurWeight(blurdir.y, temp_factor, center_factor);
  383.         total_ao += temp_ao * temp_weight;
  384.         total_weight += temp_weight;
  385.     }
  386.  
  387.     total_ao /= total_weight;
  388.     float4 mxao = saturate(total_ao);
  389.  
  390.     float scenedepth = GetLinearDepth(texcoord.xy); //might change center_factor so better fetch depth directly here.
  391.     float4 color = max(0.0,tex2Dlod(SamplerLOD, float4(texcoord.xy,0,0))); //get miplevel 0 which was shifted prior in MipLODBias.
  392.     float colorgray = dot(color.xyz,float3(0.299,0.587,0.114));
  393.  
  394.     mxao.xyz  = lerp(dot(mxao.xyz,float3(0.299,0.587,0.114)),mxao.xyz,fMXAOIndirectLightingSaturation) * fMXAOIndirectLightingAmount;
  395.     mxao.w    = 1.0-pow(1.0-mxao.w, fMXAOAmbientOcclusionAmount * 2.0);
  396.  
  397. #if(bMXAODebugViewEnable == 0)
  398.     mxao    = lerp(mxao, 0.0, pow(colorgray,2.0));
  399. #endif
  400.     mxao.w    = lerp(mxao.w, 0.0,smoothstep(AO_FADE____START, AO_FADE____END, scenedepth));             //AO FADEOUT
  401.     mxao.xyz  = lerp(mxao.xyz,0.0,smoothstep(AO_FADE____START*0.5, AO_FADE____END*0.5, scenedepth));        //AO FADEOUT //IL can look really bad on far objects.
  402.  
  403.     float3 GI = mxao.w - mxao.xyz*2;
  404.     GI = max(0.0,1-GI);
  405.  
  406.     color.xyz *= GI;
  407.     color.xyz += mxao.xyz * 0.05; //pitch black surfaces.
  408.  
  409.  
  410. #if(bMXAODebugViewEnable != 0)
  411.     #if(bMXAOIndirectLightingEnable != 0)  
  412.         color.xyz = GI*0.5;
  413.     #else
  414.         color.xyz = GI;
  415.     #endif
  416. #endif
  417.     res = color;
  418. }
  419.  
  420. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  421. //
  422. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  423.  
  424. technique PostProcess < bool enabled = 1;toggle = MXAO_TOGGLEKEY;>
  425. {
  426.     pass P0
  427.     {
  428.         VertexShader = VS_PostProcess;
  429.         PixelShader  = PS_AO_Pre;
  430.         RenderTarget0 = texLOD;
  431.         RenderTarget1 = texDepthLOD;
  432.         RenderTarget2 = texNormal;
  433.     }
  434.     pass P1
  435.     {
  436.         VertexShader = VS_PostProcess;
  437.         PixelShader  = PS_AO_Gen;
  438.         RenderTarget = texSSAO;
  439.     }
  440.     pass P2_0
  441.     {
  442.         VertexShader = VS_PostProcess;
  443.         PixelShader  = PS_AO_Blur1;
  444.     }
  445.     pass P2
  446.     {
  447.         VertexShader = VS_PostProcess;
  448.         PixelShader  = PS_AO_Blur2;
  449.     }
  450. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top