Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/content/tutorials/en/intro-to-shaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ function draw() {
shader(myShader);

// Create a color using the mouse's x position as red and
// its y position as blue, and pass it into the shader
// its y position as green, and pass it into the shader
myShader.setUniform('myColor', [
map(mouseX, 0, width, 0, 1, true), // Red
map(mouseY, 0, width, 0, 1, true), // Green
Expand Down Expand Up @@ -643,7 +643,7 @@ void main() {
</Fragment>
</AnnotatedCode>

Since we defined a `varying` called `vTexCoord` in the vertex shader, we can now use it in the fragment shader as well. Here is a simple fragment shader that maps the x value to the red channel and the y value to the blue channel. Note that while `vTexCoord` is defined *per vertex* in the vertex shader, its value is defined *per pixel* in the fragment shader. To get the per-pixel value, WebGL smoothly interpolates between the per-vertex values on each face.
Since we defined a `varying` called `vTexCoord` in the vertex shader, we can now use it in the fragment shader as well. Here is a simple fragment shader that maps the x value to the red channel and the y value to the green channel. Note that while `vTexCoord` is defined *per vertex* in the vertex shader, its value is defined *per pixel* in the fragment shader. To get the per-pixel value, WebGL smoothly interpolates between the per-vertex values on each face.

<AnnotatedCode lang="glsl" code={({ begin, end }) =>
`${begin('shader')}
Expand Down
Loading
Loading