mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0028114: Visualization, Path tracing - Make path tracing mode interactive in high resolutions
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
|
||||
#ifdef PATH_TRACING
|
||||
|
||||
//! Number of previously rendered frames.
|
||||
uniform int uAccumSamples;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// Specific data types
|
||||
|
||||
@@ -677,6 +680,9 @@ vec3 IntersectLight (in SRay theRay, in int theDepth, in float theHitDistance, o
|
||||
// Enables expiremental russian roulette sampling
|
||||
#define RUSSIAN_ROULETTE
|
||||
|
||||
//! Frame step to increase number of bounces
|
||||
#define FRAME_STEP 5
|
||||
|
||||
//=======================================================================
|
||||
// function : PathTrace
|
||||
// purpose : Calculates radiance along the given ray
|
||||
@@ -832,7 +838,7 @@ vec4 PathTrace (in SRay theRay, in vec3 theInverse)
|
||||
aSurvive = aDepth < 3 ? 1.f : min (dot (LUMA, aThroughput), 0.95f);
|
||||
#endif
|
||||
|
||||
if (RandFloat() > aSurvive || all (lessThanEqual (aThroughput, MIN_THROUGHPUT)))
|
||||
if (RandFloat() > aSurvive || all (lessThan (aThroughput, MIN_THROUGHPUT)) || aDepth >= uAccumSamples / FRAME_STEP + step (1.f / M_PI, aImpPDF))
|
||||
{
|
||||
aDepth = INVALID_BOUNCES; // terminate path
|
||||
}
|
||||
|
@@ -9,10 +9,7 @@ uniform int uFrameRndSeed;
|
||||
uniform int uBlockedRngEnabled;
|
||||
|
||||
#ifndef ADAPTIVE_SAMPLING
|
||||
//! Weight of current frame related to accumulated samples.
|
||||
uniform float uSampleWeight;
|
||||
|
||||
//! Input accumulated image.
|
||||
//! Input image with previously accumulated samples.
|
||||
uniform sampler2D uAccumTexture;
|
||||
#endif
|
||||
|
||||
@@ -95,13 +92,13 @@ void main (void)
|
||||
|
||||
#else
|
||||
|
||||
if (uSampleWeight >= 1.f)
|
||||
if (uAccumSamples == 0)
|
||||
{
|
||||
OutColor = aColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, uSampleWeight);
|
||||
OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, 1.f / (uAccumSamples + 1));
|
||||
}
|
||||
|
||||
#endif // ADAPTIVE_SAMPLING
|
||||
|
@@ -15,6 +15,9 @@ static const char Shaders_PathtraceBase_fs[] =
|
||||
"\n"
|
||||
"#ifdef PATH_TRACING\n"
|
||||
"\n"
|
||||
"//! Number of previously rendered frames.\n"
|
||||
"uniform int uAccumSamples;\n"
|
||||
"\n"
|
||||
"///////////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"// Specific data types\n"
|
||||
"\n"
|
||||
@@ -680,6 +683,9 @@ static const char Shaders_PathtraceBase_fs[] =
|
||||
"// Enables expiremental russian roulette sampling\n"
|
||||
"#define RUSSIAN_ROULETTE\n"
|
||||
"\n"
|
||||
"//! Frame step to increase number of bounces\n"
|
||||
"#define FRAME_STEP 5\n"
|
||||
"\n"
|
||||
"//=======================================================================\n"
|
||||
"// function : PathTrace\n"
|
||||
"// purpose : Calculates radiance along the given ray\n"
|
||||
@@ -835,7 +841,7 @@ static const char Shaders_PathtraceBase_fs[] =
|
||||
" aSurvive = aDepth < 3 ? 1.f : min (dot (LUMA, aThroughput), 0.95f);\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
" if (RandFloat() > aSurvive || all (lessThanEqual (aThroughput, MIN_THROUGHPUT)))\n"
|
||||
" if (RandFloat() > aSurvive || all (lessThan (aThroughput, MIN_THROUGHPUT)) || aDepth >= uAccumSamples / FRAME_STEP + step (1.f / M_PI, aImpPDF))\n"
|
||||
" {\n"
|
||||
" aDepth = INVALID_BOUNCES; // terminate path\n"
|
||||
" }\n"
|
||||
|
@@ -12,10 +12,7 @@ static const char Shaders_RaytraceRender_fs[] =
|
||||
"uniform int uBlockedRngEnabled;\n"
|
||||
"\n"
|
||||
"#ifndef ADAPTIVE_SAMPLING\n"
|
||||
" //! Weight of current frame related to accumulated samples.\n"
|
||||
" uniform float uSampleWeight;\n"
|
||||
"\n"
|
||||
" //! Input accumulated image.\n"
|
||||
" //! Input image with previously accumulated samples.\n"
|
||||
" uniform sampler2D uAccumTexture;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
@@ -98,13 +95,13 @@ static const char Shaders_RaytraceRender_fs[] =
|
||||
"\n"
|
||||
"#else\n"
|
||||
"\n"
|
||||
" if (uSampleWeight >= 1.f)\n"
|
||||
" if (uAccumSamples == 0)\n"
|
||||
" {\n"
|
||||
" OutColor = aColor;\n"
|
||||
" }\n"
|
||||
" else\n"
|
||||
" {\n"
|
||||
" OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, uSampleWeight);\n"
|
||||
" OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, 1.f / (uAccumSamples + 1));\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"#endif // ADAPTIVE_SAMPLING\n"
|
||||
|
Reference in New Issue
Block a user