"//! become structured. Can be used fo final rendering.\n"
"uniform int uBlockedRngEnabled;\n"
"\n"
+ "//! Number of previously rendered frames (used in non-ISS mode).\n"
+ "uniform int uAccumSamples;\n"
+ "\n"
"#ifndef ADAPTIVE_SAMPLING\n"
" //! Input image with previously accumulated samples.\n"
" uniform sampler2D uAccumTexture;\n"
"\n"
"#ifdef ADAPTIVE_SAMPLING\n"
"\n"
- " ivec2 aTileXY = imageLoad (uOffsetImage, ivec2 (aFragCoord.x / BLOCK_SIZE,\n"
- " aFragCoord.y / BLOCK_SIZE)).xy;\n"
+ " ivec2 aTileXY = imageLoad (uOffsetImage, aFragCoord / uTileSize).xy * uTileSize;\n"
+ " if (aTileXY.x < 0) { discard; }\n"
"\n"
- " ivec2 aRealBlockSize = ivec2 (min (uWinSizeX - aTileXY.x, BLOCK_SIZE),\n"
- " min (uWinSizeY - aTileXY.y, BLOCK_SIZE));\n"
+ " ivec2 aRealBlockSize = ivec2 (min (uWinSizeX - aTileXY.x, uTileSize.x),\n"
+ " min (uWinSizeY - aTileXY.y, uTileSize.y));\n"
"\n"
" aFragCoord.x = aTileXY.x + (aFragCoord.x % aRealBlockSize.x);\n"
" aFragCoord.y = aTileXY.y + (aFragCoord.y % aRealBlockSize.y);\n"
"\n"
"#ifdef PATH_TRACING\n"
"\n"
- " vec4 aColor = PathTrace (aRay, aInvDirect);\n"
+ "#ifndef ADAPTIVE_SAMPLING\n"
+ "\n"
+ " vec4 aColor = PathTrace (aRay, aInvDirect, uAccumSamples);\n"
+ "\n"
+ "#else\n"
+ "\n"
+ " float aNbSamples = imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
+ " 2 * aFragCoord.y + 1), 1.0);\n"
+ "\n"
+ " vec4 aColor = PathTrace (aRay, aInvDirect, int (aNbSamples));\n"
+ "\n"
+ "#endif\n"
"\n"
" if (any (isnan (aColor.rgb)))\n"
" {\n"
" imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
" 2 * aFragCoord.y + 1), aColor.w);\n"
"\n"
- " // accumulate number of samples\n"
- " float aNbSamples = imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
- " 2 * aFragCoord.y + 1), 1.0);\n"
- "\n"
" if (int (aNbSamples) % 2 == 0) // accumulate luminance for even samples only\n"
" {\n"
" imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
" 2 * aFragCoord.y + 0), dot (LUMA, aColor.rgb));\n"
" }\n"
"\n"
- " discard; // fragment should not be written to frame buffer\n"
- "\n"
"#else\n"
"\n"
" if (uAccumSamples == 0)\n"