0028373: Incomplete section between cylinder and plane
[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"
14 "#ifndef ADAPTIVE_SAMPLING\n"
383c6c9f 15 " //! Input image with previously accumulated samples.\n"
ee5befae 16 " uniform sampler2D uAccumTexture;\n"
17 "#endif\n"
18 "\n"
b09447ed 19 "//! Maximum radiance that can be added to the pixel.\n"
20 "//! Decreases noise level, but introduces some bias.\n"
21 "uniform float uMaxRadiance = 50.f;\n"
ee5befae 22 "\n"
23 "// =======================================================================\n"
24 "// function : main\n"
25 "// purpose :\n"
26 "// =======================================================================\n"
27 "void main (void)\n"
28 "{\n"
29 " SeedRand (uFrameRndSeed, uWinSizeX, uBlockedRngEnabled == 0 ? 1 : 16);\n"
30 "\n"
31 "#ifndef PATH_TRACING\n"
32 "\n"
33 " SRay aRay = GenerateRay (vPixel);\n"
34 "\n"
35 "#else\n"
36 "\n"
37 " ivec2 aFragCoord = ivec2 (gl_FragCoord.xy);\n"
38 "\n"
39 "#ifdef ADAPTIVE_SAMPLING\n"
40 "\n"
41 " ivec2 aTileXY = imageLoad (uOffsetImage, ivec2 (aFragCoord.x / BLOCK_SIZE,\n"
42 " aFragCoord.y / BLOCK_SIZE)).xy;\n"
43 "\n"
44 " ivec2 aRealBlockSize = ivec2 (min (uWinSizeX - aTileXY.x, BLOCK_SIZE),\n"
45 " min (uWinSizeY - aTileXY.y, BLOCK_SIZE));\n"
46 "\n"
47 " aFragCoord.x = aTileXY.x + (aFragCoord.x % aRealBlockSize.x);\n"
48 " aFragCoord.y = aTileXY.y + (aFragCoord.y % aRealBlockSize.y);\n"
49 "\n"
50 "#endif // ADAPTIVE_SAMPLING\n"
51 "\n"
52 " vec2 aPnt = vec2 (aFragCoord.x + RandFloat(),\n"
53 " aFragCoord.y + RandFloat());\n"
54 "\n"
55 " SRay aRay = GenerateRay (aPnt / vec2 (uWinSizeX, uWinSizeY));\n"
56 "\n"
57 "#endif // PATH_TRACING\n"
58 "\n"
59 " vec3 aInvDirect = InverseDirection (aRay.Direct);\n"
60 "\n"
61 "#ifdef PATH_TRACING\n"
62 "\n"
63 " vec4 aColor = PathTrace (aRay, aInvDirect);\n"
64 "\n"
65 " if (any (isnan (aColor.rgb)))\n"
66 " {\n"
67 " aColor.rgb = ZERO;\n"
68 " }\n"
69 "\n"
b09447ed 70 " aColor.rgb = min (aColor.rgb, vec3 (uMaxRadiance));\n"
ee5befae 71 "\n"
72 "#ifdef ADAPTIVE_SAMPLING\n"
73 "\n"
74 " // accumulate RGB color and depth\n"
75 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
76 " 2 * aFragCoord.y + 0), aColor.r);\n"
77 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 1,\n"
78 " 2 * aFragCoord.y + 0), aColor.g);\n"
79 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 1,\n"
80 " 2 * aFragCoord.y + 1), aColor.b);\n"
81 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
82 " 2 * aFragCoord.y + 1), aColor.w);\n"
83 "\n"
84 " // accumulate number of samples\n"
85 " float aNbSamples = imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 0,\n"
86 " 2 * aFragCoord.y + 1), 1.0);\n"
87 "\n"
88 " if (int (aNbSamples) % 2 == 0) // accumulate luminance for even samples only\n"
89 " {\n"
90 " imageAtomicAdd (uRenderImage, ivec2 (3 * aFragCoord.x + 2,\n"
91 " 2 * aFragCoord.y + 0), dot (LUMA, aColor.rgb));\n"
92 " }\n"
93 "\n"
94 " discard; // fragment should not be written to frame buffer\n"
95 "\n"
96 "#else\n"
97 "\n"
383c6c9f 98 " if (uAccumSamples == 0)\n"
ee5befae 99 " {\n"
100 " OutColor = aColor;\n"
101 " }\n"
102 " else\n"
103 " {\n"
383c6c9f 104 " OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, 1.f / (uAccumSamples + 1));\n"
ee5befae 105 " }\n"
106 "\n"
107 "#endif // ADAPTIVE_SAMPLING\n"
108 "\n"
109 "#else\n"
110 "\n"
111 " OutColor = clamp (Radiance (aRay, aInvDirect), 0.f, 1.f);\n"
112 "\n"
113 "#endif // PATH_TRACING\n"
114 "}\n";