denoise.cpp 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. /*
  2. * Copyright 2021 elven cache. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. /*
  6. * Implement SVGF style denoising as bgfx example. Goal is to explore various
  7. * options and parameters, not produce an optimized, efficient denoiser.
  8. *
  9. * Starts with deferred rendering scene with very basic lighting. Lighting is
  10. * masked out with a noise pattern to provide something to denoise. There are
  11. * two options for the noise pattern. One is a fixed 2x2 dither pattern to
  12. * stand-in for lighting at quarter resolution. The other is the common
  13. * shadertoy random pattern as a stand-in for some fancier lighting without
  14. * enough samples per pixel, like ray tracing.
  15. *
  16. * First a temporal denoising filter is applied. The temporal filter is only
  17. * using normals to reject previous samples. The SVGF paper also describes using
  18. * depth comparison to reject samples but that is not implemented here.
  19. *
  20. * Followed by some number of spatial filters. These are implemented like in the
  21. * SVGF paper. As an alternative to the 5x5 Edge-Avoiding A-Trous filter, can
  22. * select a 3x3 filter instead. The 3x3 filter takes fewer samples and covers a
  23. * smaller area, but takes less time to compute. From a loosely eyeballed
  24. * comparison, N 5x5 passes looks similar to N+1 3x3 passes. The wider spatial
  25. * filters take a fair chunk of time to compute. I wonder if it would be a good
  26. * idea to interleave the input texture before computing, after the first pass
  27. * which skips zero pixels.
  28. *
  29. * I have not implemetened the variance guided part.
  30. *
  31. * There's also an optional TXAA pass to be applied after. I am not happy with
  32. * its implementation yet, so it defaults to off here.
  33. */
  34. /*
  35. * Reference(s):
  36. *
  37. * - Spatiotemporal Variance-Guided Filtering: Real-Time Reconstruction for Path-Traced Global Illumination.
  38. * https://web.archive.org/web/20170720213354/https://research.nvidia.com/sites/default/files/pubs/2017-07_Spatiotemporal-Variance-Guided-Filtering%3A/svgf_preprint.pdf
  39. *
  40. * - Streaming G-Buffer Compression for Multi-Sample Anti-Aliasing.
  41. * https://web.archive.org/web/20200807211002/https://software.intel.com/content/www/us/en/develop/articles/streaming-g-buffer-compression-for-multi-sample-anti-aliasing.html
  42. *
  43. * - Edge-Avoiding A-Trous Wavelet Transform for fast Global Illumination Filtering
  44. * https://web.archive.org/web/20130412085423/https://www.uni-ulm.de/fileadmin/website_uni_ulm/iui.inst.100/institut/Papers/atrousGIfilter.pdf
  45. *
  46. */
  47. #include <common.h>
  48. #include <camera.h>
  49. #include <bgfx_utils.h>
  50. #include <imgui/imgui.h>
  51. #include <bx/rng.h>
  52. #include <bx/os.h>
  53. namespace {
  54. #define DENOISE_MAX_PASSES 6
  55. // Gbuffer has multiple render targets
  56. #define GBUFFER_RT_COLOR 0
  57. #define GBUFFER_RT_NORMAL 1
  58. #define GBUFFER_RT_VELOCITY 2
  59. #define GBUFFER_RT_DEPTH 3
  60. #define GBUFFER_RENDER_TARGETS 4
  61. #define MODEL_COUNT 100
  62. static const char * s_meshPaths[] =
  63. {
  64. "meshes/column.bin",
  65. "meshes/tree.bin",
  66. "meshes/hollowcube.bin",
  67. "meshes/bunny.bin"
  68. };
  69. static const float s_meshScale[] =
  70. {
  71. 0.05f,
  72. 0.15f,
  73. 0.25f,
  74. 0.25f
  75. };
  76. // Vertex decl for our screen space quad (used in deferred rendering)
  77. struct PosTexCoord0Vertex
  78. {
  79. float m_x;
  80. float m_y;
  81. float m_z;
  82. float m_u;
  83. float m_v;
  84. static void init()
  85. {
  86. ms_layout
  87. .begin()
  88. .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
  89. .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
  90. .end();
  91. }
  92. static bgfx::VertexLayout ms_layout;
  93. };
  94. bgfx::VertexLayout PosTexCoord0Vertex::ms_layout;
  95. struct Uniforms
  96. {
  97. enum { NumVec4 = 13 };
  98. void init() {
  99. u_params = bgfx::createUniform("u_params", bgfx::UniformType::Vec4, NumVec4);
  100. };
  101. void submit() const {
  102. bgfx::setUniform(u_params, m_params, NumVec4);
  103. }
  104. void destroy() {
  105. bgfx::destroy(u_params);
  106. }
  107. union
  108. {
  109. struct
  110. {
  111. /* 0 */ struct { float m_cameraJitterCurr[2]; float m_cameraJitterPrev[2]; };
  112. /* 1 */ struct { float m_feedbackMin; float m_feedbackMax; float m_unused1[2]; };
  113. /* 2 */ struct { float m_unused2; float m_applyMitchellFilter; float m_options[2]; };
  114. /* 3-6 */ struct { float m_worldToViewPrev[16]; };
  115. /* 7-10 */ struct { float m_viewToProjPrev[16]; };
  116. /* 11 */ struct { float m_frameOffsetForNoise; float m_noiseType; float m_unused11[2]; };
  117. /* 12 */ struct { float m_denoiseStep; float m_sigmaDepth; float m_sigmaNormal; float m_unused12; };
  118. };
  119. float m_params[NumVec4 * 4];
  120. };
  121. bgfx::UniformHandle u_params;
  122. };
  123. struct RenderTarget
  124. {
  125. void init(uint32_t _width, uint32_t _height, bgfx::TextureFormat::Enum _format, uint64_t _flags)
  126. {
  127. m_texture = bgfx::createTexture2D(uint16_t(_width), uint16_t(_height), false, 1, _format, _flags);
  128. const bool destroyTextures = true;
  129. m_buffer = bgfx::createFrameBuffer(1, &m_texture, destroyTextures);
  130. }
  131. void destroy()
  132. {
  133. // also responsible for destroying texture
  134. bgfx::destroy(m_buffer);
  135. }
  136. bgfx::TextureHandle m_texture;
  137. bgfx::FrameBufferHandle m_buffer;
  138. };
  139. void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
  140. {
  141. if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout) )
  142. {
  143. bgfx::TransientVertexBuffer vb;
  144. bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout);
  145. PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data;
  146. const float minx = -_width;
  147. const float maxx = _width;
  148. const float miny = 0.0f;
  149. const float maxy = _height * 2.0f;
  150. const float texelHalfW = _texelHalf / _textureWidth;
  151. const float texelHalfH = _texelHalf / _textureHeight;
  152. const float minu = -1.0f + texelHalfW;
  153. const float maxu = 1.0f + texelHalfW;
  154. const float zz = 0.0f;
  155. float minv = texelHalfH;
  156. float maxv = 2.0f + texelHalfH;
  157. if (_originBottomLeft)
  158. {
  159. float temp = minv;
  160. minv = maxv;
  161. maxv = temp;
  162. minv -= 1.0f;
  163. maxv -= 1.0f;
  164. }
  165. vertex[0].m_x = minx;
  166. vertex[0].m_y = miny;
  167. vertex[0].m_z = zz;
  168. vertex[0].m_u = minu;
  169. vertex[0].m_v = minv;
  170. vertex[1].m_x = maxx;
  171. vertex[1].m_y = miny;
  172. vertex[1].m_z = zz;
  173. vertex[1].m_u = maxu;
  174. vertex[1].m_v = minv;
  175. vertex[2].m_x = maxx;
  176. vertex[2].m_y = maxy;
  177. vertex[2].m_z = zz;
  178. vertex[2].m_u = maxu;
  179. vertex[2].m_v = maxv;
  180. bgfx::setVertexBuffer(0, &vb);
  181. }
  182. }
  183. void vec2Set(float* _v, float _x, float _y)
  184. {
  185. _v[0] = _x;
  186. _v[1] = _y;
  187. }
  188. void mat4Set(float * _m, const float * _src)
  189. {
  190. const uint32_t MAT4_FLOATS = 16;
  191. for (uint32_t ii = 0; ii < MAT4_FLOATS; ++ii) {
  192. _m[ii] = _src[ii];
  193. }
  194. }
  195. class ExampleDenoise : public entry::AppI
  196. {
  197. public:
  198. ExampleDenoise(const char* _name, const char* _description)
  199. : entry::AppI(_name, _description)
  200. , m_currFrame(UINT32_MAX)
  201. , m_texelHalf(0.0f)
  202. {
  203. }
  204. void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) override
  205. {
  206. Args args(_argc, _argv);
  207. m_width = _width;
  208. m_height = _height;
  209. m_debug = BGFX_DEBUG_NONE;
  210. m_reset = BGFX_RESET_VSYNC;
  211. bgfx::Init init;
  212. init.type = args.m_type;
  213. init.vendorId = args.m_pciId;
  214. init.resolution.width = m_width;
  215. init.resolution.height = m_height;
  216. init.resolution.reset = m_reset;
  217. bgfx::init(init);
  218. // Enable debug text.
  219. bgfx::setDebug(m_debug);
  220. // Create uniforms
  221. m_uniforms.init();
  222. // Create texture sampler uniforms (used when we bind textures)
  223. s_albedo = bgfx::createUniform("s_albedo", bgfx::UniformType::Sampler); // Model's source albedo
  224. s_color = bgfx::createUniform("s_color", bgfx::UniformType::Sampler); // Color (albedo) gbuffer, default color input
  225. s_normal = bgfx::createUniform("s_normal", bgfx::UniformType::Sampler); // Normal gbuffer, Model's source normal
  226. s_velocity = bgfx::createUniform("s_velocity", bgfx::UniformType::Sampler); // Velocity gbuffer
  227. s_depth = bgfx::createUniform("s_depth", bgfx::UniformType::Sampler); // Depth gbuffer
  228. s_previousColor = bgfx::createUniform("s_previousColor", bgfx::UniformType::Sampler); // Previous frame's result
  229. s_previousNormal = bgfx::createUniform("s_previousNormal", bgfx::UniformType::Sampler); // Previous frame's gbuffer normal
  230. // Create program from shaders.
  231. m_gbufferProgram = loadProgram("vs_denoise_gbuffer", "fs_denoise_gbuffer"); // Fill gbuffer
  232. m_combineProgram = loadProgram("vs_denoise_screenquad", "fs_denoise_deferred_combine"); // Compute lighting from gbuffer
  233. m_copyProgram = loadProgram("vs_denoise_screenquad", "fs_denoise_copy");
  234. m_denoiseTemporalProgram = loadProgram("vs_denoise_screenquad", "fs_denoise_temporal");
  235. m_denoiseSpatialProgram3x3 = loadProgram("vs_denoise_screenquad", "fs_denoise_spatial_3x3");
  236. m_denoiseSpatialProgram5x5 = loadProgram("vs_denoise_screenquad", "fs_denoise_spatial_5x5");
  237. m_denoiseApplyLighting = loadProgram("vs_denoise_screenquad", "fs_denoise_apply_lighting");
  238. m_txaaProgram = loadProgram("vs_denoise_screenquad", "fs_denoise_txaa");
  239. // Load some meshes
  240. for (uint32_t ii = 0; ii < BX_COUNTOF(s_meshPaths); ++ii)
  241. {
  242. m_meshes[ii] = meshLoad(s_meshPaths[ii]);
  243. }
  244. // Randomly create some models
  245. bx::RngMwc mwc;
  246. for (uint32_t ii = 0; ii < BX_COUNTOF(m_models); ++ii)
  247. {
  248. Model& model = m_models[ii];
  249. model.mesh = mwc.gen() % BX_COUNTOF(s_meshPaths);
  250. model.position[0] = ( ( (mwc.gen() % 256) ) - 128.0f) / 20.0f;
  251. model.position[1] = 0;
  252. model.position[2] = ( ( (mwc.gen() % 256) ) - 128.0f) / 20.0f;
  253. }
  254. // Load ground, just use the cube
  255. m_ground = meshLoad("meshes/cube.bin");
  256. m_groundTexture = loadTexture("textures/fieldstone-rgba.dds");
  257. m_normalTexture = loadTexture("textures/fieldstone-n.dds");
  258. m_recreateFrameBuffers = false;
  259. createFramebuffers();
  260. // Vertex decl
  261. PosTexCoord0Vertex::init();
  262. // Init camera
  263. cameraCreate();
  264. cameraSetPosition({ 0.0f, 1.5f, 0.0f });
  265. cameraSetVerticalAngle(-0.3f);
  266. m_fovY = 60.0f;
  267. // Init "prev" matrices, will be same for first frame
  268. cameraGetViewMtx(m_view);
  269. bx::mtxProj(m_proj, m_fovY, float(m_size[0]) / float(m_size[1]), 0.01f, 100.0f, bgfx::getCaps()->homogeneousDepth);
  270. mat4Set(m_worldToViewPrev, m_view);
  271. mat4Set(m_viewToProjPrev, m_proj);
  272. // Track whether previous results are valid
  273. m_havePrevious = false;
  274. // Get renderer capabilities info.
  275. const bgfx::RendererType::Enum renderer = bgfx::getRendererType();
  276. m_texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;
  277. imguiCreate();
  278. }
  279. int32_t shutdown() override
  280. {
  281. for (uint32_t ii = 0; ii < BX_COUNTOF(s_meshPaths); ++ii)
  282. {
  283. meshUnload(m_meshes[ii]);
  284. }
  285. meshUnload(m_ground);
  286. bgfx::destroy(m_normalTexture);
  287. bgfx::destroy(m_groundTexture);
  288. bgfx::destroy(m_gbufferProgram);
  289. bgfx::destroy(m_combineProgram);
  290. bgfx::destroy(m_copyProgram);
  291. bgfx::destroy(m_denoiseTemporalProgram);
  292. bgfx::destroy(m_denoiseSpatialProgram3x3);
  293. bgfx::destroy(m_denoiseSpatialProgram5x5);
  294. bgfx::destroy(m_denoiseApplyLighting);
  295. bgfx::destroy(m_txaaProgram);
  296. m_uniforms.destroy();
  297. bgfx::destroy(s_albedo);
  298. bgfx::destroy(s_color);
  299. bgfx::destroy(s_normal);
  300. bgfx::destroy(s_velocity);
  301. bgfx::destroy(s_depth);
  302. bgfx::destroy(s_previousColor);
  303. bgfx::destroy(s_previousNormal);
  304. destroyFramebuffers();
  305. cameraDestroy();
  306. imguiDestroy();
  307. bgfx::shutdown();
  308. return 0;
  309. }
  310. bool update() override
  311. {
  312. if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
  313. {
  314. // skip processing when minimized, otherwise crashing
  315. if (0 == m_width
  316. || 0 == m_height)
  317. {
  318. return true;
  319. }
  320. // Update frame timer
  321. int64_t now = bx::getHPCounter();
  322. static int64_t last = now;
  323. const int64_t frameTime = now - last;
  324. last = now;
  325. const double freq = double(bx::getHPFrequency() );
  326. const float deltaTime = float(frameTime / freq);
  327. const bgfx::Caps* caps = bgfx::getCaps();
  328. if (m_size[0] != (int32_t)m_width
  329. || m_size[1] != (int32_t)m_height
  330. || m_recreateFrameBuffers)
  331. {
  332. destroyFramebuffers();
  333. createFramebuffers();
  334. m_recreateFrameBuffers = false;
  335. }
  336. // Update camera
  337. cameraUpdate(deltaTime*0.15f, m_mouseState, ImGui::MouseOverArea() );
  338. // Set up matrices for gbuffer
  339. cameraGetViewMtx(m_view);
  340. updateUniforms();
  341. bx::mtxProj(m_proj, m_fovY, float(m_size[0]) / float(m_size[1]), 0.01f, 100.0f, caps->homogeneousDepth);
  342. bx::mtxProj(m_proj2, m_fovY, float(m_size[0]) / float(m_size[1]), 0.01f, 100.0f, false);
  343. if (m_enableTxaa)
  344. {
  345. m_proj[2*4+0] += m_jitter[0] * (2.0f / m_size[0]);
  346. m_proj[2*4+1] -= m_jitter[1] * (2.0f / m_size[1]);
  347. }
  348. bgfx::ViewId view = 0;
  349. // Draw everything into gbuffer
  350. {
  351. bgfx::setViewName(view, "GBuffer");
  352. bgfx::setViewClear(view
  353. , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
  354. , 0
  355. , 1.0f
  356. , 0
  357. );
  358. bgfx::setViewRect(view, 0, 0, uint16_t(m_size[0]), uint16_t(m_size[1]) );
  359. bgfx::setViewTransform(view, m_view, m_proj);
  360. // Make sure when we draw it goes into gbuffer and not backbuffer
  361. bgfx::setViewFrameBuffer(view, m_gbuffer);
  362. bgfx::setState(0
  363. | BGFX_STATE_WRITE_RGB
  364. | BGFX_STATE_WRITE_A
  365. | BGFX_STATE_WRITE_Z
  366. | BGFX_STATE_DEPTH_TEST_LESS
  367. );
  368. drawAllModels(view, m_gbufferProgram, m_uniforms);
  369. ++view;
  370. }
  371. float orthoProj[16];
  372. bx::mtxOrtho(orthoProj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, caps->homogeneousDepth);
  373. // Shade gbuffer
  374. {
  375. bgfx::setViewName(view, "Combine");
  376. // for some reason, previous draws texture lingering in transform stack
  377. // need to clear out, otherwise this copy is garbled. this used to work
  378. // and broke after updating, but i last updated like 2 years ago.
  379. float identity[16];
  380. bx::mtxIdentity(identity);
  381. bgfx::setTransform(identity);
  382. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  383. bgfx::setViewTransform(view, NULL, orthoProj);
  384. bgfx::setViewFrameBuffer(view, m_currentColor.m_buffer);
  385. bgfx::setState(0
  386. | BGFX_STATE_WRITE_RGB
  387. | BGFX_STATE_WRITE_A
  388. | BGFX_STATE_DEPTH_TEST_ALWAYS
  389. );
  390. bgfx::setTexture(0, s_color, m_gbufferTex[GBUFFER_RT_COLOR]);
  391. bgfx::setTexture(1, s_normal, m_gbufferTex[GBUFFER_RT_NORMAL]);
  392. m_uniforms.submit();
  393. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  394. bgfx::submit(view, m_combineProgram);
  395. ++view;
  396. }
  397. // update last texture written, to chain passes together
  398. bgfx::TextureHandle lastTex = m_currentColor.m_texture;
  399. // denoise temporal pass
  400. if (m_useTemporalPass && m_havePrevious)
  401. {
  402. bgfx::setViewName(view, "Denoise Temporal");
  403. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  404. bgfx::setViewTransform(view, NULL, orthoProj);
  405. bgfx::setViewFrameBuffer(view, m_temporaryColor.m_buffer);
  406. bgfx::setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_DEPTH_TEST_ALWAYS);
  407. // want color, prevColor
  408. // normal, prevNormal
  409. // depth, prevDepth to reject previous samples from accumulating - skipping depth for now
  410. bgfx::setTexture(0, s_color, lastTex);
  411. bgfx::setTexture(1, s_normal, m_gbufferTex[GBUFFER_RT_NORMAL]);
  412. bgfx::setTexture(2, s_velocity, m_gbufferTex[GBUFFER_RT_VELOCITY]);
  413. bgfx::setTexture(3, s_previousColor, m_previousDenoise.m_texture);
  414. bgfx::setTexture(4, s_previousNormal, m_previousNormal.m_texture);
  415. m_uniforms.submit();
  416. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  417. bgfx::submit(view, m_denoiseTemporalProgram);
  418. ++view;
  419. lastTex = m_temporaryColor.m_texture;
  420. }
  421. // denoise spatial passes
  422. if (0 < m_denoisePasses)
  423. {
  424. // variable number of passes for denoise, alternate between two textures/buffers
  425. bgfx::FrameBufferHandle destBuffer[] =
  426. {
  427. m_previousDenoise.m_buffer,
  428. m_currentColor.m_buffer,
  429. m_temporaryColor.m_buffer,
  430. m_currentColor.m_buffer,
  431. m_temporaryColor.m_buffer,
  432. m_currentColor.m_buffer,
  433. };
  434. BX_STATIC_ASSERT(BX_COUNTOF(destBuffer) == DENOISE_MAX_PASSES);
  435. const uint32_t denoisePasses = bx::min(DENOISE_MAX_PASSES, m_denoisePasses);
  436. for (uint32_t ii = 0; ii < denoisePasses; ++ii)
  437. {
  438. char name[64];
  439. bx::snprintf(name, BX_COUNTOF(name), "Denoise %d/%d", ii, denoisePasses-1);
  440. bgfx::setViewName(view, name);
  441. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  442. bgfx::setViewTransform(view, NULL, orthoProj);
  443. bgfx::setViewFrameBuffer(view, destBuffer[ii]);
  444. bgfx::setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_DEPTH_TEST_ALWAYS);
  445. bgfx::setTexture(0, s_color, lastTex);
  446. bgfx::setTexture(1, s_normal, m_gbufferTex[GBUFFER_RT_NORMAL]);
  447. bgfx::setTexture(2, s_depth, m_gbufferTex[GBUFFER_RT_DEPTH]);
  448. // need to update some denoise uniforms per draw
  449. const float denoiseStepScale = bx::pow(2.0f, float(ii) );
  450. m_uniforms.m_denoiseStep = denoiseStepScale;
  451. m_uniforms.submit();
  452. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  453. const bgfx::ProgramHandle spatialProgram = (0 == m_spatialSampleType)
  454. ? m_denoiseSpatialProgram3x3
  455. : m_denoiseSpatialProgram5x5
  456. ;
  457. bgfx::submit(view, spatialProgram);
  458. ++view;
  459. if (m_previousDenoise.m_buffer.idx == destBuffer[ii].idx)
  460. {
  461. lastTex = m_previousDenoise.m_texture;
  462. }
  463. else if (m_temporaryColor.m_buffer.idx == destBuffer[ii].idx)
  464. {
  465. lastTex = m_temporaryColor.m_texture;
  466. }
  467. else
  468. {
  469. lastTex = m_currentColor.m_texture;
  470. }
  471. }
  472. }
  473. else
  474. {
  475. // need color result for temporal denoise if not supplied by spatial pass
  476. // (per SVGF paper, reuse previous frame's first spatial pass output as previous color
  477. bgfx::setViewName(view, "Copy Color for Temporal Denoise");
  478. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  479. bgfx::setViewTransform(view, NULL, orthoProj);
  480. bgfx::setViewFrameBuffer(view, m_previousDenoise.m_buffer);
  481. bgfx::setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_DEPTH_TEST_ALWAYS);
  482. bgfx::setTexture(0, s_color, lastTex);
  483. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  484. bgfx::submit(view, m_copyProgram);
  485. ++view;
  486. }
  487. // apply lighting
  488. {
  489. bgfx::setViewName(view, "Apply Lighting");
  490. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  491. bgfx::setViewTransform(view, NULL, orthoProj);
  492. bgfx::FrameBufferHandle destBuffer = (lastTex.idx == m_currentColor.m_texture.idx)
  493. ? m_temporaryColor.m_buffer
  494. : m_currentColor.m_buffer
  495. ;
  496. bgfx::setViewFrameBuffer(view, destBuffer);
  497. bgfx::setState(0
  498. | BGFX_STATE_WRITE_RGB
  499. | BGFX_STATE_WRITE_A
  500. | BGFX_STATE_DEPTH_TEST_ALWAYS
  501. );
  502. bgfx::setTexture(0, s_color, lastTex);
  503. bgfx::setTexture(1, s_albedo, m_gbufferTex[GBUFFER_RT_COLOR]);
  504. m_uniforms.submit();
  505. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  506. bgfx::submit(view, m_denoiseApplyLighting);
  507. ++view;
  508. lastTex = (m_temporaryColor.m_buffer.idx == destBuffer.idx)
  509. ? m_temporaryColor.m_texture
  510. : m_currentColor.m_texture
  511. ;
  512. }
  513. if (m_enableTxaa)
  514. {
  515. // Draw txaa to txaa buffer
  516. {
  517. bgfx::setViewName(view, "Temporal AA");
  518. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  519. bgfx::setViewTransform(view, NULL, orthoProj);
  520. bgfx::setViewFrameBuffer(view, m_txaaColor.m_buffer);
  521. bgfx::setState(0
  522. | BGFX_STATE_WRITE_RGB
  523. | BGFX_STATE_WRITE_A
  524. | BGFX_STATE_DEPTH_TEST_ALWAYS
  525. );
  526. bgfx::setTexture(0, s_color, lastTex);
  527. bgfx::setTexture(1, s_previousColor, m_previousColor.m_texture);
  528. bgfx::setTexture(2, s_velocity, m_gbufferTex[GBUFFER_RT_VELOCITY]);
  529. bgfx::setTexture(3, s_depth, m_gbufferTex[GBUFFER_RT_DEPTH]);
  530. m_uniforms.submit();
  531. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  532. bgfx::submit(view, m_txaaProgram);
  533. ++view;
  534. }
  535. // Copy txaa result to previous
  536. {
  537. bgfx::setViewName(view, "Copy to Previous");
  538. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  539. bgfx::setViewTransform(view, NULL, orthoProj);
  540. bgfx::setViewFrameBuffer(view, m_previousColor.m_buffer);
  541. bgfx::setState(0
  542. | BGFX_STATE_WRITE_RGB
  543. | BGFX_STATE_WRITE_A
  544. | BGFX_STATE_DEPTH_TEST_ALWAYS
  545. );
  546. bgfx::setTexture(0, s_color, m_txaaColor.m_texture);
  547. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  548. bgfx::submit(view, m_copyProgram);
  549. ++view;
  550. }
  551. // Copy txaa result to swap chain
  552. {
  553. bgfx::setViewName(view, "Display");
  554. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  555. bgfx::setViewTransform(view, NULL, orthoProj);
  556. bgfx::setViewFrameBuffer(view, BGFX_INVALID_HANDLE);
  557. bgfx::setState(0
  558. | BGFX_STATE_WRITE_RGB
  559. | BGFX_STATE_WRITE_A
  560. | BGFX_STATE_DEPTH_TEST_ALWAYS
  561. );
  562. bgfx::setTexture(0, s_color, m_txaaColor.m_texture);
  563. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  564. bgfx::submit(view, m_copyProgram);
  565. ++view;
  566. }
  567. }
  568. else
  569. {
  570. // Copy color result to swap chain
  571. {
  572. bgfx::setViewName(view, "Display");
  573. bgfx::setViewClear(view
  574. , BGFX_CLEAR_NONE
  575. , 0
  576. , 1.0f
  577. , 0
  578. );
  579. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  580. bgfx::setViewTransform(view, NULL, orthoProj);
  581. bgfx::setViewFrameBuffer(view, BGFX_INVALID_HANDLE);
  582. bgfx::setState(0
  583. | BGFX_STATE_WRITE_RGB
  584. | BGFX_STATE_WRITE_A
  585. );
  586. bgfx::setTexture(0, s_color, lastTex);
  587. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  588. bgfx::submit(view, m_copyProgram);
  589. ++view;
  590. }
  591. }
  592. // copy the normal buffer for next time
  593. {
  594. bgfx::setViewName(view, "Copy Normals");
  595. bgfx::setViewRect(view, 0, 0, uint16_t(m_width), uint16_t(m_height) );
  596. bgfx::setViewTransform(view, NULL, orthoProj);
  597. bgfx::setViewFrameBuffer(view, m_previousNormal.m_buffer);
  598. bgfx::setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_DEPTH_TEST_ALWAYS);
  599. bgfx::setTexture(0, s_color, m_gbufferTex[GBUFFER_RT_NORMAL]);
  600. screenSpaceQuad(float(m_width), float(m_height), m_texelHalf, caps->originBottomLeft);
  601. bgfx::submit(view, m_copyProgram);
  602. ++view;
  603. // update previous status
  604. m_havePrevious = true;
  605. }
  606. // Copy matrices for next time
  607. mat4Set(m_worldToViewPrev, m_view);
  608. mat4Set(m_viewToProjPrev, m_proj);
  609. // Draw UI
  610. imguiBeginFrame(m_mouseState.m_mx
  611. , m_mouseState.m_my
  612. , (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
  613. | (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
  614. | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
  615. , m_mouseState.m_mz
  616. , uint16_t(m_width)
  617. , uint16_t(m_height)
  618. );
  619. showExampleDialog(this);
  620. ImGui::SetNextWindowPos(
  621. ImVec2(m_width - m_width / 4.0f - 10.0f, 10.0f)
  622. , ImGuiCond_FirstUseEver
  623. );
  624. ImGui::SetNextWindowSize(
  625. ImVec2(m_width / 4.0f, m_height / 1.24f)
  626. , ImGuiCond_FirstUseEver
  627. );
  628. ImGui::Begin("Settings"
  629. , NULL
  630. , 0
  631. );
  632. ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
  633. {
  634. ImGui::TextWrapped(
  635. "In this demo, noise is added to results of deferred lighting. Then denoise is applied "
  636. "before multiplying the lit result with gbuffer albedo. Optionally, temporal antialiasing "
  637. "can be applied after that. (off by default, implementation blurry)");
  638. ImGui::Separator();
  639. ImGui::Text("noise controls:");
  640. ImGui::Combo("pattern", &m_noiseType, "none\0dither\0random\0\0");
  641. if (ImGui::IsItemHovered() )
  642. {
  643. ImGui::BeginTooltip();
  644. ImGui::Text("none");
  645. ImGui::BulletText("compare denoised results to this");
  646. ImGui::BulletText("brighter than noisy images, not losing any pixel's energy");
  647. ImGui::Text("dither");
  648. ImGui::BulletText("reject 3 out of 4 pixels in 2x2 pattern");
  649. ImGui::BulletText("could represent lower resolution signal");
  650. ImGui::Text("random");
  651. ImGui::BulletText("reject about half pixels, using common shader random");
  652. ImGui::BulletText("could represent monte carlo something or other");
  653. ImGui::EndTooltip();
  654. }
  655. ImGui::Checkbox("dynamic noise", &m_dynamicNoise);
  656. if (ImGui::IsItemHovered() )
  657. {
  658. ImGui::SetTooltip("update noise pattern each frame");
  659. }
  660. ImGui::Separator();
  661. }
  662. {
  663. ImGui::Text("temporal denoise pass controls:");
  664. ImGui::Checkbox("use temporal pass", &m_useTemporalPass);
  665. ImGui::Separator();
  666. }
  667. {
  668. ImGui::Text("spatial denoise pass controls:");
  669. ImGui::SliderInt("spatial passes", &m_denoisePasses, 0, DENOISE_MAX_PASSES);
  670. if (ImGui::IsItemHovered() )
  671. {
  672. ImGui::SetTooltip("set passes to 0 to turn off spatial denoise");
  673. }
  674. ImGui::Combo("spatial sample extent", &m_spatialSampleType, "three\0five\0\0");
  675. if (ImGui::IsItemHovered() )
  676. {
  677. ImGui::SetTooltip("select 3x3 or 5x5 filter kernal");
  678. }
  679. ImGui::SliderFloat("sigma z", &m_sigmaDepth, 0.0f, 0.1f, "%.5f");
  680. if (ImGui::IsItemHovered() )
  681. {
  682. ImGui::SetTooltip("lower sigma z, pickier blending across depth edges");
  683. }
  684. ImGui::SliderFloat("sigma n", &m_sigmaNormal, 1.0f, 256.0f);
  685. if (ImGui::IsItemHovered() )
  686. {
  687. ImGui::SetTooltip("higher sigma n, pickier blending across normal edges");
  688. }
  689. ImGui::Separator();
  690. }
  691. if (ImGui::CollapsingHeader("TXAA options") )
  692. {
  693. ImGui::Checkbox("use TXAA", &m_enableTxaa);
  694. ImGui::Checkbox("apply extra blur to current color", &m_applyMitchellFilter);
  695. if (ImGui::IsItemHovered() )
  696. {
  697. ImGui::SetTooltip("reduces flicker/crawl on thin features, maybe too much!");
  698. }
  699. ImGui::SliderFloat("feedback min", &m_feedbackMin, 0.0f, 1.0f);
  700. if (ImGui::IsItemHovered() )
  701. {
  702. ImGui::SetTooltip("minimum amount of previous frame to blend in");
  703. }
  704. ImGui::SliderFloat("feedback max", &m_feedbackMax, 0.0f, 1.0f);
  705. if (ImGui::IsItemHovered() )
  706. {
  707. ImGui::SetTooltip("maximum amount of previous frame to blend in");
  708. }
  709. ImGui::Checkbox("debug TXAA with slow frame rate", &m_useTxaaSlow);
  710. if (ImGui::IsItemHovered() )
  711. {
  712. ImGui::BeginTooltip();
  713. ImGui::Text("sleep 100ms per frame to highlight temporal artifacts");
  714. ImGui::Text("high framerate compensates for flickering, masking issues");
  715. ImGui::EndTooltip();
  716. }
  717. ImGui::Separator();
  718. }
  719. ImGui::End();
  720. imguiEndFrame();
  721. // Advance to next frame. Rendering thread will be kicked to
  722. // process submitted rendering primitives.
  723. m_currFrame = bgfx::frame();
  724. // add artificial wait to emphasize txaa behavior
  725. if (m_useTxaaSlow)
  726. {
  727. bx::sleep(100);
  728. }
  729. return true;
  730. }
  731. return false;
  732. }
  733. void drawAllModels(bgfx::ViewId _pass, bgfx::ProgramHandle _program, const Uniforms & _uniforms)
  734. {
  735. for (uint32_t ii = 0; ii < BX_COUNTOF(m_models); ++ii)
  736. {
  737. const Model& model = m_models[ii];
  738. // Set up transform matrix for each model
  739. const float scale = s_meshScale[model.mesh];
  740. float mtx[16];
  741. bx::mtxSRT(mtx
  742. , scale
  743. , scale
  744. , scale
  745. , 0.0f
  746. , 0.0f
  747. , 0.0f
  748. , model.position[0]
  749. , model.position[1]
  750. , model.position[2]
  751. );
  752. // Submit mesh to gbuffer
  753. bgfx::setTexture(0, s_albedo, m_groundTexture);
  754. bgfx::setTexture(1, s_normal, m_normalTexture);
  755. _uniforms.submit();
  756. meshSubmit(m_meshes[model.mesh], _pass, _program, mtx);
  757. }
  758. // Draw ground
  759. float mtxScale[16];
  760. const float scale = 10.0f;
  761. bx::mtxScale(mtxScale, scale, scale, scale);
  762. float mtxTranslate[16];
  763. bx::mtxTranslate(mtxTranslate
  764. , 0.0f
  765. , -10.0f
  766. , 0.0f
  767. );
  768. float mtx[16];
  769. bx::mtxMul(mtx, mtxScale, mtxTranslate);
  770. bgfx::setTexture(0, s_albedo, m_groundTexture);
  771. bgfx::setTexture(1, s_normal, m_normalTexture);
  772. _uniforms.submit();
  773. meshSubmit(m_ground, _pass, _program, mtx);
  774. }
  775. void createFramebuffers()
  776. {
  777. m_size[0] = m_width;
  778. m_size[1] = m_height;
  779. const uint64_t bilinearFlags = 0
  780. | BGFX_TEXTURE_RT
  781. | BGFX_SAMPLER_U_CLAMP
  782. | BGFX_SAMPLER_V_CLAMP
  783. ;
  784. const uint64_t pointSampleFlags = bilinearFlags
  785. | BGFX_SAMPLER_MIN_POINT
  786. | BGFX_SAMPLER_MAG_POINT
  787. | BGFX_SAMPLER_MIP_POINT
  788. ;
  789. m_gbufferTex[GBUFFER_RT_COLOR] = bgfx::createTexture2D(uint16_t(m_size[0]), uint16_t(m_size[1]), false, 1, bgfx::TextureFormat::BGRA8, pointSampleFlags);
  790. m_gbufferTex[GBUFFER_RT_NORMAL] = bgfx::createTexture2D(uint16_t(m_size[0]), uint16_t(m_size[1]), false, 1, bgfx::TextureFormat::BGRA8, pointSampleFlags);
  791. m_gbufferTex[GBUFFER_RT_VELOCITY] = bgfx::createTexture2D(uint16_t(m_size[0]), uint16_t(m_size[1]), false, 1, bgfx::TextureFormat::RG16F, pointSampleFlags);
  792. m_gbufferTex[GBUFFER_RT_DEPTH] = bgfx::createTexture2D(uint16_t(m_size[0]), uint16_t(m_size[1]), false, 1, bgfx::TextureFormat::D32F , pointSampleFlags);
  793. m_gbuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_gbufferTex), m_gbufferTex, true);
  794. m_currentColor.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, bilinearFlags);
  795. m_previousColor.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, bilinearFlags);
  796. m_txaaColor.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, bilinearFlags);
  797. m_temporaryColor.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, bilinearFlags);
  798. m_previousNormal.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, pointSampleFlags);
  799. m_previousDenoise.init(m_size[0], m_size[1], bgfx::TextureFormat::RG11B10F, bilinearFlags);
  800. }
  801. // all buffers set to destroy their textures
  802. void destroyFramebuffers()
  803. {
  804. bgfx::destroy(m_gbuffer);
  805. m_currentColor.destroy();
  806. m_previousColor.destroy();
  807. m_txaaColor.destroy();
  808. m_temporaryColor.destroy();
  809. m_previousNormal.destroy();
  810. m_previousDenoise.destroy();
  811. }
  812. void updateUniforms()
  813. {
  814. {
  815. uint32_t idx = m_currFrame % 8;
  816. const float offsets[] =
  817. {
  818. (1.0f/ 2.0f), (1.0f/3.0f),
  819. (1.0f/ 4.0f), (2.0f/3.0f),
  820. (3.0f/ 4.0f), (1.0f/9.0f),
  821. (1.0f/ 8.0f), (4.0f/9.0f),
  822. (5.0f/ 8.0f), (7.0f/9.0f),
  823. (3.0f/ 8.0f), (2.0f/9.0f),
  824. (7.0f/ 8.0f), (5.0f/9.0f),
  825. (1.0f/16.0f), (8.0f/9.0f),
  826. };
  827. // Strange constant for jitterX is because 8 values from halton2
  828. // sequence above do not average out to 0.5, 1/16 skews it to the
  829. // left. Subtracting a smaller value to center the range of jitter
  830. // around 0. Not necessary for jitterY. Not confident this makes sense...
  831. const float jitterX = 1.0f * (offsets[2*idx] - (7.125f/16.0f) );
  832. const float jitterY = 1.0f * (offsets[2*idx+1] - 0.5f);
  833. vec2Set(m_uniforms.m_cameraJitterCurr, jitterX, jitterY);
  834. vec2Set(m_uniforms.m_cameraJitterPrev, m_jitter[0], m_jitter[1]);
  835. m_jitter[0] = jitterX;
  836. m_jitter[1] = jitterY;
  837. }
  838. m_uniforms.m_feedbackMin = m_feedbackMin;
  839. m_uniforms.m_feedbackMax = m_feedbackMax;
  840. m_uniforms.m_applyMitchellFilter = m_applyMitchellFilter ? 1.0f : 0.0f;
  841. mat4Set(m_uniforms.m_worldToViewPrev, m_worldToViewPrev);
  842. mat4Set(m_uniforms.m_viewToProjPrev, m_viewToProjPrev);
  843. m_uniforms.m_frameOffsetForNoise = m_dynamicNoise
  844. ? float(m_currFrame % 8)
  845. : 0.0f
  846. ;
  847. m_uniforms.m_noiseType = float(m_noiseType);
  848. m_uniforms.m_sigmaDepth = m_sigmaDepth;
  849. m_uniforms.m_sigmaNormal = m_sigmaNormal;
  850. }
  851. uint32_t m_width;
  852. uint32_t m_height;
  853. uint32_t m_debug;
  854. uint32_t m_reset;
  855. entry::MouseState m_mouseState;
  856. // Resource handles
  857. bgfx::ProgramHandle m_gbufferProgram;
  858. bgfx::ProgramHandle m_combineProgram;
  859. bgfx::ProgramHandle m_copyProgram;
  860. bgfx::ProgramHandle m_denoiseTemporalProgram;
  861. bgfx::ProgramHandle m_denoiseSpatialProgram3x3;
  862. bgfx::ProgramHandle m_denoiseSpatialProgram5x5;
  863. bgfx::ProgramHandle m_denoiseApplyLighting;
  864. bgfx::ProgramHandle m_txaaProgram;
  865. // Shader uniforms
  866. Uniforms m_uniforms;
  867. // Uniforms to indentify texture samplers
  868. bgfx::UniformHandle s_albedo;
  869. bgfx::UniformHandle s_color;
  870. bgfx::UniformHandle s_normal;
  871. bgfx::UniformHandle s_velocity;
  872. bgfx::UniformHandle s_depth;
  873. bgfx::UniformHandle s_previousColor;
  874. bgfx::UniformHandle s_previousNormal;
  875. bgfx::FrameBufferHandle m_gbuffer;
  876. bgfx::TextureHandle m_gbufferTex[GBUFFER_RENDER_TARGETS];
  877. RenderTarget m_currentColor;
  878. RenderTarget m_previousColor;
  879. RenderTarget m_txaaColor;
  880. RenderTarget m_temporaryColor; // need another buffer to ping-pong results
  881. RenderTarget m_previousNormal;
  882. RenderTarget m_previousDenoise; // color output by first spatial denoise pass, input to next frame as previous color
  883. struct Model
  884. {
  885. uint32_t mesh; // Index of mesh in m_meshes
  886. float position[3];
  887. };
  888. Model m_models[MODEL_COUNT];
  889. Mesh* m_meshes[BX_COUNTOF(s_meshPaths)];
  890. Mesh* m_ground;
  891. bgfx::TextureHandle m_groundTexture;
  892. bgfx::TextureHandle m_normalTexture;
  893. uint32_t m_currFrame;
  894. float m_texelHalf = 0.0f;
  895. float m_fovY = 60.0f;
  896. bool m_recreateFrameBuffers = false;
  897. bool m_havePrevious = false;
  898. float m_view[16];
  899. float m_proj[16];
  900. float m_proj2[16];
  901. float m_viewToProjPrev[16];
  902. float m_worldToViewPrev[16];
  903. float m_jitter[2];
  904. int32_t m_size[2];
  905. // UI parameters
  906. int32_t m_noiseType = 2;
  907. int32_t m_spatialSampleType = 1;
  908. int32_t m_denoisePasses = 5;
  909. float m_sigmaDepth = 0.05f;
  910. float m_sigmaNormal = 128.0f;
  911. float m_feedbackMin = 0.8f;
  912. float m_feedbackMax = 0.95f;
  913. bool m_dynamicNoise = true;
  914. bool m_useTemporalPass = true;
  915. bool m_enableTxaa = false;
  916. bool m_applyMitchellFilter = true;
  917. bool m_useTxaaSlow = false;
  918. };
  919. } // namespace
  920. ENTRY_IMPLEMENT_MAIN(ExampleDenoise, "43-denoise", "Denoise.");