@@ -6,13 +6,13 @@ Your second 3D shader
6
6
From a high-level, what Godot does is give the user a bunch of shader parameters
7
7
that can be optionally set (``AO ``, ``SSS_Strength ``, ``RIM ``, etc.). These
8
8
parameters correspond to different complex effects (Ambient Occlusion,
9
- SubSurface Scattering, Rim Lighting, etc.). When not written to, the code is
9
+ SubSurface Scattering, Rim Lighting, etc.). When not written to, the code is
10
10
thrown out before it is compiled and so the shader does not incur the cost of
11
11
the extra feature. This allows users to have complex PBR-correct
12
12
shading, without writing complex shaders. Of course, Godot also allows you to
13
13
ignore all these parameters and write a fully customized shader.
14
14
15
- For a full list of these parameters see the :ref: `spatial shader <doc_spatial_shader >`
15
+ For a full list of these parameters see the :ref: `spatial shader <doc_spatial_shader >`
16
16
reference doc.
17
17
18
18
A difference between the vertex function and a fragment function is that the
@@ -26,7 +26,7 @@ importantly, sets the ``ALBEDO`` color of the :ref:`MeshInstance3D<class_MeshIns
26
26
fragment function in Godot is to set up different material properties and let
27
27
Godot handle the rest. In order to provide even more flexibility, Godot also
28
28
provides render modes. Render modes are set at the top of the
29
- shader, directly below ``shader_type ``. They; re used to specify what sort of
29
+ shader, directly below ``shader_type ``. They' re used to specify what sort of
30
30
functionality you want the built-in aspects of the shader to have.
31
31
32
32
For example, if you do not want to have lights affect an object, set the
@@ -37,8 +37,8 @@ importantly, sets the ``ALBEDO`` color of the :ref:`MeshInstance3D<class_MeshIns
37
37
render_mode unshaded;
38
38
39
39
You can also stack multiple render modes together. For example, if you want to
40
- use toon shading instead of more-realistic PBR shading, set the diffuse mode
41
- and specular mode to toon:
40
+ use toon shading instead of more-realistic PBR shading, set the diffuse
41
+ and specular modes to toon:
42
42
43
43
.. code-block :: glsl
44
44
@@ -47,7 +47,7 @@ importantly, sets the ``ALBEDO`` color of the :ref:`MeshInstance3D<class_MeshIns
47
47
This model of built-in functionality allows you to write complex custom
48
48
shaders by changing only a few parameters.
49
49
50
- For a full list of render modes see the :ref: `Spatial shader reference <doc_spatial_shader >`.
50
+ For a full list of render modes, see the :ref: `Spatial shader reference <doc_spatial_shader >`.
51
51
52
52
Your first spatial fragment function
53
53
------------------------------------
67
67
.. code-block :: glsl
68
68
69
69
void vertex() {
70
- tex_position = VERTEX.xz / 10.0 + 0.5; // Scaling factor set to 10 for 10x10 mesh
70
+ tex_position = VERTEX.xz / 10.0 + 0.5; // Scaling factor set to 10 for 10x10 mesh.
71
71
float height = texture(noise, tex_position).x;
72
72
VERTEX.y += height * height_scale;
73
73
}
@@ -104,7 +104,7 @@ the reflection and the ``ALBEDO`` color. A high ``METALLIC`` almost ignores
104
104
``METALLIC `` has a more equal representation of sky color and ``ALBEDO `` color.
105
105
106
106
In the example below, ``ROUGHNESS `` increases from ``0 `` to ``1 `` from left to
107
- right while ``METALLIC `` increase from ``0 `` to ``1 `` from top to bottom.
107
+ right while ``METALLIC `` increases from ``0 `` to ``1 `` from top to bottom.
108
108
109
109
.. image :: img/PBR.webp
110
110
@@ -213,9 +213,9 @@ cosine of ``TIME``.
213
213
.. note ::
214
214
215
215
This will result in texture coordinates that will go out of the bounds of our
216
- noise textures and wrap around. The :ref: `NoiseTexture2D <class_NoiseTexture2D >`'s
216
+ noise textures and wrap around. The :ref: `NoiseTexture2D <class_NoiseTexture2D >`s
217
217
we are using for **Noise** and **Normalmap** should have their :ref:`Seamless <class_NoiseTexture2D_property_seamless>`
218
- property set to ``On `` at this stage, or the seams will start to be visible.
218
+ property set to ``On `` at this stage, or the seams will be visible.
219
219
220
220
This results in waves that move slowly, but not in a very natural way. The next
221
221
section will dig deeper into using shaders to create more complex effects, in
@@ -233,7 +233,7 @@ corresponding normal value from our normal map. In the next section we will be
233
233
introducing functions to compute our own height values, making our normal map
234
234
invalid. This means we will have to compute them manually.
235
235
236
- First we will move the height calculation into it's own function. Put the code
236
+ First we will move the height calculation into its own function. Put the code
237
237
into a function called ``height() ``.
238
238
239
239
.. code-block :: glsl
@@ -271,7 +271,7 @@ We will also remove the code assigning to ``NORMAL_MAP`` in ``fragment()``.
271
271
As these are estimates, we have lost some quality. We can partially address this
272
272
by reducing the detail in our noise texture. Open **Mesh > Material > Shader
273
273
parameters ** and then the :ref: `Noise <class_NoiseTexture2D_property_noise >`
274
- texture. Set it's :ref: `Noise > Frequency <class_FastNoiseLite_property_frequency >`
274
+ texture. Set its :ref: `Noise > Frequency <class_FastNoiseLite_property_frequency >`
275
275
value to ``0.005 ``.
276
276
277
277
.. image :: img/set-frequency.webp
@@ -348,6 +348,7 @@ We do this by scaling ``position``.
348
348
float h = wave(position * 0.4);
349
349
return h;
350
350
}
351
+
351
352
.. image :: img/wave2.webp
352
353
353
354
This wave has a more natural shape, but it is a bit smooth. In our material settings
@@ -429,6 +430,6 @@ the same mesh and noise settings as mentioned above.
429
430
}
430
431
431
432
For more information about Spatial shaders read the :ref: `Shading Language <doc_shading_language >`
432
- doc and the :ref: `Spatial Shaders <doc_spatial_shader >` doc.
433
+ and :ref: `Spatial Shaders <doc_spatial_shader >` docs.
433
434
Also look at more advanced tutorials in the :ref: `Shading section<toc-learn-features-shading> `
434
- and the :ref: `3D <toc-learn-features-3d >` sections.
435
+ and :ref: `3D <toc-learn-features-3d >` sections.
0 commit comments