Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
1,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.78 KB | None | 0 0
  1. /*=============================================================================
  2.  
  3. ReShade 4 effect file
  4. github.com/martymcmodding
  5.  
  6. Support me:
  7. paypal.me/mcflypg
  8. patreon.com/mcflypg
  9.  
  10. Path Traced Global Illumination
  11.  
  12. by Marty McFly / P.Gilcher
  13. part of qUINT shader library for ReShade 4
  14.  
  15. CC BY-NC-ND 3.0 licensed.
  16.  
  17. =============================================================================*/
  18.  
  19. /*=============================================================================
  20. Preprocessor settings
  21. =============================================================================*/
  22.  
  23. //these two are required if I want to reuse the MXAO textures properly
  24.  
  25. #ifndef MXAO_MIPLEVEL_AO
  26. #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
  27. #endif
  28.  
  29. #ifndef MXAO_MIPLEVEL_IL
  30. #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.
  31. #endif
  32.  
  33. #ifndef INFINITE_BOUNCES
  34. #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.
  35. #endif
  36.  
  37. #ifndef SPATIAL_FILTER
  38. #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.
  39. #endif
  40.  
  41. /*=============================================================================
  42. UI Uniforms
  43. =============================================================================*/
  44.  
  45. uniform float RT_SIZE_SCALE <
  46. ui_type = "drag";
  47. ui_min = 0.5; ui_max = 1.0;
  48. ui_step = 0.5;
  49. ui_label = "GI Render Resolution Scale";
  50. ui_category = "Global";
  51. > = 1.0;
  52.  
  53. uniform float FILTER_SENSITIVITY <
  54. ui_type = "drag";
  55. ui_min = 0.01; ui_max = 10.0;
  56. ui_step = 0.01;
  57. ui_label = "GI Filter Sensitivity";
  58. ui_category = "Global";
  59. > = 1.0;
  60.  
  61. uniform float RT_SAMPLE_RADIUS <
  62. ui_type = "drag";
  63. ui_min = 0.5; ui_max = 20.0;
  64. ui_step = 0.01;
  65. ui_label = "Ray Length";
  66. ui_tooltip = "Maximum ray length, directly affects\nthe spread radius of shadows / indirect lighing";
  67. ui_category = "Path Tracing";
  68. > = 5.0;
  69.  
  70. uniform int RT_RAY_AMOUNT <
  71. ui_type = "slider";
  72. ui_min = 1; ui_max = 20;
  73. ui_label = "Ray Amount";
  74. ui_category = "Path Tracing";
  75. > = 3;
  76.  
  77. uniform int RT_RAY_STEPS <
  78. ui_type = "slider";
  79. ui_min = 5; ui_max = 20;
  80. ui_label = "Ray Step Amount";
  81. ui_category = "Path Tracing";
  82. > = 10;
  83.  
  84. uniform bool RT_RAY_ISOMETRIC_SAMPLING
  85. <
  86. ui_label = "Enable Isometric Rays";
  87. > = false;
  88.  
  89. uniform float RT_Z_THICKNESS <
  90. ui_type = "drag";
  91. ui_min = 0.0; ui_max = 10.0;
  92. ui_step = 0.01;
  93. ui_label = "Z Thickness";
  94. 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.";
  95. ui_category = "Path Tracing";
  96. > = 1.0;
  97.  
  98. uniform float RT_AO_AMOUNT <
  99. ui_type = "drag";
  100. ui_min = 0; ui_max = 2.0;
  101. ui_step = 0.01;
  102. ui_label = "Ambient Occlusion Intensity";
  103. ui_category = "Blending";
  104. > = 1.0;
  105.  
  106. uniform float RT_IL_AMOUNT <
  107. ui_type = "drag";
  108. ui_min = 0; ui_max = 7.0;
  109. ui_step = 0.01;
  110. ui_label = "Indirect Lighting Intensity";
  111. ui_category = "Blending";
  112. > = 4.0;
  113.  
  114. #if INFINITE_BOUNCES != 0
  115. uniform float RT_IL_BOUNCE_WEIGHT <
  116. ui_type = "drag";
  117. ui_min = 0; ui_max = 5.0;
  118. ui_step = 0.01;
  119. ui_label = "Next Bounce Weight";
  120. ui_category = "Blending";
  121. > = 0.0;
  122. #endif
  123.  
  124. uniform float2 RT_FADE_DEPTH <
  125. ui_type = "drag";
  126. ui_label = "Fade Out Start / End";
  127. ui_min = 0.00; ui_max = 1.00;
  128. ui_tooltip = "Distance where GI starts to fade out | is completely faded out.";
  129. ui_category = "Blending";
  130. > = float2(0.0, 0.5);
  131.  
  132. uniform int RT_DEBUG_VIEW <
  133. ui_type = "radio";
  134. ui_label = "Enable Debug View";
  135. ui_items = "None\0AO/IL channel\0";
  136. ui_tooltip = "Different debug outputs";
  137. ui_category = "Debug";
  138. > = 0;
  139.  
  140. uniform float3 SKY_COLOR <
  141. ui_type = "color";
  142. ui_label = "Sky Color";
  143. ui_category = "Path Tracing";
  144. > = float3(0.0, 0.0, 0.0);
  145.  
  146. /*
  147. uniform float4 tempF1 <
  148. ui_type = "drag";
  149. ui_min = -100.0;
  150. ui_max = 100.0;
  151. > = float4(1,1,1,1);
  152.  
  153. uniform float4 tempF2 <
  154. ui_type = "drag";
  155. ui_min = -100.0;
  156. ui_max = 100.0;
  157. > = float4(1,1,1,1);
  158. */
  159.  
  160. /*=============================================================================
  161. Textures, Samplers, Globals
  162. =============================================================================*/
  163.  
  164. #include "qUINT_common.fxh"
  165.  
  166. uniform int framecount < source = "framecount"; >;
  167.  
  168. texture ZTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R16F; MipLevels = 3 + MXAO_MIPLEVEL_AO;};
  169. texture NormalTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; MipLevels = 3 + MXAO_MIPLEVEL_IL;};
  170. texture GITex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
  171. texture GITexPrev { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
  172. texture GITexTemp { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
  173. texture GBufferTexPrev { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA16F; };
  174.  
  175. texture JitterTex < source = "LDR_RGB1_18.png"; > { Width = 32; Height = 32; Format = RGBA8; };
  176.  
  177. sampler2D sZTex { Texture = ZTex; };
  178. sampler2D sNormalTex { Texture = NormalTex; };
  179. sampler2D sGITex { Texture = GITex; };
  180. sampler2D sGITexPrev { Texture = GITexPrev; };
  181. sampler2D sGITexTemp { Texture = GITexTemp; };
  182. sampler2D sGBufferTexPrev { Texture = GBufferTexPrev; };
  183.  
  184. sampler sJitterTex { Texture = JitterTex; AddressU = WRAP; AddressV = WRAP;};
  185.  
  186. /*=============================================================================
  187. Vertex Shader
  188. =============================================================================*/
  189.  
  190. struct VSOUT
  191. {
  192. float4 vpos : SV_Position;
  193. float4 __6698 : TEXCOORD0;
  194. float2 __6699 : TEXCOORD1;
  195. nointerpolation float3 c2 : TEXCOORD2;
  196. nointerpolation float3 c1 : TEXCOORD3;
  197. nointerpolation float4 c3 : TEXCOORD4;
  198. };
  199.  
  200. VSOUT VS_RT(in uint id : SV_VertexID)
  201. {
  202. VSOUT o;
  203.  
  204. o.__6699.x = (id == 2) ? 2.0 : 0.0;
  205. o.__6699.y = (id == 1) ? 2.0 : 0.0;
  206.  
  207. o.__6698.xy = o.__6699 / RT_SIZE_SCALE;
  208. o.__6698.zw = o.__6699 * RT_SIZE_SCALE;
  209.  
  210. o.vpos = float4(o.__6699.xy * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  211.  
  212. o.c2 = float3(-1.0,-1.0,1.0);
  213. o.c1 = float3(2.0,2.0,0.0);
  214.  
  215. #if 1
  216. static const float FOV = 75; //vertical FoV
  217. o.c2 = float3(-tan(radians(FOV * 0.5)).xx,1.0) * qUINT::ASPECT_RATIO.yxx;
  218. o.c1 = float3(-2.0 * o.c2.xy,0.0);
  219. #endif
  220.  
  221. o.c3.xy = rcp(o.c1.xy);
  222. o.c3.zw = -o.c2.xy * o.c3.xy;
  223.  
  224. return o;
  225. }
  226.  
  227. /*=============================================================================
  228. Functions
  229. =============================================================================*/
  230.  
  231. struct _6A6
  232. {
  233. float __687;
  234. float3 __668;
  235. float3 __667;
  236. float2 __669;
  237. };
  238.  
  239. struct __6733
  240. {
  241. float4 gi : SV_Target0;
  242. float4 __4223 : SV_Target1;
  243. };
  244.  
  245. struct _6A66
  246. {
  247. float3 _6631;
  248. float3 _442;
  249. float3x3 _811;
  250. int _632;
  251. int _633;
  252. };
  253.  
  254. float depth_to_distance(in float depth)
  255. {
  256. return depth * RESHADE_DEPTH_LINEARIZATION_FAR_PLANE + 1;
  257. }
  258.  
  259. float3 __557(in VSOUT i, in float2 __6699, in float z)
  260. {
  261. return (__6699.xyx * i.c1 + i.c2) * z;
  262. }
  263.  
  264. float3 __557_(in VSOUT i)
  265. {
  266. return (i.__6699.xyx * i.c1 + i.c2) * depth_to_distance(qUINT::linear_depth(i.__6699));
  267. }
  268.  
  269. float3 __557_(in VSOUT i, in float2 __6699)
  270. {
  271. return (__6699.xyx * i.c1 + i.c2) * depth_to_distance(qUINT::linear_depth(__6699));
  272. }
  273.  
  274. float3 __557_(in VSOUT i, in float2 __6699, in int mip)
  275. {
  276. return (__6699.xyx * i.c1 + i.c2) * tex2Dlod(sZTex, float4(__6699.xyx, mip)).x;
  277. }
  278.  
  279. float2 get___6699__(in VSOUT i, in float3 p)
  280. {
  281. return (p.xy / p.z) * i.c3.xy + i.c3.zw;
  282. }
  283.  
  284. float3 __6673(in VSOUT i)
  285. {
  286. float3 d = float3(qUINT::PIXEL_SIZE, 0);
  287. float3 p = __557_(i);
  288. float3 ddx1 = -p + __557_(i, i.__6699 + d.xz);
  289. float3 ddx2 = p - __557_(i, i.__6699 - d.xz);
  290. float3 ddy1 = -p + __557_(i, i.__6699 + d.zy);
  291. float3 ddy2 = p - __557_(i, i.__6699 - d.zy);
  292.  
  293. ddx1 = abs(ddx1.z) > abs(ddx2.z) ? ddx2 : ddx1;
  294. ddy1 = abs(ddy1.z) > abs(ddy2.z) ? ddy2 : ddy1;
  295.  
  296. float3 n = cross(ddy1, ddx1);
  297. n *= rsqrt(dot(n, n) + 1e-9);
  298. return n;
  299. }
  300.  
  301. float3x3 __1233(float3 n)
  302. {
  303. //other variants have problems with transitions
  304. float3 e1proj = float3(1, 0, 0) - n.x * n;
  305. float3 e2proj = float3(0, 1, 0) - n.y * n;
  306. float3 e3proj = float3(0, 0, 1) - n.z * n;
  307.  
  308. float3 longest = dot(e1proj, e1proj) > dot(e2proj, e2proj) ? e1proj : e2proj;
  309. longest = dot(longest, longest) > dot(e3proj, e3proj) ? longest : e3proj;
  310.  
  311. longest = normalize(longest);
  312.  
  313. float3 t = longest;
  314. float3 b = cross(t, n);
  315.  
  316. return float3x3(t, b, n);
  317. }
  318.  
  319. void x(inout float3 z)
  320. {
  321. z /= 1.01 - z;
  322. }
  323.  
  324. void y(inout float3 z)
  325. {
  326. z /= 1.01 + z;
  327. }
  328.  
  329. float w(__6733 __7764, __6733 __7712)
  330. {
  331. float4 __556 = abs(__7764.__4223 - __7712.__4223);
  332.  
  333. float __522 = dot(__556.xyz, __556.xyz) * 10 + __556.w * 5000 * FILTER_SENSITIVITY;
  334. __522 = exp(-__522);
  335.  
  336. __522 = saturate(1 - __522);
  337. return lerp(0.05, 0.9, __522);
  338. }
  339.  
  340. float4 _442(in float2 __6699)
  341. {
  342. return float4(tex2Dlod(sNormalTex, float4(__6699, 0, 0)).xyz * 2 - 1,
  343. tex2Dlod(sZTex, float4(__6699, 0, 0)).x / RESHADE_DEPTH_LINEARIZATION_FAR_PLANE);
  344.  
  345. }
  346.  
  347. float4 atrous(int iter, sampler gisampler, VSOUT i)
  348. {
  349. float4 __4223_center = _442(i.__6699);
  350. float4 gi_center = tex2D(gisampler, i.__6699);
  351.  
  352. 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
  353. z_grad = rcp(z_grad * 6);
  354.  
  355. float4 sum_gi = 0;
  356. float sum_w = 0.005;
  357.  
  358. float error_thresh[3] = {0.04, 4.0, 1.0};
  359. int kernelsize[3] = {1, 1, 2};
  360. float size[3] = {1.3, 3.14, 7.5};
  361.  
  362. /* 0.6 values
  363. size[0] = 1; size[1] = 2; size[2] = 4;
  364. kernelsize[0] = 2; kernelsize[1] = 2; kernelsize[2] = 2;
  365. */
  366.  
  367. for(int x = -kernelsize[iter]; x <= kernelsize[iter]; x++)
  368. for(int y = -kernelsize[iter]; y <= kernelsize[iter]; y++)
  369. //for(int x = -2; x <= 2; x++)
  370. //for(int y = -2; y <= 2; y++)
  371. {
  372. float2 conv__6699 = i.__6699 + float2(x,y) * qUINT::PIXEL_SIZE * size[iter];
  373.  
  374. float4 gi_tap = tex2Dlod(gisampler, float4(conv__6699, 0, 0));
  375. float4 __4223_tap = _442(conv__6699);
  376.  
  377. float wz = exp(-abs(__4223_tap.w - __4223_center.w) * z_grad);
  378. float wn = pow(saturate(dot(__4223_tap.xyz, __4223_center.xyz)), 64 * FILTER_SENSITIVITY);
  379. float wi = exp(-abs(gi_tap.w - gi_center.w) * 16.0 * error_thresh[iter] * FILTER_SENSITIVITY);
  380.  
  381. wn = lerp(wn, 1, saturate(1 - wz));
  382.  
  383. sum_gi += gi_tap * wz*wn*wi;
  384. sum_w += wz*wn*wi;
  385. }
  386.  
  387. return sum_gi / sum_w;
  388. }
  389.  
  390. /*=============================================================================
  391. Pixel Shaders
  392. =============================================================================*/
  393.  
  394. void PS_Deferred(in VSOUT i, out float4 normal : SV_Target0, out float depth : SV_Target1)
  395. {
  396. normal = float4(__6673(i) * 0.5 + 0.5, 1);
  397. depth = depth_to_distance(qUINT::linear_depth(i.__6699));
  398. }
  399.  
  400.  
  401. void PS_RTMain(in VSOUT i, out float4 o : SV_Target0)
  402. {
  403. 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;
  404. #if INFINITE_BOUNCES != 0
  405. float3 nextbounce = tex2Dlod(sGITexPrev, __809).rgb; x(nextbounce); albedo += nextbounce * RT_IL_BOUNCE_WEIGHT;
  406. #endif
  407. 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;
  408. }
  409.  
  410. void PS_Copy(in VSOUT i, out __6733 o)
  411. {
  412. o.gi = tex2D(sGITex, i.__6698.zw);
  413. o.__4223 = _442(i.__6699);
  414. }
  415.  
  416. void PS_Filter0(in VSOUT i, out float4 o : SV_Target0)
  417. {
  418. o = atrous(0, sGITexPrev, i);
  419. }
  420. void PS_Filter1(in VSOUT i, out float4 o : SV_Target0)
  421. {
  422. o = atrous(1, sGITexTemp, i);
  423. }
  424. void PS_Filter2(in VSOUT i, out float4 o : SV_Target0)
  425. {
  426. o = atrous(2, sGITex, i);
  427. }
  428.  
  429. //need this as backbuffer is not guaranteed to have RGBA8
  430. void PS_Output(in VSOUT i, out float4 o : SV_Target0)
  431. {
  432. #if SPATIAL_FILTER != 0
  433. float4 gi = tex2D(sGITexTemp, i.__6699);
  434. #else
  435. float4 gi = tex2D(sGITex, i.__6698.zw);
  436. #endif
  437. float3 color = tex2D(qUINT::sBackBufferTex, i.__6699).rgb;
  438.  
  439. x(color);
  440. x(gi.rgb);
  441.  
  442. gi *= smoothstep(RT_FADE_DEPTH.y, RT_FADE_DEPTH.x, qUINT::linear_depth(i.__6699));
  443.  
  444. gi.w = RT_AO_AMOUNT > 1 ? pow(1 - gi.w, RT_AO_AMOUNT) : 1 - gi.w * RT_AO_AMOUNT;
  445. gi.rgb *= RT_IL_AMOUNT * RT_IL_AMOUNT;
  446.  
  447. color = color * gi.w * (1 + gi.rgb);
  448.  
  449. if(RT_DEBUG_VIEW == 1)
  450. color.rgb = gi.w * (1 + gi.rgb);
  451.  
  452. y(color.rgb);
  453. o = float4(color, 1);
  454. }
  455.  
  456. /*=============================================================================
  457. Techniques
  458. =============================================================================*/
  459.  
  460. technique RTGlobalIllumination
  461. {
  462. pass
  463. {
  464. VertexShader = VS_RT;
  465. PixelShader = PS_Deferred;
  466. RenderTarget0 = NormalTex;
  467. RenderTarget1 = ZTex;
  468. }
  469. pass
  470. {
  471. VertexShader = VS_RT;
  472. PixelShader = PS_RTMain;
  473. RenderTarget0 = GITex;
  474. }
  475. pass
  476. {
  477. VertexShader = VS_RT;
  478. PixelShader = PS_Copy;
  479. RenderTarget0 = GITexPrev;
  480. RenderTarget1 = GBufferTexPrev;
  481. }
  482. #if SPATIAL_FILTER != 0
  483. pass
  484. {
  485. VertexShader = VS_RT;
  486. PixelShader = PS_Filter0;
  487. RenderTarget = GITexTemp;
  488. }
  489. pass
  490. {
  491. VertexShader = VS_RT;
  492. PixelShader = PS_Filter1;
  493. RenderTarget = GITex;
  494. }
  495. pass
  496. {
  497. VertexShader = VS_RT;
  498. PixelShader = PS_Filter2;
  499. RenderTarget = GITexTemp;
  500. }
  501. #endif
  502. pass
  503. {
  504. VertexShader = VS_RT;
  505. PixelShader = PS_Output;
  506. }
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement