@@ -83,6 +83,51 @@ Render modes
83
83
| **fog_disabled ** | Disable receiving depth-based or volumetric fog. Useful for blend_add materials like particles. |
84
84
+-------------------------------+------------------------------------------------------------------------------------------------------+
85
85
86
+ Coordinate spaces
87
+ ^^^^^^^^^^^^^^^^^
88
+
89
+ Spatial shaders do their work across multiple coordinate spaces. Some built-in variables with the same name are in different
90
+ coordinate spaces in different processor functions.
91
+
92
+ +-------------------------------+----------------------------------------------------------------------------------------+
93
+ | Coordinate space | Description |
94
+ +===============================+========================================================================================+
95
+ | Model space | Also called "local space" or "local coordinates". |
96
+ | | Same as local coordinates of Transform3D. |
97
+ +-------------------------------+----------------------------------------------------------------------------------------+
98
+ | World space | Same as global coordinates of Transform3D. |
99
+ | | |
100
+ +-------------------------------+----------------------------------------------------------------------------------------+
101
+ | View space | |
102
+ +-------------------------------+----------------------------------------------------------------------------------------+
103
+ | Clip space | |
104
+ +-------------------------------+----------------------------------------------------------------------------------------+
105
+ | Screen space | |
106
+ +-------------------------------+----------------------------------------------------------------------------------------+
107
+ | Normalized device coordinates | |
108
+ +-------------------------------+----------------------------------------------------------------------------------------+
109
+
110
+ You can convert between different coordinate spaces by using the built-in transform matrices. For example, in the fragment shader,
111
+ both ``VERTEX `` and ``NORMAL `` are in view space by default. You can convert them to world space by multiplying them by
112
+ ``INV_VIEW_MATRIX ``. When transforming a *position * vector, the `z ` value should be `1.0 `. When transforming a direction
113
+ vector, the `z ` value should be `0.0 `.
114
+
115
+ .. code-block :: glsl
116
+
117
+ void fragment() {
118
+ vec3 position_world = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
119
+ vec3 normal_world = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
120
+ }
121
+
122
+ TODO add a sentence about screen space and NDC.
123
+
124
+ .. code-block :: glsl
125
+
126
+ void convert_to_screenspace() {
127
+ TODO add the to and from NDC snippets here
128
+ }
129
+
130
+
86
131
Built-ins
87
132
^^^^^^^^^
88
133
0 commit comments