0028129: Visualization, Path Tracing - Improve interactivity in "steady" rendering...
[occt.git] / src / Shaders / Shaders_PathtraceBase_fs.pxx
index fb1746c..04cd95a 100644 (file)
@@ -15,9 +15,6 @@ 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"
@@ -703,17 +700,26 @@ static const char Shaders_PathtraceBase_fs[] =
   "#define MATERIAL_FRESNEL(index) (18 * index + 16)\n"
   "#define MATERIAL_ABSORPT(index) (18 * index + 17)\n"
   "\n"
-  "// Enables expiremental russian roulette sampling\n"
+  "//! Enables experimental russian roulette sampling path termination.\n"
+  "//! In most cases, it provides faster image convergence with minimal\n"
+  "//! bias, so it is enabled by default.\n"
   "#define RUSSIAN_ROULETTE\n"
   "\n"
-  "//! Frame step to increase number of bounces\n"
-  "#define FRAME_STEP 5\n"
+  "//! Frame step to increase number of bounces. This mode is used\n"
+  "//! for interaction with the model, when path length is limited\n"
+  "//! for the first samples, and gradually increasing when camera\n"
+  "//! is stabilizing.\n"
+  "#ifdef ADAPTIVE_SAMPLING\n"
+  "  #define FRAME_STEP 4\n"
+  "#else\n"
+  "  #define FRAME_STEP 5\n"
+  "#endif\n"
   "\n"
   "//=======================================================================\n"
   "// function : PathTrace\n"
   "// purpose  : Calculates radiance along the given ray\n"
   "//=======================================================================\n"
-  "vec4 PathTrace (in SRay theRay, in vec3 theInverse)\n"
+  "vec4 PathTrace (in SRay theRay, in vec3 theInverse, in int theNbSamples)\n"
   "{\n"
   "  float aRaytraceDepth = MAXFLOAT;\n"
   "\n"
@@ -870,7 +876,8 @@ 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 (lessThan (aThroughput, MIN_THROUGHPUT)) || aDepth >= uAccumSamples / FRAME_STEP + step (1.f / M_PI, aImpPDF))\n"
+  "    // here, we additionally increase path length for non-diffuse bounces\n"
+  "    if (RandFloat() > aSurvive || all (lessThan (aThroughput, MIN_THROUGHPUT)) || aDepth >= theNbSamples / FRAME_STEP + step (1.f / M_PI, aImpPDF))\n"
   "    {\n"
   "      aDepth = INVALID_BOUNCES; // terminate path\n"
   "    }\n"