Skip to content

Commit 422113c

Browse files
authored
Merge pull request #1439 from nickcosmo/fix/2.0_tutorial_passing-data-from-vertex-to-fragment-shader
Update tutorial snippet to pass proper varying from vertex shader to
2 parents b031ce7 + 12d55be commit 422113c

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/content/tutorials/en/intro-to-glsl.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -618,29 +618,24 @@ You can see the complete list of uniforms that p5.js provides for you in the [p5
618618
For example, you may want to use a shape's texture coordinates in the fragment shader. These come in the form of a `vec2`, where coordinates go between 0 and 1. This initially comes in an `attribute` from p5.js, and those are only accessible in the vertex shader. Let's look at what our standard vertex shader does to pass that to fragment shaders:
619619

620620
<AnnotatedCode lang="glsl" code={({ begin, end }) =>
621-
`
622-
precision highp float;
621+
`precision highp float;
623622
624623
attribute vec3 aPosition;
625624
${begin('texcoord')}
626625
attribute vec2 aTexCoord;
627626
${end('texcoord')}
628-
attribute vec4 aVertexColor;
629-
630627
uniform mat4 uModelViewMatrix;
631628
uniform mat4 uProjectionMatrix;
632-
633629
${begin('varying')}
634630
varying vec2 vTexCoord;
635631
${end('varying')}
636-
varying vec4 vVertexColor;
637632
void main() {
638633
// Apply the camera transform
639634
vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);
640635
// Tell WebGL where the vertex goes
641636
gl_Position = uProjectionMatrix * viewModelPosition;
642637
${begin('assign')}
643-
vVertexColor = aVertexColor;
638+
vTexCoord = aTexCoord;
644639
${end('assign')}
645640
}
646641
`}>

0 commit comments

Comments
 (0)