Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*=============================================================================
- ReShade 4 effect file
- github.com/martymcmodding
- Support me:
- paypal.me/mcflypg
- patreon.com/mcflypg
- Path Traced Global Illumination
- by Marty McFly / P.Gilcher
- part of qUINT shader library for ReShade 4
- CC BY-NC-ND 3.0 licensed.
- =============================================================================*/
- /*=============================================================================
- Preprocessor settings
- =============================================================================*/
- //these two are required if I want to reuse the MXAO textures properly
- #ifndef MXAO_MIPLEVEL_AO
- #define MXAO_MIPLEVEL_AO 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
- #endif
- #ifndef MXAO_MIPLEVEL_IL
- #define MXAO_MIPLEVEL_IL 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.
- #endif
- #ifndef INFINITE_BOUNCES
- #define INFINITE_BOUNCES 0 //[0 or 1] If enabled, path tracer samples __7712ious frame GI as well, causing a feedback loop to simulate secondary bounces, causing a more widespread GI.
- #endif
- #ifndef SPATIAL_FILTER
- #define SPATIAL_FILTER 1 //[0 or 1] If enabled, final GI is filtered for a less noisy but also less precise result. Enabled by default.
- #endif
- /*=============================================================================
- UI Uniforms
- =============================================================================*/
- uniform float RT_SIZE_SCALE <
- ui_type = "drag";
- ui_min = 0.5; ui_max = 1.0;
- ui_step = 0.5;
- ui_label = "GI Render Resolution Scale";
- ui_category = "Global";
- > = 1.0;
- uniform float FILTER_SENSITIVITY <
- ui_type = "drag";
- ui_min = 0.01; ui_max = 10.0;
- ui_step = 0.01;
- ui_label = "GI Filter Sensitivity";
- ui_category = "Global";
- > = 1.0;
- uniform float RT_SAMPLE_RADIUS <
- ui_type = "drag";
- ui_min = 0.5; ui_max = 20.0;
- ui_step = 0.01;
- ui_label = "Ray Length";
- ui_tooltip = "Maximum ray length, directly affects\nthe spread radius of shadows / indirect lighing";
- ui_category = "Path Tracing";
- > = 5.0;
- uniform int RT_RAY_AMOUNT <
- ui_type = "slider";
- ui_min = 1; ui_max = 20;
- ui_label = "Ray Amount";
- ui_category = "Path Tracing";
- > = 3;
- uniform int RT_RAY_STEPS <
- ui_type = "slider";
- ui_min = 5; ui_max = 20;
- ui_label = "Ray Step Amount";
- ui_category = "Path Tracing";
- > = 10;
- uniform bool RT_RAY_ISOMETRIC_SAMPLING
- <
- ui_label = "Enable Isometric Rays";
- > = false;
- uniform float RT_Z_THICKNESS <
- ui_type = "drag";
- ui_min = 0.0; ui_max = 10.0;
- ui_step = 0.01;
- ui_label = "Z Thickness";
- ui_tooltip = "The shader can't know how thick objects are, since it only\nsees the side the camera faces and has to assume a fixed value.\n\nUse this parameter to remove halos around thin objects.";
- ui_category = "Path Tracing";
- > = 1.0;
- uniform float RT_AO_AMOUNT <
- ui_type = "drag";
- ui_min = 0; ui_max = 2.0;
- ui_step = 0.01;
- ui_label = "Ambient Occlusion Intensity";
- ui_category = "Blending";
- > = 1.0;
- uniform float RT_IL_AMOUNT <
- ui_type = "drag";
- ui_min = 0; ui_max = 7.0;
- ui_step = 0.01;
- ui_label = "Indirect Lighting Intensity";
- ui_category = "Blending";
- > = 4.0;
- #if INFINITE_BOUNCES != 0
- uniform float RT_IL_BOUNCE_WEIGHT <
- ui_type = "drag";
- ui_min = 0; ui_max = 5.0;
- ui_step = 0.01;
- ui_label = "Next Bounce Weight";
- ui_category = "Blending";
- > = 0.0;
- #endif
- uniform float2 RT_FADE_DEPTH <
- ui_type = "drag";
- ui_label = "Fade Out Start / End";
- ui_min = 0.00; ui_max = 1.00;
- ui_tooltip = "Distance where GI starts to fade out | is completely faded out.";
- ui_category = "Blending";
- > = float2(0.0, 0.5);
- uniform int RT_DEBUG_VIEW <
- ui_type = "radio";
- ui_label = "Enable Debug View";
- ui_items = "None\0AO/IL channel\0";
- ui_tooltip = "Different debug outputs";
- ui_category = "Debug";
- > = 0;
- uniform float3 SKY_COLOR <
- ui_type = "color";
- ui_label = "Sky Color";
- ui_category = "Path Tracing";
- > = float3(0.0, 0.0, 0.0);
- /*
- uniform float4 tempF1 <
- ui_type = "drag";
- ui_min = -100.0;
- ui_max = 100.0;
- > = float4(1,1,1,1);
- uniform float4 tempF2 <
- ui_type = "drag";
- ui_min = -100.0;
- ui_max = 100.0;
- > = float4(1,1,1,1);
- */
- /*=============================================================================
- Textures, Samplers, Globals
- =============================================================================*/
- #include "qUINT_common.fxh"
- uniform int framecount < source = "framecount"; >;
- texture ZTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R16F; MipLevels = 3 + MXAO_MIPLEVEL_AO;};
- texture NormalTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; MipLevels = 3 + MXAO_MIPLEVEL_IL;};
- texture GITex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
- texture GITexPrev { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
- texture GITexTemp { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
- texture GBufferTexPrev { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
- texture JitterTex < source = "LDR_RGB1_18.png"; > { Width = 32; Height = 32; Format = RGBA8; };
- sampler2D sZTex { Texture = ZTex; };
- sampler2D sNormalTex { Texture = NormalTex; };
- sampler2D sGITex { Texture = GITex; };
- sampler2D sGITexPrev { Texture = GITexPrev; };
- sampler2D sGITexTemp { Texture = GITexTemp; };
- sampler2D sGBufferTexPrev { Texture = GBufferTexPrev; };
- sampler sJitterTex { Texture = JitterTex; AddressU = WRAP; AddressV = WRAP;};
- /*=============================================================================
- Vertex Shader
- =============================================================================*/
- struct VSOUT
- {
- float4 vpos : SV_Position;
- float4 __6698 : TEXCOORD0;
- float2 __6699 : TEXCOORD1;
- nointerpolation float3 c2 : TEXCOORD2;
- nointerpolation float3 c1 : TEXCOORD3;
- nointerpolation float4 c3 : TEXCOORD4;
- };
- VSOUT VS_RT(in uint id : SV_VertexID)
- {
- VSOUT o;
- o.__6699.x = (id == 2) ? 2.0 : 0.0;
- o.__6699.y = (id == 1) ? 2.0 : 0.0;
- o.__6698.xy = o.__6699 / RT_SIZE_SCALE;
- o.__6698.zw = o.__6699 * RT_SIZE_SCALE;
- o.vpos = float4(o.__6699.xy * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
- o.c2 = float3(-1.0,-1.0,1.0);
- o.c1 = float3(2.0,2.0,0.0);
- #if 1
- static const float FOV = 75; //vertical FoV
- o.c2 = float3(-tan(radians(FOV * 0.5)).xx,1.0) * qUINT::ASPECT_RATIO.yxx;
- o.c1 = float3(-2.0 * o.c2.xy,0.0);
- #endif
- o.c3.xy = rcp(o.c1.xy);
- o.c3.zw = -o.c2.xy * o.c3.xy;
- return o;
- }
- /*=============================================================================
- Functions
- =============================================================================*/
- struct _6A6
- {
- float __687;
- float3 __668;
- float3 __667;
- float2 __669;
- };
- struct __6733
- {
- float4 gi : SV_Target0;
- float4 __4223 : SV_Target1;
- };
- struct _6A66
- {
- float3 _6631;
- float3 _442;
- float3x3 _811;
- int _632;
- int _633;
- };
- float depth_to_distance(in float depth)
- {
- return depth * RESHADE_DEPTH_LINEARIZATION_FAR_PLANE + 1;
- }
- float3 __557(in VSOUT i, in float2 __6699, in float z)
- {
- return (__6699.xyx * i.c1 + i.c2) * z;
- }
- float3 __557_(in VSOUT i)
- {
- return (i.__6699.xyx * i.c1 + i.c2) * depth_to_distance(qUINT::linear_depth(i.__6699));
- }
- float3 __557_(in VSOUT i, in float2 __6699)
- {
- return (__6699.xyx * i.c1 + i.c2) * depth_to_distance(qUINT::linear_depth(__6699));
- }
- float3 __557_(in VSOUT i, in float2 __6699, in int mip)
- {
- return (__6699.xyx * i.c1 + i.c2) * tex2Dlod(sZTex, float4(__6699.xyx, mip)).x;
- }
- float2 get___6699__(in VSOUT i, in float3 p)
- {
- return (p.xy / p.z) * i.c3.xy + i.c3.zw;
- }
- float3 __6673(in VSOUT i)
- {
- float3 d = float3(qUINT::PIXEL_SIZE, 0);
- float3 p = __557_(i);
- float3 ddx1 = -p + __557_(i, i.__6699 + d.xz);
- float3 ddx2 = p - __557_(i, i.__6699 - d.xz);
- float3 ddy1 = -p + __557_(i, i.__6699 + d.zy);
- float3 ddy2 = p - __557_(i, i.__6699 - d.zy);
- ddx1 = abs(ddx1.z) > abs(ddx2.z) ? ddx2 : ddx1;
- ddy1 = abs(ddy1.z) > abs(ddy2.z) ? ddy2 : ddy1;
- float3 n = cross(ddy1, ddx1);
- n *= rsqrt(dot(n, n) + 1e-9);
- return n;
- }
- float3x3 __1233(float3 n)
- {
- //other variants have problems with transitions
- float3 e1proj = float3(1, 0, 0) - n.x * n;
- float3 e2proj = float3(0, 1, 0) - n.y * n;
- float3 e3proj = float3(0, 0, 1) - n.z * n;
- float3 longest = dot(e1proj, e1proj) > dot(e2proj, e2proj) ? e1proj : e2proj;
- longest = dot(longest, longest) > dot(e3proj, e3proj) ? longest : e3proj;
- longest = normalize(longest);
- float3 t = longest;
- float3 b = cross(t, n);
- return float3x3(t, b, n);
- }
- void x(inout float3 z)
- {
- z /= 1.01 - z;
- }
- void y(inout float3 z)
- {
- z /= 1.01 + z;
- }
- float w(__6733 __7764, __6733 __7712)
- {
- float4 __556 = abs(__7764.__4223 - __7712.__4223);
- float __522 = dot(__556.xyz, __556.xyz) * 10 + __556.w * 5000 * FILTER_SENSITIVITY;
- __522 = exp(-__522);
- __522 = saturate(1 - __522);
- return lerp(0.05, 0.9, __522);
- }
- float4 _442(in float2 __6699)
- {
- return float4(tex2Dlod(sNormalTex, float4(__6699, 0, 0)).xyz * 2 - 1,
- tex2Dlod(sZTex, float4(__6699, 0, 0)).x / RESHADE_DEPTH_LINEARIZATION_FAR_PLANE);
- }
- float4 atrous(int iter, sampler gisampler, VSOUT i)
- {
- float4 __4223_center = _442(i.__6699);
- float4 gi_center = tex2D(gisampler, i.__6699);
- float z_grad = FILTER_SENSITIVITY * abs(__4223_center.z) * rsqrt(dot(__4223_center.xy, __4223_center.xy) + 1e-6) + 1e-6;//cot(angle) = cos/sin, cos = z of normal, sin = length of xy of normal
- z_grad = rcp(z_grad * 6);
- float4 sum_gi = 0;
- float sum_w = 0.005;
- float error_thresh[3] = {0.04, 4.0, 1.0};
- int kernelsize[3] = {1, 1, 2};
- float size[3] = {1.3, 3.14, 7.5};
- /* 0.6 values
- size[0] = 1; size[1] = 2; size[2] = 4;
- kernelsize[0] = 2; kernelsize[1] = 2; kernelsize[2] = 2;
- */
- for(int x = -kernelsize[iter]; x <= kernelsize[iter]; x++)
- for(int y = -kernelsize[iter]; y <= kernelsize[iter]; y++)
- //for(int x = -2; x <= 2; x++)
- //for(int y = -2; y <= 2; y++)
- {
- float2 conv__6699 = i.__6699 + float2(x,y) * qUINT::PIXEL_SIZE * size[iter];
- float4 gi_tap = tex2Dlod(gisampler, float4(conv__6699, 0, 0));
- float4 __4223_tap = _442(conv__6699);
- float wz = exp(-abs(__4223_tap.w - __4223_center.w) * z_grad);
- float wn = pow(saturate(dot(__4223_tap.xyz, __4223_center.xyz)), 64 * FILTER_SENSITIVITY);
- float wi = exp(-abs(gi_tap.w - gi_center.w) * 16.0 * error_thresh[iter] * FILTER_SENSITIVITY);
- wn = lerp(wn, 1, saturate(1 - wz));
- sum_gi += gi_tap * wz*wn*wi;
- sum_w += wz*wn*wi;
- }
- return sum_gi / sum_w;
- }
- /*=============================================================================
- Pixel Shaders
- =============================================================================*/
- void PS_Deferred(in VSOUT i, out float4 normal : SV_Target0, out float depth : SV_Target1)
- {
- normal = float4(__6673(i) * 0.5 + 0.5, 1);
- depth = depth_to_distance(qUINT::linear_depth(i.__6699));
- }
- void PS_RTMain(in VSOUT i, out float4 o : SV_Target0)
- {
- float __547 = i.__6698.z; float __548 = i.__6698.w; float __549 = max(__547, __548); const float __550 = 1.00999999; bool __551 = __549 > __550; if (__551) { discard; } _6A66 rtconstants; VSOUT __554; float2 __555; __554 = i; float2 __556 = i.__6698.xy; __555 = __556; float3 __557 = __557_(__554, __555); rtconstants._6631 = __557; float2 __558 = i.__6698.xy; float4 __559 = tex2D(sNormalTex, __558); float3 __560 = __559.xyz; const float3 __561 = float3(2.00000000, 2.00000000, 2.00000000); float3 __562 = __560 * __561; const float3 __563 = float3(1.00000000, 1.00000000, 1.00000000); float3 __564 = __562 - __563; rtconstants._442 = __564; float3 __565; float3 __566 = rtconstants._442; __565 = __566; float3x3 __567 = __1233(__565); rtconstants._811 = __567; rtconstants._633 = RT_RAY_AMOUNT; rtconstants._632 = RT_RAY_STEPS; float __568 = rtconstants._6631.z; const float __569 = 1000.00000000; float __570 = __568 / __569; float depth__571; depth__571 = __570; float3 __572 = rtconstants._6631; const float3 __573 = float3(0.99800003, 0.99800003, 0.99800003); float3 __574 = __572 * __573; float3 __575 = rtconstants._442; float3 __576 = depth__571.xxx; float3 __577 = __575 * __576; float3 __578 = __574 + __577; rtconstants._6631 = __578; __6733 __7764__580; __6733 __7712__582; float __583 = rtconstants._442[0]; float __584 = rtconstants._442[1]; float __585 = rtconstants._442[2]; float4 __586 = float4(__583, __584, __585, depth__571); __7764__580.__4223 = __586; float2 __587 = i.__6698.xy; float4 __588 = tex2D(sGITexPrev, __587); __7712__582.gi = __588; float2 __589 = i.__6698.xy; float4 __590 = tex2D(sGBufferTexPrev, __589); __7712__582.__4223 = __590; __6733 __591; __6733 __592; __591 = __7764__580; __592 = __7712__582; float __593 = w(__591, __592); float alpha; alpha = __593; float __595 = saturate(alpha); const float __596 = 4.00000000; float __597 = __596 * __595; int __598 = ((int)__597); int __599 = rtconstants._633; int __600 = __599 + __598; rtconstants._633 = __600; const int __601 = 256; int zz; zz = __601; int __603 = rtconstants._633; int g; g = __603; const int __605 = 8; int nframes; nframes = __605; int2 __607 = tex2Dsize(sJitterTex); float2 __608 = i.vpos.xy; float2 __609 = ((float2)__607); float2 __610 = __608 % __609; int __611 = ((int)__610[0]); int __612 = ((int)__610[1]); const int __613 = 0; const int __614 = 0; int4 __615 = int4(__611, __612, __613, __614); float4 __616 = tex2Dfetch(sJitterTex, __615); float2 __617 = __616.xy; float2 bluenoise; bluenoise = __617; const float __619[8] = { 1.00000000, 5.00000000, 3.00000000, 7.00000000, 2.00000000, 6.00000000, 4.00000000, 8.00000000 }; float bayer1D[8]; bayer1D = __619; float __621 = bluenoise[0]; const float __622 = 255.00000000; float __623 = __621 * __622; float ipixel; ipixel = __623; int __625 = framecount % nframes; float __626 = bayer1D[__625]; float iframe; iframe = __626; float __628 = ((float)nframes); float __629 = ipixel * __628; float __630 = __629 + iframe; float index; index = __630; int __632 = zz * nframes; float __633 = ((float)__632); float __634 = index / __633; float samplejitter; samplejitter = __634; const float2 __636 = float2(0.00000000, 0.00000000); float2 sample_dir; sample_dir = __636; const float __638 = 2.39996314; float __639 = __638 * index; float __640; float __641; __640 = sin(__639), __641 = cos(__639); sample_dir.x = __640; sample_dir.y = __641; const float2x2 __643 = float2x2(-0.10280598, -0.99470145, 0.99470145, -0.10280598); float2x2 rotate; rotate = __643; const float4 __645 = float4(0.00000000, 0.00000000, 0.00000000, 0.00000000); __7764__580.gi = __645; float __646 = RT_SAMPLE_RADIUS * RT_SAMPLE_RADIUS; float __647 = __646 * RT_Z_THICKNESS; const float __648 = 1.00000000; float __649 = __648 / __647; float invthickness; invthickness = __649; const int __651 = 0; int r; r = __651; int __658 = rtconstants._633; bool __659 = r < __658; [loop] while (__659) { { _6A6 ray; float __664 = ((float)r); float __665 = __664 + samplejitter; float __666 = ((float)rtconstants._633); float __667 = __665 / __666; ray.__668.z = __667; const float __668 = 0.00000000; const float __669 = 1.00000000; float __670 = ray.__668.z; float __671 = lerp(__668, __669, __670); ray.__668.z = __671; float __672 = ray.__668.z; float __673 = sqrt(__672); ray.__668.z = __673; float __674 = ray.__668.z; float __675 = ray.__668.z; float __676 = __674 * __675; const float __677 = 1.00000000; float __678 = __677 - __676; float __679 = sqrt(__678); float2 __680 = __679.xx; float2 __681 = sample_dir * __680; ray.__668.xy = __681; float3 __682 = ray.__668; float3x3 __683 = rtconstants._811; float3 __684 = mul(__682, __683); ray.__668 = __684; float __685 = RT_SAMPLE_RADIUS * RT_SAMPLE_RADIUS; ray.__687 = __685; float2 __686 = mul(sample_dir, rotate); sample_dir = __686; if (RT_RAY_ISOMETRIC_SAMPLING) { float2 __690 = ray.__668.xy; float2 __691 = ray.__668.xy; float __692 = dot(__690, __691); float __693 = rsqrt(__692); float __694 = ray.__687; float __695 = __694 * __693; ray.__687 = __695; } const float __696 = 0.00000000; float intersected; intersected = __696; const float __698 = 0.00000000; float mip__699; mip__699 = __698; const int __700 = 0; int s; s = __700; const bool __702 = true; bool inside_screen; inside_screen = __702; const int __709 = 1; int __710 = s + __709; s = __710; int __711 = rtconstants._632; bool __712 = __710 < __711; bool __713 = __712 && inside_screen; while (__713) { { float __714 = ((float)s); float __715 = bluenoise[1]; float __716 = __714 + __715; float __717 = ((float)rtconstants._632); float __718 = __716 / __717; float lambda; lambda = __718; float __720 = rsqrt(lambda); float __721 = lambda * __720; float __722 = lambda * __721; lambda = __722; float3 __723 = ray.__668; float3 __724 = lambda.xxx; float3 __725 = __723 * __724; float3 __726 = ray.__687.xxx; float3 __727 = __725 * __726; float3 __728 = rtconstants._6631; float3 __729 = __728 + __727; ray.__667 = __729; VSOUT __730; float3 __731; __730 = i; float3 __732 = ray.__667; __731 = __732; float2 __733 = get___6699__(__730, __731); ray.__669 = __733; float2 __734 = ray.__669; float2 __735 = -__734; float2 __736 = ray.__669; float2 __737 = __735 * __736; float2 __738 = ray.__669; float2 __739 = __737 + __738; float2 __740 = saturate(__739); bool2 __741 = ((bool2)__740); bool __742 = all(__741); inside_screen = __742; float2 __743 = ray.__669; float2 __744 = i.__6698.xy; float2 __745 = __743 - __744; const float2 __746 = float2(1.77777779, 1.00000000); float2 __747 = __745 * __746; float __748 = length(__747); const float __749 = 28.00000000; float __750 = __748 * __749; mip__699 = __750; const float __751 = MXAO_MIPLEVEL_AO; float __752 = mip__699 + __751; VSOUT __753; float2 __754; int __755; __753 = i; float2 __756 = ray.__669; __754 = __756; int __757 = ((int)__752); __755 = __757; float3 __758 = __557_(__753, __754, __755); float3 __759 = ray.__667; float3 __760 = __758 - __759; float3 delta; delta = __760; float3 __762 = invthickness.xxx; float3 __763 = delta * __762; delta = __763; float __767 = delta[2]; const float __768 = 0.00000000; bool __769 = __767 < __768; float __770 = delta[2]; const float __771 = -1.00000000; bool __772 = __770 > __771; bool __773 = __769 && __772; [branch] if (__773) { float __774 = dot(delta, delta); const float __775 = 1.00000000; float __776 = __775 - __774; float __777 = saturate(__776); float __778 = ((float)inside_screen); float __779 = __777 * __778; intersected = __779; int __780 = rtconstants._632; s = __780; } } const int __709 = 1; int __710 = s + __709; s = __710; int __711 = rtconstants._632; bool __712 = __710 < __711; __713 = __712 && inside_screen; } float __781 = __7764__580.gi[3]; float __782 = __781 + intersected; __7764__580.gi[3] = __782; const float __783 = 10.00000000; float __784 = intersected * __783; const float __785 = 1.00000000; float __786 = __785 - __784; float __787 = saturate(__786); float3 __788 = __787.xxx; float3 __789 = SKY_COLOR * __788; float3 __790 = ((float3)inside_screen.xxx); float3 __791 = __789 * __790; int __792 = rtconstants._632; bool __793 = s >= __792; float3 __794 = ((float3)__793.xxx); float3 __795 = __791 * __794; float3 __796 = __7764__580.gi.xyz; float3 __797 = __796 + __795; __7764__580.gi.xyz = __797; const float __801 = 0.00000000; bool __802 = RT_IL_AMOUNT > __801; const float __803 = 0.05000000; bool __804 = intersected > __803; bool __805 = __802 && __804; [branch] if (__805) { mip__699 = mip__699 - MXAO_MIPLEVEL_AO + MXAO_MIPLEVEL_IL; float __806 = ray.__669[0]; float __807 = ray.__669[1]; const float __808 = 0.00000000; float4 __809 = float4(__806, __807, __808, mip__699); float4 __810 = tex2Dlod(qUINT::sBackBufferTex, __809); float3 __811 = __810.xyz; float3 albedo; albedo = __811; float3 __813; __813 = albedo; x(__813); albedo = __813;
- #if INFINITE_BOUNCES != 0
- float3 nextbounce = tex2Dlod(sGITexPrev, __809).rgb; x(nextbounce); albedo += nextbounce * RT_IL_BOUNCE_WEIGHT;
- #endif
- float __815 = ray.__669[0]; float __816 = ray.__669[1]; const float __817 = 0.00000000; float4 __818 = float4(__815, __816, __817, mip__699); float4 __819 = tex2Dlod(sNormalTex, __818); float3 __820 = __819.xyz; const float3 __821 = float3(2.00000000, 2.00000000, 2.00000000); float3 __822 = __820 * __821; const float3 __823 = float3(1.00000000, 1.00000000, 1.00000000); float3 __824 = __822 - __823; float3 intersect_normal; intersect_normal = __824; float3 __826 = intersected.xxx; float3 __827 = albedo * __826; float3 __828 = -intersect_normal; float3 __829 = ray.__668; float __830 = dot(__828, __829); float __831 = saturate(__830); float3 __832 = __831.xxx; float3 __833 = __827 * __832; float3 __834 = __7764__580.gi.xyz; float3 __835 = __834 + __833; __7764__580.gi.xyz = __835; } } const int __660 = 1; int __661 = r + __660; r = __661; int __658 = rtconstants._633; __659 = r < __658; } float4 __836 = ((float4)rtconstants._633.xxxx); float4 __837 = __7764__580.gi; float4 __838 = __837 / __836; __7764__580.gi = __838; float3 __839; float3 __840 = __7764__580.gi.xyz; __839 = __840; y(__839); __7764__580.gi.xyz = __839; float4 __842 = __7712__582.gi; float4 __843 = __7764__580.gi; float4 __844 = alpha.xxxx; float4 __845 = lerp(__842, __843, __844); o = __845; return;
- }
- void PS_Copy(in VSOUT i, out __6733 o)
- {
- o.gi = tex2D(sGITex, i.__6698.zw);
- o.__4223 = _442(i.__6699);
- }
- void PS_Filter0(in VSOUT i, out float4 o : SV_Target0)
- {
- o = atrous(0, sGITexPrev, i);
- }
- void PS_Filter1(in VSOUT i, out float4 o : SV_Target0)
- {
- o = atrous(1, sGITexTemp, i);
- }
- void PS_Filter2(in VSOUT i, out float4 o : SV_Target0)
- {
- o = atrous(2, sGITex, i);
- }
- //need this as backbuffer is not guaranteed to have RGBA8
- void PS_Output(in VSOUT i, out float4 o : SV_Target0)
- {
- #if SPATIAL_FILTER != 0
- float4 gi = tex2D(sGITexTemp, i.__6699);
- #else
- float4 gi = tex2D(sGITex, i.__6698.zw);
- #endif
- float3 color = tex2D(qUINT::sBackBufferTex, i.__6699).rgb;
- x(color);
- x(gi.rgb);
- gi *= smoothstep(RT_FADE_DEPTH.y, RT_FADE_DEPTH.x, qUINT::linear_depth(i.__6699));
- gi.w = RT_AO_AMOUNT > 1 ? pow(1 - gi.w, RT_AO_AMOUNT) : 1 - gi.w * RT_AO_AMOUNT;
- gi.rgb *= RT_IL_AMOUNT * RT_IL_AMOUNT;
- color = color * gi.w * (1 + gi.rgb);
- if(RT_DEBUG_VIEW == 1)
- color.rgb = gi.w * (1 + gi.rgb);
- y(color.rgb);
- o = float4(color, 1);
- }
- /*=============================================================================
- Techniques
- =============================================================================*/
- technique RTGlobalIllumination
- {
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Deferred;
- RenderTarget0 = NormalTex;
- RenderTarget1 = ZTex;
- }
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_RTMain;
- RenderTarget0 = GITex;
- }
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Copy;
- RenderTarget0 = GITexPrev;
- RenderTarget1 = GBufferTexPrev;
- }
- #if SPATIAL_FILTER != 0
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Filter0;
- RenderTarget = GITexTemp;
- }
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Filter1;
- RenderTarget = GITex;
- }
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Filter2;
- RenderTarget = GITexTemp;
- }
- #endif
- pass
- {
- VertexShader = VS_RT;
- PixelShader = PS_Output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement