Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Commit ec0b907

Browse files
committed
Fix shader example
1 parent e063a14 commit ec0b907

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/12-postprocessors.mdx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,24 @@ In this example we can make the entire game gray scale:
7474
class GrayScalePostProcessor implements ex.PostProcessor {
7575
private _shader: ex.ScreenShader
7676
initialize(gl: WebGLRenderingContext): void {
77-
this._shader = new ex.ScreenShader(`
77+
this._shader = new ex.ScreenShader(
78+
`#version 300 es
7879
precision mediump float;
7980
80-
// Passed in from the vertex shader.
81-
varying vec2 v_texcoord;
82-
83-
// The texture.
84-
uniform sampler2D u_texture;
85-
81+
// our texture
82+
uniform sampler2D u_image;
83+
84+
// the texCoords passed in from the vertex shader.
85+
in vec2 v_texcoord;
86+
87+
out vec4 fragColor;
88+
8689
void main() {
87-
vec4 tex = texture2D(u_texture, vec2(v_texcoord.x, v_texcoord.y));
90+
vec4 tex = texture(u_image, v_texcoord);
8891
float avg = 0.2126 * tex.r + 0.7152 * tex.g + 0.0722 * tex.b;
89-
gl_FragColor = vec4(avg, avg, avg, 1.0);
90-
}`)
92+
fragColor = vec4(avg, avg, avg, 1.0);
93+
}`
94+
)
9195
}
9296

9397
getLayout(): ex.VertexLayout {

0 commit comments

Comments
 (0)