Browse Source

Add details on the shader's eye position built-ins

Changed descriptions for CAMERA_POSITION_WORLD and EYE_OFFSET to benefit XR developers.
I decided to make this pull request because my dad spent a while trying to get the eye positions correct, eventually finding  that CAMERA_POSITION_WORLD is the same for both eyes, and later that the EYE_OFFSET is not in world space.
My dad and I were almost led to believe that the perspective artifacts we saw with our custom shader were due to an optimization in the headset, and that we would have to work around it in our game, but it has since been fixed.
Ted Gignac 1 week ago
parent
commit
304d1070f2
1 changed files with 9 additions and 5 deletions
  1. 9 5
      tutorials/shaders/shader_reference/spatial_shader.rst

+ 9 - 5
tutorials/shaders/shader_reference/spatial_shader.rst

@@ -192,7 +192,9 @@ shader, this value can be used as desired.
 +----------------------------------------+--------------------------------------------------------+
 | in vec3 **NODE_POSITION_VIEW**         | Node position, in view space.                          |
 +----------------------------------------+--------------------------------------------------------+
-| in vec3 **CAMERA_POSITION_WORLD**      | Camera position, in world space.                       |
+| in vec3 **CAMERA_POSITION_WORLD**      | Camera position, in world space. Represents the        |
+|                                        | midpoint of the two eyes when in multiview/stereo      |
+|                                        | rendering.                                             |
 +----------------------------------------+--------------------------------------------------------+
 | in vec3 **CAMERA_DIRECTION_WORLD**     | Camera direction, in world space.                      |
 +----------------------------------------+--------------------------------------------------------+
@@ -210,8 +212,8 @@ shader, this value can be used as desired.
 +----------------------------------------+--------------------------------------------------------+
 | in int **VIEW_RIGHT**                  | Constant for right eye, always ``1``.                  |
 +----------------------------------------+--------------------------------------------------------+
-| in vec3 **EYE_OFFSET**                 | Position offset for the eye being rendered.            |
-|                                        | Only applicable for multiview rendering.               |
+| in vec3 **EYE_OFFSET**                 | Position offset for the eye being rendered, in view    |
+|                                        | space. Only applicable for multiview rendering.        |
 +----------------------------------------+--------------------------------------------------------+
 | inout vec3 **VERTEX**                  | Position of the vertex, in model space.                |
 |                                        | In world space if ``world_vertex_coords`` is used.     |
@@ -322,7 +324,8 @@ these properties, and if you don't write to them, Godot will optimize away the c
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
 | in vec3 **NODE_POSITION_VIEW**         | Node position, in view space.                                                                    |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec3 **CAMERA_POSITION_WORLD**      | Camera position, in world space.                                                                 |
+| in vec3 **CAMERA_POSITION_WORLD**      | Camera position, in world space. Represents the midpoint of the two eyes when in                 |
+|                                        | multiview/stereo rendering.                                                                      |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
 | in vec3 **CAMERA_DIRECTION_WORLD**     | Camera direction, in world space.                                                                |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
@@ -343,7 +346,8 @@ these properties, and if you don't write to them, Godot will optimize away the c
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
 | in int **VIEW_RIGHT**                  | Constant for right eye, always ``1``.                                                            |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec3 **EYE_OFFSET**                 | Position offset for the eye being rendered. Only applicable for multiview rendering.             |
+| in vec3 **EYE_OFFSET**                 | Position offset for the eye being rendered, in view space. Only applicable for multiview         |
+|                                        | rendering.                                                                                       |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+
 | sampler2D **SCREEN_TEXTURE**           | Removed in Godot 4. Use a ``sampler2D`` with ``hint_screen_texture`` instead.                    |
 +----------------------------------------+--------------------------------------------------------------------------------------------------+