0028488: VIS - fix compilation with VTK 8.2
[occt.git] / src / Shaders / Shaders_RaytraceRender_fs.pxx
CommitLineData
ee5befae 1// This file has been automatically generated from resource file src/Shaders/RaytraceRender.fs
2
3static const char Shaders_RaytraceRender_fs[] =
4 "out vec4 OutColor;\n"
5 "\n"
6 "// Seed for random number generator (generated on CPU).\n"
7 "uniform int uFrameRndSeed;\n"
8 "\n"
9 "//! Enables/disables using of single RNG seed for 16x16 image\n"
10 "//! blocks. Increases performance up to 4x, but the noise has\n"
11 "//! become structured. Can be used fo final rendering.\n"
12 "uniform int uBlockedRngEnabled;\n"
13 "\n"
4eaaf9d8 14 "//! Number of previously rendered frames (used in non-ISS mode).\n"
15 "uniform int uAccumSamples;\n"
16 "\n"
ee5befae 17 "#ifndef ADAPTIVE_SAMPLING\n"
383c6c9f 18 " //! Input image with previously accumulated samples.\n"
ee5befae 19 " uniform sampler2D uAccumTexture;\n"
20 "#endif\n"
21 "\n"
b09447ed 22 "//! Maximum radiance that can be added to the pixel.\n"
23 "//! Decreases noise level, but introduces some bias.\n"
24 "uniform float uMaxRadiance = 50.f;\n"
ee5befae 25 "\n"
26 "// =======================================================================\n"
27 "// function : main\n"
28 "// purpose :\n"
29 "// =======================================================================\n"
30 "void main (void)\n"
31 "{\n"
32 " SeedRand (uFrameRndSeed, uWinSizeX, uBlockedRngEnabled == 0 ? 1 : 16);\n"
33 "\n"
34 "#ifndef PATH_TRACING\n"
35 "\n"
36 " SRay aRay = GenerateRay (vPixel);\n"
37 "\n"
38 "#else\n"
39 "\n"
40 " ivec2 aFragCoord = ivec2 (gl_FragCoord.xy);\n"
41 "\n"
42 "#ifdef ADAPTIVE_SAMPLING\n"
43 "\n"
44 " ivec2 aTileXY = imageLoad (uOffsetImage, ivec2 (aFragCoord.x / BLOCK_SIZE,\n"
45 " aFragCoord.y / BLOCK_SIZE)).xy;\n"
46 "\n"
47 " ivec2 aRealBlockSize = ivec2 (min (uWinSizeX - aTileXY.x, BLOCK_SIZE),\n"
48 " min (uWinSizeY - aTileXY.y, BLOCK_SIZE));\n"
49 "\n"
50 " aFragCoord.x = aTileXY.x + (aFragCoord.x % aRealBlockSize.x);\n"
51 " aFragCoord.y = aTileXY.y + (aFragCoord.y % aRealBlockSize.y);\n"
52 "\n"
53 "#endif // ADAPTIVE_SAMPLING\n"
54 "\n"
55 " vec2 aPnt = vec2 (aFragCoord.x + RandFloat(),\n"
56 " aFragCoord.y + RandFloat());\n"
57 "\n"
58 " SRay aRay = GenerateRay (aPnt / vec2 (uWinSizeX, uWinSizeY));\n"
59 "\n"
60 "#endif // PATH_TRACING\n"
61 "\n"
62 " vec3 aInvDirect = InverseDirection (aRay.Direct);\n"
63 "\n"
64 "#ifdef PATH_TRACING\n"
65 "\n"
4eaaf9d8 66 "#ifndef ADAPTIVE_SAMPLING\n"
67 "\n"
68 " vec4 aColor = PathTrace (aRay, aInvDirect, uAccumSamples);\n"
69 "\n"
70 "#else\n"
71 "\n"
72 " float aNbSamples = imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
73 " 2 * aFragCoord.y + 1), 1.0);\n"
74 "\n"
75 " vec4 aColor = PathTrace (aRay, aInvDirect, int (aNbSamples));\n"
76 "\n"
77 "#endif\n"
ee5befae 78 "\n"
79 " if (any (isnan (aColor.rgb)))\n"
80 " {\n"
81 " aColor.rgb = ZERO;\n"
82 " }\n"
83 "\n"
b09447ed 84 " aColor.rgb = min (aColor.rgb, vec3 (uMaxRadiance));\n"
ee5befae 85 "\n"
86 "#ifdef ADAPTIVE_SAMPLING\n"
87 "\n"
88 " // accumulate RGB color and depth\n"
89 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
90 " 2 * aFragCoord.y + 0), aColor.r);\n"
91 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 1,\n"
92 " 2 * aFragCoord.y + 0), aColor.g);\n"
93 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 1,\n"
94 " 2 * aFragCoord.y + 1), aColor.b);\n"
95 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
96 " 2 * aFragCoord.y + 1), aColor.w);\n"
97 "\n"
ee5befae 98 " if (int (aNbSamples) % 2 == 0) // accumulate luminance for even samples only\n"
99 " {\n"
100 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
101 " 2 * aFragCoord.y + 0), dot (LUMA, aColor.rgb));\n"
102 " }\n"
103 "\n"
ee5befae 104 "#else\n"
105 "\n"
383c6c9f 106 " if (uAccumSamples == 0)\n"
ee5befae 107 " {\n"
108 " OutColor = aColor;\n"
109 " }\n"
110 " else\n"
111 " {\n"
383c6c9f 112 " OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, 1.f / (uAccumSamples + 1));\n"
ee5befae 113 " }\n"
114 "\n"
115 "#endif // ADAPTIVE_SAMPLING\n"
116 "\n"
117 "#else\n"
118 "\n"
119 " OutColor = clamp (Radiance (aRay, aInvDirect), 0.f, 1.f);\n"
120 "\n"
121 "#endif // PATH_TRACING\n"
122 "}\n";