Skip to content

Commit

Permalink
Merge pull request #10143 from tetrapod00/large-world-coords-shader
Browse files Browse the repository at this point in the history
Note limitation of shader world coordinates with large world coordinates
  • Loading branch information
skyace65 authored Oct 25, 2024
2 parents cb2a53f + e4d395d commit d713535
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tutorials/physics/large_world_coordinates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,23 @@ some limitations when it comes to 3D rendering precision:
- :ref:`Triplanar mapping <doc_standard_material_3d_triplanar_mapping>` doesn't
benefit from increased precision. Materials using triplanar mapping will exhibit
visible jittering when far away from the world origin.
- In double-precision builds, world space coordinates in a shader ``fragment()``
function can't be reconstructed from view space, for example:

.. code-block:: glsl
vec3 world = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
Instead, calculate the world space coordinates in the ``vertex()`` function and
pass them using a :ref:`varying<doc_shading_language_varyings>`, for example:

.. code-block:: glsl
varying vec3 world;
void vertex() {
world = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
}
2D rendering currently doesn't benefit from increased precision when large world
coordinates are enabled. This can cause visible model snapping to occur when
Expand Down
1 change: 1 addition & 0 deletions tutorials/shaders/shader_reference/shading_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ function calls is not allowed, such as from ``int`` to ``float`` (``1`` to ``1.0
vec3 green = get_color(1.0);
}
.. _doc_shading_language_varyings:

Varyings
--------
Expand Down

0 comments on commit d713535

Please sign in to comment.