"\n"
"#ifdef PATH_TRACING\n"
"\n"
- "//! Number of previously rendered frames.\n"
- "uniform int uAccumSamples;\n"
- "\n"
"///////////////////////////////////////////////////////////////////////////////////////\n"
"// Specific data types\n"
"\n"
"#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"
" 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"