diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index f7bd08ba15..27c76a7878 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -2396,6 +2396,11 @@ Standard_Boolean OpenGl_View::runRaytraceShaders (const Graphic3d_CView& if (myRaytraceParameters.GlobalIllumination) { + if (myAccumFrames == 0) + { + myRNG.SetSeed(); + } + // Set frame accumulation weight myRaytraceProgram->SetUniform (theGlContext, myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + 1)); diff --git a/src/math/math_BullardGenerator.hxx b/src/math/math_BullardGenerator.hxx index ff604ec720..4b682d2440 100644 --- a/src/math/math_BullardGenerator.hxx +++ b/src/math/math_BullardGenerator.hxx @@ -24,14 +24,21 @@ class math_BullardGenerator public: //! Creates new Xorshift 64-bit RNG. - Standard_EXPORT math_BullardGenerator(unsigned int theSeed = 1) - : myStateHi (theSeed) + math_BullardGenerator (unsigned int theSeed = 1) + : myStateHi (theSeed) { + SetSeed (theSeed); + } + + //! Setup new seed / reset defaults. + void SetSeed (unsigned int theSeed = 1) + { + myStateHi = theSeed; myStateLo = theSeed ^ 0x49616E42; } //! Generates new 64-bit integer value. - Standard_EXPORT unsigned int NextInt() + unsigned int NextInt() { myStateHi = (myStateHi >> 2) + (myStateHi << 2); @@ -42,7 +49,7 @@ public: } //! Generates new floating-point value. - Standard_EXPORT Standard_Real NextReal() + Standard_Real NextReal() { return NextInt() / static_cast (0xFFFFFFFFu); }