@@ -64,6 +64,43 @@ update the radiance cubemap each frame, make sure your
6464:ref: `Sky process mode <class_Sky_property_process_mode >` is set to
6565:ref: `REALTIME <class_Sky_constant_PROCESS_MODE_REALTIME >`.
6666
67+ Note that the :ref: `process mode <class_Sky_property_process_mode >` only
68+ affects the rendering of the radiance cubemap. The visible sky is always
69+ rendered by calling the fragment shader for every pixel. With complex fragment
70+ shaders, this can result in a high rendering overhead. If the sky is static
71+ (the conditions listed above are met) or changes slowly, running the full
72+ fragment shader every frame is not needed. This can be avoided by rendering the
73+ full sky into the radiance cubemap, and reading from this cubemap when
74+ rendering the visible sky. With a completely static sky, this means that it
75+ needs to be rendered only once.
76+
77+ The following code renders the full sky into the radiance cubemap and reads
78+ from that cubemap for displaying the visible sky:
79+
80+ .. code-block :: glsl
81+
82+ shader_type sky;
83+
84+ void sky() {
85+ if (AT_CUBEMAP_PASS) {
86+ vec3 dir = EYEDIR;
87+
88+ vec4 col = vec4(0.0);
89+
90+ // Complex color calculation
91+
92+ COLOR = col.xyz;
93+ ALPHA = 1.0;
94+ } else {
95+ COLOR = texture(RADIANCE, EYEDIR).rgb;
96+ }
97+ }
98+
99+ This way, the complex calculations happen only in the cubemap pass, which can
100+ be optimized by setting the sky's :ref: `process mode <class_Sky_property_process_mode >`
101+ and the :ref: `radiance size <class_Sky_property_radiance_size >` to get the
102+ desired balance between performance and visual fidelity.
103+
67104Render modes
68105^^^^^^^^^^^^
69106
@@ -103,7 +140,7 @@ Built-ins
103140^^^^^^^^^
104141
105142Values marked as "in" are read-only. Values marked as "out" are for optional
106- writing and will not necessarily contain sensible values. Samplers cannot be
143+ writing and will not necessarily contain sensible values. Samplers cannot be
107144written to so they are not marked.
108145
109146Global built-ins
0 commit comments