@@ -76,9 +76,9 @@ This will allow you to see the triangles making up the plane.
7676
7777.. image :: img/plane.png
7878
79- Now set ``Subdivide Width `` and ``Subdivide Depth `` to ``32 ``.
79+ Now set ``Subdivide Width `` and ``Subdivide Depth `` of the :ref: ` PlaneMesh < class_planemesh >` to ``32 ``.
8080
81- .. image :: img/plane-sub-set.png
81+ .. image :: img/plane-sub-set.webp
8282
8383You can see that there are now many more triangles in the
8484:ref: `MeshInstance3D<class_MeshInstance3D> `. This will give us more vertices to work with
@@ -99,18 +99,21 @@ first Spatial shader!
9999Shader magic
100100------------
101101
102- .. image :: img/shader-error.png
102+ .. image :: img/shader-editor.webp
103103
104- Notice how there is already error? This is because the shader editor reloads
105- shaders on the fly. The first thing Godot shaders need is a declaration of what
106- type of shader they are. We set the variable ``shader_type `` to ``spatial ``
104+ The new shader is already generated with a ``shader_type ``
105+ variable and the ``fragment() `` function.
106+ The first thing Godot shaders need is a declaration
107+ of what type of shader they are.
108+ In this case the ``shader_type `` is set to ``spatial ``
107109because this is a spatial shader.
108110
109111.. code-block :: glsl
110112
111113 shader_type spatial;
112114
113- Next we will define the ``vertex() `` function. The ``vertex() `` function
115+ For now ignore the ``fragment() `` function
116+ and define the ``vertex() `` function. The ``vertex() `` function
114117determines where the vertices of your :ref: `MeshInstance3D<class_MeshInstance3D> ` appear in
115118the final scene. We will be using it to offset the height of each vertex and
116119make our flat plane appear like a little terrain.
@@ -177,16 +180,16 @@ This will allow you to send a noise texture to the shader. Now look in the
177180inspector under your material. You should see a section called "Shader Params".
178181If you open it up, you'll see a section called "noise".
179182
180- Click beside it where it says "[empty]" and select "New NoiseTexture ". Then in
181- your NoiseTexture click beside where it says "Noise" and select "New
182- NoiseTexture ".
183+ Click beside it where it says "[empty]" and select "New NoiseTexture2D ". Then in
184+ your :ref: ` NoiseTexture2D < class_noisetexture2D >` click beside where it says "Noise" and select "New
185+ FastNoiseLite ".
183186
184- .. note :: :ref:`FastNoiseLite <class_fastnoiselite>` is used by the NoiseTexture to
187+ .. note :: :ref:`FastNoiseLite <class_fastnoiselite>` is used by the NoiseTexture2D to
185188 generate a heightmap.
186189
187190Once you set it up and should look like this.
188191
189- .. image :: img/noise-set.png
192+ .. image :: img/noise-set.webp
190193
191194Now, access the noise texture using the ``texture() `` function. ``texture() ``
192195takes a texture as the first argument and a ``vec2 `` for the position on the
@@ -201,8 +204,10 @@ this case we'll use the ``r``, or ``x`` channel.
201204
202205.. code-block :: glsl
203206
204- float height = texture(noise, VERTEX.xz / 2.0 + 0.5).x;
205- VERTEX.y += height;
207+ void vertex() {
208+ float height = texture(noise, VERTEX.xz / 2.0 + 0.5).x;
209+ VERTEX.y += height;
210+ }
206211
207212 Note: ``xyzw `` is the same as ``rgba `` in GLSL, so instead of ``texture().x ``
208213above, we could use ``texture().r ``. See the `OpenGL documentation
@@ -304,10 +309,10 @@ do that by passing in a second noise texture.
304309
305310 uniform sampler2D normalmap;
306311
307- Set this second uniform texture to another NoiseTexture with another
308- FastNoiseLite. But this time, check **As Normalmap **.
312+ Set this second uniform texture to another :ref: ` NoiseTexture2D < class_noisetexture2D >` with another
313+ :ref: ` FastNoiseLite < class_fastnoiselite >` . But this time, check **As Normalmap **.
309314
310- .. image :: img/normal-set.png
315+ .. image :: img/normal-set.webp
311316
312317Now, because this is a normalmap and not a per-vertex normal, we are going to
313318assign it in the ``fragment() `` function. The ``fragment() `` function will be
0 commit comments