Loading files
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// clang-format off
// This file has been automatically generated from resource file resources/Shaders/Display.fs
static const char Shaders_Display_fs[] =
"#ifdef ADAPTIVE_SAMPLING\n"
"\n"
" #extension GL_ARB_shader_image_load_store : require\n"
"\n"
" #extension GL_ARB_shader_image_size : enable\n"
"\n"
" //! OpenGL image used for accumulating rendering result.\n"
" volatile restrict layout(r32f) uniform image2D uRenderImage;\n"
"\n"
" //! OpenGL image storing variance of sampled pixels blocks.\n"
" volatile restrict layout(r32i) uniform iimage2D uVarianceImage;\n"
"\n"
" //! Scale factor used to quantize visual error (float) into signed integer.\n"
" uniform float uVarianceScaleFactor;\n"
"\n"
" //! Screen space tile size.\n"
" uniform ivec2 uTileSize;\n"
"\n"
"#else // ADAPTIVE_SAMPLING\n"
"\n"
" //! Input image.\n"
" uniform sampler2D uInputTexture;\n"
"\n"
" //! Ray tracing depth image.\n"
" uniform sampler2D uDepthTexture;\n"
"\n"
"#endif // ADAPTIVE_SAMPLING\n"
"\n"
"//! Number of accumulated frames.\n"
"uniform int uAccumFrames;\n"
"\n"
"//! Is debug mode enabled for importance screen sampling.\n"
"uniform int uDebugAdaptive;\n"
"\n"
"//! Exposure value for tone mapping.\n"
"uniform float uExposure;\n"
"\n"
"#ifdef TONE_MAPPING_FILMIC\n"
"\n"
"//! White point value for filmic tone mapping.\n"
"uniform float uWhitePoint;\n"
"\n"
"#endif // TONE_MAPPING\n"
"\n"
"//! Output pixel color.\n"
"out vec4 OutColor;\n"
"\n"
"//! RGB weight factors to calculate luminance.\n"
"#define LUMA vec3 (0.2126f, 0.7152f, 0.0722f)\n"
"\n"
"// =======================================================================\n"
"// function : ToneMappingFilmic\n"
"// purpose :\n"
"// =======================================================================\n"
"vec4 ToneMappingFilmic(vec4 theColor, float theWhitePoint)\n"
"{\n"
" vec4 aPackColor = vec4 (theColor.rgb, theWhitePoint);\n"
" vec4 aFilmicCurve = 1.425f * aPackColor + vec4 (0.05f);\n"
" vec4 aResultColor = (aPackColor * aFilmicCurve + vec4 (0.004f)) / (aPackColor * (aFilmicCurve + vec4 (0.55f)) + vec4 (0.0491f)) - vec4 (0.0821f);\n"
" return vec4 (aResultColor.rgb / aResultColor.www, 1.0);\n"
"}\n"
"\n"
"// =======================================================================\n"
"// function : main\n"
"// purpose :\n"
"// =======================================================================\n"
"void main (void)\n"
"{\n"
"#ifndef ADAPTIVE_SAMPLING\n"
"\n"
" vec4 aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);\n"
"\n"
"#ifdef PATH_TRACING\n"
" float aDepth = aColor.w; // path tracing uses averaged depth\n"
"#else\n"
" float aDepth = texelFetch (uDepthTexture, ivec2 (gl_FragCoord.xy), 0).r;\n"
"#endif\n"
"\n"
" gl_FragDepth = aDepth;\n"
"\n"
"#else // ADAPTIVE_SAMPLING\n"
"\n"
" ivec2 aPixel = ivec2 (gl_FragCoord.xy);\n"
"\n"
" vec4 aColor = vec4 (0.0);\n"
"\n"
" // fetch accumulated color and total number of samples\n"
" aColor.x = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 0,\n"
" 2 * aPixel.y + 0)).x;\n"
" aColor.y = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 1,\n"
" 2 * aPixel.y + 0)).x;\n"
" aColor.z = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 1,\n"
" 2 * aPixel.y + 1)).x;\n"
" aColor.w = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 0,\n"
" 2 * aPixel.y + 1)).x;\n"
"\n"
" // calculate normalization factor\n"
" float aSampleWeight = 1.f / max (1.0, aColor.w);\n"
"\n"
" // calculate averaged depth value\n"
" gl_FragDepth = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 2,\n"
" 2 * aPixel.y + 1)).x * aSampleWeight;\n"
"\n"
" // calculate averaged radiance for all samples and even samples only\n"
" float aHalfRad = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 2,\n"
" 2 * aPixel.y + 0)).x * aSampleWeight * 2.f;\n"
"\n"
" float aAverRad = dot (aColor.rgb, LUMA) * aSampleWeight;\n"
"\n"
" // apply our 'tone mapping' operator (gamma correction and clamping)\n"
" aHalfRad = min (1.f, sqrt (aHalfRad));\n"
" aAverRad = min (1.f, sqrt (aAverRad));\n"
"\n"
" // calculate visual error\n"
" float anError = (aAverRad - aHalfRad) * (aAverRad - aHalfRad);\n"
"\n"
" // accumulate visual error to current block; estimated error is written only\n"
" // after the first 40 samples and path length has reached 10 bounces or more\n"
" imageAtomicAdd (uVarianceImage, aPixel / uTileSize,\n"
" int (mix (uVarianceScaleFactor, anError * uVarianceScaleFactor, aColor.w > 40.f)));\n"
"\n"
" if (uDebugAdaptive == 0) // normal rendering\n"
" {\n"
" aColor = vec4 (aColor.rgb * aSampleWeight, 1.0);\n"
" }\n"
" else // showing number of samples\n"
" {\n"
" vec2 aRatio = vec2 (1.f, 1.f);\n"
"#ifdef GL_ARB_shader_image_size\n"
" aRatio = vec2 (imageSize (uRenderImage)) / vec2 (3.f * 512.f, 2.f * 512.f);\n"
"#endif\n"
" aColor = vec4 (0.5f * aColor.rgb * aSampleWeight + vec3 (0.f, sqrt (aRatio.x * aRatio.y) * aColor.w / uAccumFrames * 0.35f, 0.f), 1.0);\n"
" }\n"
"\n"
"#endif // ADAPTIVE_SAMPLING\n"
"\n"
"#ifdef PATH_TRACING\n"
"\n"
" aColor *= pow (2.0, uExposure);\n"
"\n"
"#ifdef TONE_MAPPING_FILMIC\n"
" aColor = ToneMappingFilmic (aColor, uWhitePoint);\n"
"#endif // TONE_MAPPING\n"
"\n"
"#ifdef THE_SHIFT_sRGB\n"
" // apply gamma correction (we use gamma = 2)\n"
" OutColor = vec4 (sqrt (aColor.rgb), 0.f);\n"
"#else\n"
" OutColor = vec4 (aColor.rgb, 0.f);\n"
"#endif\n"
"\n"
"#else // not PATH_TRACING\n"
"\n"
" OutColor = aColor;\n"
"\n"
"#endif\n"
"}\n";
// clang-format on
f2929057eThis file is pinned to the selected release. Download the original to open it in your design tool.