Skip to content

Commit d7d19fd

Browse files
authored
Merge pull request godotengine#8583 from paddy-exe/update-first-2d-shader-docs
Update first 2D shader TEXTURE built-in variable section
2 parents 4856666 + 03ddb93 commit d7d19fd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tutorials/shaders/your_first_shader/your_first_2d_shader.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ so long as it is drawing to the canvas, so for this tutorial we will use a Sprit
4343
as it is the easiest CanvasItem to start drawing with.
4444

4545
In the Inspector, click beside "Texture" where it says "[empty]" and select
46-
"Load", then select "Icon.png". For new projects, this is the Godot icon. You
46+
"Load", then select "icon.svg". For new projects, this is the Godot icon. You
4747
should now see the icon in the viewport.
4848

4949
Next, look down in the Inspector, under the CanvasItem section, click beside
@@ -132,27 +132,27 @@ other functions or to assign values to ``COLOR`` directly.
132132
Using ``TEXTURE`` built-in
133133
^^^^^^^^^^^^^^^^^^^^^^^^^^
134134

135-
When you want to adjust a color in a Sprite2D you cannot just adjust the color
135+
The default fragment function reads from the set Sprite2D texture and displays it.
136+
137+
When you want to adjust a color in a Sprite2D you can adjust the color
136138
from the texture manually like in the code below.
137139

138140
.. code-block:: glsl
139141
140142
void fragment(){
141-
//this shader will result in an all white rectangle
143+
// This shader will result in a blue-tinted icon
142144
COLOR.b = 1.0;
143145
}
144146
145-
The default fragment function reads from a texture and displays it. When you
146-
overwrite the default fragment function, you lose that functionality, so you
147-
have to implement it yourself. You read from textures using the ``texture``
148-
function. Certain nodes, like Sprite2Ds, have a dedicated texture variable that
149-
can be accessed in the shader using ``TEXTURE``. Use it together with ``UV`` and
150-
``texture`` to draw the Sprite2D.
147+
Certain nodes, like Sprite2Ds, have a dedicated texture variable that can be accessed
148+
in the shader using ``TEXTURE``. If you want to use the Sprite2D texture to combine
149+
with other colors, you can use the ``UV`` with the ``texture`` function to access
150+
this variable. Use them to redraw the Sprite2D with the texture.
151151

152152
.. code-block:: glsl
153153
154154
void fragment(){
155-
COLOR = texture(TEXTURE, UV); //read from texture
155+
COLOR = texture(TEXTURE, UV); // Read from texture again.
156156
COLOR.b = 1.0; //set blue channel to 1.0
157157
}
158158
@@ -180,7 +180,7 @@ Add a uniform to change the amount of blue in our Sprite2D.
180180
uniform float blue = 1.0; // you can assign a default value to uniforms
181181
182182
void fragment(){
183-
COLOR = texture(TEXTURE, UV); //read from texture
183+
COLOR = texture(TEXTURE, UV); // Read from texture
184184
COLOR.b = blue;
185185
}
186186

0 commit comments

Comments
 (0)