From 67fc43fae87694fada21f8b5d55a8fdba8673977 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Thu, 11 Jul 2024 02:47:09 -0700 Subject: [PATCH] [hdEmbree] fix for random number generation use of std::bind was copying the underlying random number generator before use, resulting in the exact same sequence getting reused for, ie, every AO calculation within a given tile-group --- pxr/imaging/plugin/hdEmbree/renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/imaging/plugin/hdEmbree/renderer.cpp b/pxr/imaging/plugin/hdEmbree/renderer.cpp index 13956c7b25..bbce00a8ef 100644 --- a/pxr/imaging/plugin/hdEmbree/renderer.cpp +++ b/pxr/imaging/plugin/hdEmbree/renderer.cpp @@ -503,7 +503,7 @@ HdEmbreeRenderer::_RenderTiles(HdRenderThread *renderThread, // Create a uniform distribution for jitter calculations. std::uniform_real_distribution uniform_dist(0.0f, 1.0f); - std::function uniform_float = std::bind(uniform_dist, random); + auto uniform_float = [&random, &uniform_dist]() { return uniform_dist(random); }; // _RenderTiles gets a range of tiles; iterate through them. for (unsigned int tile = tileStart; tile < tileEnd; ++tile) { @@ -923,7 +923,7 @@ HdEmbreeRenderer::_ComputeAmbientOcclusion(GfVec3f const& position, { // Create a uniform random distribution for AO calculations. std::uniform_real_distribution uniform_dist(0.0f, 1.0f); - std::function uniform_float = std::bind(uniform_dist, random); + auto uniform_float = [&random, &uniform_dist]() { return uniform_dist(random); }; // 0 ambient occlusion samples means disable the ambient occlusion term. if (_ambientOcclusionSamples < 1) {