Loading...
Loading...
Use when writing, debugging, or reviewing shaders for the web — GLSL or WGSL, raw WebGL2/WebGPU, Three.js (ShaderMaterial/RawShaderMaterial/TSL), or React Three Fiber. Covers the language/platform matrix, correct boilerplate, common effects (SDF/raymarching, noise, post-processing), and the pitfalls that make browser shaders fail silently.
npx skill4agent add owenob1/web-shaders-agent-kit web-shaders| Target | Language | Notes |
|---|---|---|
| Raw WebGL 2 | GLSL ES 3.00 ( | You declare everything. |
| Raw WebGL 1 | GLSL ES 1.00 | |
| WebGPU (raw) | WGSL | |
Three.js | GLSL ES 1.00 by default | Three injects camera/model matrices and attributes (see §2). Set |
Three.js | whatever you declare | No injected uniforms/attributes or |
| Three.js TSL (WebGPURenderer) | JavaScript nodes | Author with |
| React Three Fiber | GLSL via drei | Wraps |
WebGPURendererShaderMaterialRawShaderMaterialpositionnormaluvmodelMatrixmodelViewMatrixprojectionMatrixviewMatrixnormalMatrixcameraPositionprecision// vertex
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}// fragment
varying vec2 vUv;
uniform float uTime;
void main() {
gl_FragColor = vec4(vUv, 0.5 + 0.5 * sin(uTime), 1.0);
}glslVersion: THREE.GLSL3varyingin/outtexture2Dtextureout vec4 fragColor;gl_FragColorshaderMaterial(uniforms, vertex, fragment)extenduseFrame@vertex fn vs(...) -> @builtin(position) vec4f@fragment fn fs(...) -> @location(0) vec4fstruct@group(g) @binding(b) var<uniform> u: U;vec3<f32>1i321.0f321uu32textureSample(tex, samp, uv)texture.flipY = truevUv.yuv.x *= resolution.x / resolution.yuv = (uv - .5) * vec2(aspect, 1.) + .5gl_Positiongl_FragCoord.xyrenderer.outputColorSpace = SRGBColorSpacetexture.colorSpace = SRGBColorSpacerenderer.toneMappingtransparent: trueblendingprecision highp float;RawShaderMaterialmediumpwhilemod(x, y)%pow(negative, y)1.0/3.01/3dFdxdFdyfwidth#extension GL_OES_standard_derivatives : enablemixstepsmoothstepifnormalize()stepsmoothstepmixclampfractmodLygiaglsl-noisewebgl-noiselygiapmndrs/postprocessingEffectComposerGPUComputationRenderergl_FragColor = vec4(vUv, 0, 1)vec4(vec3(d), 1.0)llms.txt