Skip to content

Commit d713535

Browse files
authored
Merge pull request #10143 from tetrapod00/large-world-coords-shader
Note limitation of shader world coordinates with large world coordinates
2 parents cb2a53f + e4d395d commit d713535

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tutorials/physics/large_world_coordinates.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,23 @@ some limitations when it comes to 3D rendering precision:
229229
- :ref:`Triplanar mapping <doc_standard_material_3d_triplanar_mapping>` doesn't
230230
benefit from increased precision. Materials using triplanar mapping will exhibit
231231
visible jittering when far away from the world origin.
232+
- In double-precision builds, world space coordinates in a shader ``fragment()``
233+
function can't be reconstructed from view space, for example:
234+
235+
.. code-block:: glsl
236+
237+
vec3 world = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
238+
239+
Instead, calculate the world space coordinates in the ``vertex()`` function and
240+
pass them using a :ref:`varying<doc_shading_language_varyings>`, for example:
241+
242+
.. code-block:: glsl
243+
244+
varying vec3 world;
245+
void vertex() {
246+
world = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
247+
}
248+
232249
233250
2D rendering currently doesn't benefit from increased precision when large world
234251
coordinates are enabled. This can cause visible model snapping to occur when

tutorials/shaders/shader_reference/shading_language.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ function calls is not allowed, such as from ``int`` to ``float`` (``1`` to ``1.0
662662
vec3 green = get_color(1.0);
663663
}
664664
665+
.. _doc_shading_language_varyings:
665666

666667
Varyings
667668
--------

0 commit comments

Comments
 (0)