[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78F6HVD4BF7FDAGXG36KT1D":3,"skill-same:01M78F6HVD4BF7FDAGXG36KT1D":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M78F6HVD4BF7FDAGXG36KT1D","threejs-shaders",null,"Three.js shaders - GLSL, ShaderMaterial, uniforms, custom effects. Use when creating custom visual effects, modifying vertices, writing fragment shaders, or extending built-in materials.","Sushant6095\u002Fninety","Sushant6095","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F97014664?v=4","01M78F3A8VE6FTHKRA6JY0TS5R","SUSHANT JAIN","01M78F3A9YFYRNARTXYE4EVGEJ",1,"MIT","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fthreejs-shaders\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: threejs-shaders\ndescription: Three.js shaders - GLSL, ShaderMaterial, uniforms, custom effects. Use when creating custom visual effects, modifying vertices, writing fragment shaders, or extending built-in materials.\n---\n\n# Three.js Shaders\n\n## Quick Start\n\n```javascript\nimport * as THREE from \"three\";\n\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    time: { value: 0 },\n    color: { value: new THREE.Color(0xff0000) },\n  },\n  vertexShader: `\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    uniform vec3 color;\n\n    void main() {\n      gl_FragColor = vec4(color, 1.0);\n    }\n  `,\n});\n\n\u002F\u002F Update in animation loop\nmaterial.uniforms.time.value = clock.getElapsedTime();\n```\n\n## ShaderMaterial vs RawShaderMaterial\n\n### ShaderMaterial\n\nThree.js provides built-in uniforms and attributes.\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    \u002F\u002F Built-in uniforms available:\n    \u002F\u002F uniform mat4 modelMatrix;\n    \u002F\u002F uniform mat4 modelViewMatrix;\n    \u002F\u002F uniform mat4 projectionMatrix;\n    \u002F\u002F uniform mat4 viewMatrix;\n    \u002F\u002F uniform mat3 normalMatrix;\n    \u002F\u002F uniform vec3 cameraPosition;\n\n    \u002F\u002F Built-in attributes available:\n    \u002F\u002F attribute vec3 position;\n    \u002F\u002F attribute vec3 normal;\n    \u002F\u002F attribute vec2 uv;\n\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n### RawShaderMaterial\n\nFull control - you define everything.\n\n```javascript\nconst material = new THREE.RawShaderMaterial({\n  uniforms: {\n    projectionMatrix: { value: camera.projectionMatrix },\n    modelViewMatrix: { value: new THREE.Matrix4() },\n  },\n  vertexShader: `\n    precision highp float;\n\n    attribute vec3 position;\n    uniform mat4 projectionMatrix;\n    uniform mat4 modelViewMatrix;\n\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    precision highp float;\n\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n## Uniforms\n\n### Uniform Types\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    \u002F\u002F Numbers\n    floatValue: { value: 1.5 },\n    intValue: { value: 1 },\n\n    \u002F\u002F Vectors\n    vec2Value: { value: new THREE.Vector2(1, 2) },\n    vec3Value: { value: new THREE.Vector3(1, 2, 3) },\n    vec4Value: { value: new THREE.Vector4(1, 2, 3, 4) },\n\n    \u002F\u002F Colors (converted to vec3)\n    colorValue: { value: new THREE.Color(0xff0000) },\n\n    \u002F\u002F Matrices\n    mat3Value: { value: new THREE.Matrix3() },\n    mat4Value: { value: new THREE.Matrix4() },\n\n    \u002F\u002F Textures\n    textureValue: { value: texture },\n    cubeTextureValue: { value: cubeTexture },\n\n    \u002F\u002F Arrays\n    floatArray: { value: [1.0, 2.0, 3.0] },\n    vec3Array: {\n      value: [new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0)],\n    },\n  },\n});\n```\n\n### GLSL Declarations\n\n```glsl\n\u002F\u002F In shader\nuniform float floatValue;\nuniform int intValue;\nuniform vec2 vec2Value;\nuniform vec3 vec3Value;\nuniform vec3 colorValue;    \u002F\u002F Color becomes vec3\nuniform vec4 vec4Value;\nuniform mat3 mat3Value;\nuniform mat4 mat4Value;\nuniform sampler2D textureValue;\nuniform samplerCube cubeTextureValue;\nuniform float floatArray[3];\nuniform vec3 vec3Array[2];\n```\n\n### Updating Uniforms\n\n```javascript\n\u002F\u002F Direct assignment\nmaterial.uniforms.time.value = clock.getElapsedTime();\n\n\u002F\u002F Vector\u002FColor updates\nmaterial.uniforms.position.value.set(x, y, z);\nmaterial.uniforms.color.value.setHSL(hue, 1, 0.5);\n\n\u002F\u002F Matrix updates\nmaterial.uniforms.matrix.value.copy(mesh.matrixWorld);\n```\n\n## Varyings\n\nPass data from vertex to fragment shader.\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vPosition;\n\n    void main() {\n      vUv = uv;\n      vNormal = normalize(normalMatrix * normal);\n      vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vPosition;\n\n    void main() {\n      \u002F\u002F Use interpolated values\n      gl_FragColor = vec4(vNormal * 0.5 + 0.5, 1.0);\n    }\n  `,\n});\n```\n\n## Common Shader Patterns\n\n### Texture Sampling\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    map: { value: texture },\n  },\n  vertexShader: `\n    varying vec2 vUv;\n\n    void main() {\n      vUv = uv;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    uniform sampler2D map;\n    varying vec2 vUv;\n\n    void main() {\n      vec4 texColor = texture2D(map, vUv);\n      gl_FragColor = texColor;\n    }\n  `,\n});\n```\n\n### Vertex Displacement\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    time: { value: 0 },\n    amplitude: { value: 0.5 },\n  },\n  vertexShader: `\n    uniform float time;\n    uniform float amplitude;\n\n    void main() {\n      vec3 pos = position;\n\n      \u002F\u002F Wave displacement\n      pos.z += sin(pos.x * 5.0 + time) * amplitude;\n      pos.z += sin(pos.y * 5.0 + time) * amplitude;\n\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(0.5, 0.8, 1.0, 1.0);\n    }\n  `,\n});\n```\n\n### Fresnel Effect\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n\n    void main() {\n      vNormal = normalize(normalMatrix * normal);\n      vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n\n    void main() {\n      \u002F\u002F cameraPosition is auto-provided by ShaderMaterial\n      vec3 viewDirection = normalize(cameraPosition - vWorldPosition);\n      float fresnel = pow(1.0 - dot(viewDirection, vNormal), 3.0);\n\n      vec3 baseColor = vec3(0.0, 0.0, 0.5);\n      vec3 fresnelColor = vec3(0.5, 0.8, 1.0);\n\n      gl_FragColor = vec4(mix(baseColor, fresnelColor, fresnel), 1.0);\n    }\n  `,\n});\n```\n\n### Noise-Based Effects\n\n```glsl\n\u002F\u002F Simple noise function\nfloat random(vec2 st) {\n  return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\n\u002F\u002F Value noise\nfloat noise(vec2 st) {\n  vec2 i = floor(st);\n  vec2 f = fract(st);\n\n  float a = random(i);\n  float b = random(i + vec2(1.0, 0.0));\n  float c = random(i + vec2(0.0, 1.0));\n  float d = random(i + vec2(1.0, 1.0));\n\n  vec2 u = f * f * (3.0 - 2.0 * f);\n\n  return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;\n}\n\n\u002F\u002F Usage\nfloat n = noise(vUv * 10.0 + time);\n```\n\n### Gradient\n\n```glsl\n\u002F\u002F Linear gradient\nvec3 color = mix(colorA, colorB, vUv.y);\n\n\u002F\u002F Radial gradient\nfloat dist = distance(vUv, vec2(0.5));\nvec3 color = mix(centerColor, edgeColor, dist * 2.0);\n\n\u002F\u002F Smooth gradient with custom curve\nfloat t = smoothstep(0.0, 1.0, vUv.y);\nvec3 color = mix(colorA, colorB, t);\n```\n\n### Rim Lighting\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec3 vNormal;\n    varying vec3 vViewPosition;\n\n    void main() {\n      vNormal = normalize(normalMatrix * normal);\n      vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n      vViewPosition = mvPosition.xyz;\n      gl_Position = projectionMatrix * mvPosition;\n    }\n  `,\n  fragmentShader: `\n    varying vec3 vNormal;\n    varying vec3 vViewPosition;\n\n    void main() {\n      vec3 viewDir = normalize(-vViewPosition);\n      float rim = 1.0 - max(0.0, dot(viewDir, vNormal));\n      rim = pow(rim, 4.0);\n\n      vec3 baseColor = vec3(0.2, 0.2, 0.8);\n      vec3 rimColor = vec3(1.0, 0.5, 0.0);\n\n      gl_FragColor = vec4(baseColor + rimColor * rim, 1.0);\n    }\n  `,\n});\n```\n\n### Dissolve Effect\n\n```glsl\nuniform float progress;\nuniform sampler2D noiseMap;\n\nvoid main() {\n  float noise = texture2D(noiseMap, vUv).r;\n\n  if (noise \u003C progress) {\n    discard;\n  }\n\n  \u002F\u002F Edge glow\n  float edge = smoothstep(progress, progress + 0.1, noise);\n  vec3 edgeColor = vec3(1.0, 0.5, 0.0);\n  vec3 baseColor = vec3(0.5);\n\n  gl_FragColor = vec4(mix(edgeColor, baseColor, edge), 1.0);\n}\n```\n\n## Extending Built-in Materials\n\n### onBeforeCompile\n\nModify existing material shaders.\n\n```javascript\nconst material = new THREE.MeshStandardMaterial({ color: 0x00ff00 });\n\nmaterial.onBeforeCompile = (shader) => {\n  \u002F\u002F Add custom uniform\n  shader.uniforms.time = { value: 0 };\n\n  \u002F\u002F Store reference for updates\n  material.userData.shader = shader;\n\n  \u002F\u002F Modify vertex shader\n  shader.vertexShader = shader.vertexShader.replace(\n    \"#include \u003Cbegin_vertex>\",\n    `\n    #include \u003Cbegin_vertex>\n    transformed.y += sin(position.x * 10.0 + time) * 0.1;\n    `,\n  );\n\n  \u002F\u002F Add uniform declaration\n  shader.vertexShader = \"uniform float time;\\n\" + shader.vertexShader;\n};\n\n\u002F\u002F Update in animation loop\nif (material.userData.shader) {\n  material.userData.shader.uniforms.time.value = clock.getElapsedTime();\n}\n```\n\n### Common Injection Points\n\n```javascript\n\u002F\u002F Vertex shader chunks\n\"#include \u003Cbegin_vertex>\"; \u002F\u002F After position is calculated\n\"#include \u003Cproject_vertex>\"; \u002F\u002F After gl_Position\n\"#include \u003Cbeginnormal_vertex>\"; \u002F\u002F Normal calculation start\n\n\u002F\u002F Fragment shader chunks\n\"#include \u003Ccolor_fragment>\"; \u002F\u002F After diffuse color\n\"#include \u003Coutput_fragment>\"; \u002F\u002F Final output\n\"#include \u003Cfog_fragment>\"; \u002F\u002F After fog applied\n```\n\n## GLSL Built-in Functions\n\n### Math Functions\n\n```glsl\n\u002F\u002F Basic\nabs(x), sign(x), floor(x), ceil(x), fract(x)\nmod(x, y), min(x, y), max(x, y), clamp(x, min, max)\nmix(a, b, t), step(edge, x), smoothstep(edge0, edge1, x)\n\n\u002F\u002F Trigonometry\nsin(x), cos(x), tan(x)\nasin(x), acos(x), atan(y, x), atan(x)\nradians(degrees), degrees(radians)\n\n\u002F\u002F Exponential\npow(x, y), exp(x), log(x), exp2(x), log2(x)\nsqrt(x), inversesqrt(x)\n```\n\n### Vector Functions\n\n```glsl\n\u002F\u002F Length and distance\nlength(v), distance(p0, p1), dot(x, y), cross(x, y)\n\n\u002F\u002F Normalization\nnormalize(v)\n\n\u002F\u002F Reflection and refraction\nreflect(I, N), refract(I, N, eta)\n\n\u002F\u002F Component-wise\nlessThan(x, y), lessThanEqual(x, y)\ngreaterThan(x, y), greaterThanEqual(x, y)\nequal(x, y), notEqual(x, y)\nany(bvec), all(bvec)\n```\n\n### Texture Functions\n\n```glsl\n\u002F\u002F GLSL 1.0 (default) - use texture2D\u002FtextureCube\ntexture2D(sampler, coord)\ntexture2D(sampler, coord, bias)\ntextureCube(sampler, coord)\n\n\u002F\u002F GLSL 3.0 (glslVersion: THREE.GLSL3) - use texture()\n\u002F\u002F texture(sampler, coord) replaces texture2D\u002FtextureCube\n\u002F\u002F Also use: out vec4 fragColor instead of gl_FragColor\n\n\u002F\u002F Texture size (GLSL 1.30+)\ntextureSize(sampler, lod)\n```\n\n## Common Material Properties\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    \u002F* ... *\u002F\n  },\n  vertexShader: \"\u002F* ... *\u002F\",\n  fragmentShader: \"\u002F* ... *\u002F\",\n\n  \u002F\u002F Rendering\n  transparent: true,\n  opacity: 1.0,\n  side: THREE.DoubleSide,\n  depthTest: true,\n  depthWrite: true,\n\n  \u002F\u002F Blending\n  blending: THREE.NormalBlending,\n  \u002F\u002F AdditiveBlending, SubtractiveBlending, MultiplyBlending\n\n  \u002F\u002F Wireframe\n  wireframe: false,\n  wireframeLinewidth: 1, \u002F\u002F Note: >1 has no effect on most platforms (WebGL limitation)\n\n  \u002F\u002F Extensions\n  extensions: {\n    derivatives: true, \u002F\u002F For fwidth, dFdx, dFdy\n    fragDepth: true, \u002F\u002F gl_FragDepth\n    drawBuffers: true, \u002F\u002F Multiple render targets\n    shaderTextureLOD: true, \u002F\u002F texture2DLod\n  },\n\n  \u002F\u002F GLSL version\n  glslVersion: THREE.GLSL3, \u002F\u002F For WebGL2 features\n});\n```\n\n## Shader Includes\n\n### Using Three.js Shader Chunks\n\n```javascript\nimport { ShaderChunk } from \"three\";\n\nconst fragmentShader = `\n  ${ShaderChunk.common}\n  ${ShaderChunk.packing}\n\n  uniform sampler2D depthTexture;\n  varying vec2 vUv;\n\n  void main() {\n    float depth = texture2D(depthTexture, vUv).r;\n    float linearDepth = perspectiveDepthToViewZ(depth, 0.1, 1000.0);\n    gl_FragColor = vec4(vec3(-linearDepth \u002F 100.0), 1.0);\n  }\n`;\n```\n\n### External Shader Files\n\n```javascript\n\u002F\u002F With vite\u002Fwebpack\nimport vertexShader from \".\u002Fshaders\u002Fvertex.glsl\";\nimport fragmentShader from \".\u002Fshaders\u002Ffragment.glsl\";\n\nconst material = new THREE.ShaderMaterial({\n  vertexShader,\n  fragmentShader,\n});\n```\n\n## Instanced Shaders\n\n```javascript\n\u002F\u002F Instanced attribute\nconst offsets = new Float32Array(instanceCount * 3);\n\u002F\u002F Fill offsets...\ngeometry.setAttribute(\"offset\", new THREE.InstancedBufferAttribute(offsets, 3));\n\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    attribute vec3 offset;\n\n    void main() {\n      vec3 pos = position + offset;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n## Debugging Shaders\n\n```javascript\n\u002F\u002F Check for compile errors\nmaterial.onBeforeCompile = (shader) => {\n  console.log(\"Vertex Shader:\", shader.vertexShader);\n  console.log(\"Fragment Shader:\", shader.fragmentShader);\n};\n\n\u002F\u002F Visual debugging\nfragmentShader: `\n  void main() {\n    \u002F\u002F Debug UV\n    gl_FragColor = vec4(vUv, 0.0, 1.0);\n\n    \u002F\u002F Debug normals\n    gl_FragColor = vec4(vNormal * 0.5 + 0.5, 1.0);\n\n    \u002F\u002F Debug position\n    gl_FragColor = vec4(vPosition * 0.1 + 0.5, 1.0);\n  }\n`;\n\n\u002F\u002F Check WebGL errors\nrenderer.debug.checkShaderErrors = true;\n```\n\n## Performance Tips\n\n1. **Minimize uniforms**: Group related values into vectors\n2. **Avoid conditionals**: Use mix\u002Fstep instead of if\u002Felse\n3. **Precalculate**: Move calculations to JS when possible\n4. **Use textures**: For complex functions, use lookup tables\n5. **Limit overdraw**: Avoid transparent objects when possible\n\n```glsl\n\u002F\u002F Instead of:\nif (value > 0.5) {\n  color = colorA;\n} else {\n  color = colorB;\n}\n\n\u002F\u002F Use:\ncolor = mix(colorB, colorA, step(0.5, value));\n```\n\n## See Also\n\n- `threejs-materials` - Built-in material types\n- `threejs-postprocessing` - Full-screen shader effects\n- `threejs-textures` - Texture sampling in shaders\n","# Three.js Shaders\n\n## Quick Start\n\n```javascript\nimport * as THREE from \"three\";\n\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    time: { value: 0 },\n    color: { value: new THREE.Color(0xff0000) },\n  },\n  vertexShader: `\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    uniform vec3 color;\n\n    void main() {\n      gl_FragColor = vec4(color, 1.0);\n    }\n  `,\n});\n\n\u002F\u002F Update in animation loop\nmaterial.uniforms.time.value = clock.getElapsedTime();\n```\n\n## ShaderMaterial vs RawShaderMaterial\n\n### ShaderMaterial\n\nThree.js provides built-in uniforms and attributes.\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    \u002F\u002F Built-in uniforms available:\n    \u002F\u002F uniform mat4 modelMatrix;\n    \u002F\u002F uniform mat4 modelViewMatrix;\n    \u002F\u002F uniform mat4 projectionMatrix;\n    \u002F\u002F uniform mat4 viewMatrix;\n    \u002F\u002F uniform mat3 normalMatrix;\n    \u002F\u002F uniform vec3 cameraPosition;\n\n    \u002F\u002F Built-in attributes available:\n    \u002F\u002F attribute vec3 position;\n    \u002F\u002F attribute vec3 normal;\n    \u002F\u002F attribute vec2 uv;\n\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n### RawShaderMaterial\n\nFull control - you define everything.\n\n```javascript\nconst material = new THREE.RawShaderMaterial({\n  uniforms: {\n    projectionMatrix: { value: camera.projectionMatrix },\n    modelViewMatrix: { value: new THREE.Matrix4() },\n  },\n  vertexShader: `\n    precision highp float;\n\n    attribute vec3 position;\n    uniform mat4 projectionMatrix;\n    uniform mat4 modelViewMatrix;\n\n    void main() {\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    precision highp float;\n\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n## Uniforms\n\n### Uniform Types\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    \u002F\u002F Numbers\n    floatValue: { value: 1.5 },\n    intValue: { value: 1 },\n\n    \u002F\u002F Vectors\n    vec2Value: { value: new THREE.Vector2(1, 2) },\n    vec3Value: { value: new THREE.Vector3(1, 2, 3) },\n    vec4Value: { value: new THREE.Vector4(1, 2, 3, 4) },\n\n    \u002F\u002F Colors (converted to vec3)\n    colorValue: { value: new THREE.Color(0xff0000) },\n\n    \u002F\u002F Matrices\n    mat3Value: { value: new THREE.Matrix3() },\n    mat4Value: { value: new THREE.Matrix4() },\n\n    \u002F\u002F Textures\n    textureValue: { value: texture },\n    cubeTextureValue: { value: cubeTexture },\n\n    \u002F\u002F Arrays\n    floatArray: { value: [1.0, 2.0, 3.0] },\n    vec3Array: {\n      value: [new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0)],\n    },\n  },\n});\n```\n\n### GLSL Declarations\n\n```glsl\n\u002F\u002F In shader\nuniform float floatValue;\nuniform int intValue;\nuniform vec2 vec2Value;\nuniform vec3 vec3Value;\nuniform vec3 colorValue;    \u002F\u002F Color becomes vec3\nuniform vec4 vec4Value;\nuniform mat3 mat3Value;\nuniform mat4 mat4Value;\nuniform sampler2D textureValue;\nuniform samplerCube cubeTextureValue;\nuniform float floatArray[3];\nuniform vec3 vec3Array[2];\n```\n\n### Updating Uniforms\n\n```javascript\n\u002F\u002F Direct assignment\nmaterial.uniforms.time.value = clock.getElapsedTime();\n\n\u002F\u002F Vector\u002FColor updates\nmaterial.uniforms.position.value.set(x, y, z);\nmaterial.uniforms.color.value.setHSL(hue, 1, 0.5);\n\n\u002F\u002F Matrix updates\nmaterial.uniforms.matrix.value.copy(mesh.matrixWorld);\n```\n\n## Varyings\n\nPass data from vertex to fragment shader.\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vPosition;\n\n    void main() {\n      vUv = uv;\n      vNormal = normalize(normalMatrix * normal);\n      vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vPosition;\n\n    void main() {\n      \u002F\u002F Use interpolated values\n      gl_FragColor = vec4(vNormal * 0.5 + 0.5, 1.0);\n    }\n  `,\n});\n```\n\n## Common Shader Patterns\n\n### Texture Sampling\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    map: { value: texture },\n  },\n  vertexShader: `\n    varying vec2 vUv;\n\n    void main() {\n      vUv = uv;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    uniform sampler2D map;\n    varying vec2 vUv;\n\n    void main() {\n      vec4 texColor = texture2D(map, vUv);\n      gl_FragColor = texColor;\n    }\n  `,\n});\n```\n\n### Vertex Displacement\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    time: { value: 0 },\n    amplitude: { value: 0.5 },\n  },\n  vertexShader: `\n    uniform float time;\n    uniform float amplitude;\n\n    void main() {\n      vec3 pos = position;\n\n      \u002F\u002F Wave displacement\n      pos.z += sin(pos.x * 5.0 + time) * amplitude;\n      pos.z += sin(pos.y * 5.0 + time) * amplitude;\n\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(0.5, 0.8, 1.0, 1.0);\n    }\n  `,\n});\n```\n\n### Fresnel Effect\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n\n    void main() {\n      vNormal = normalize(normalMatrix * normal);\n      vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n    }\n  `,\n  fragmentShader: `\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n\n    void main() {\n      \u002F\u002F cameraPosition is auto-provided by ShaderMaterial\n      vec3 viewDirection = normalize(cameraPosition - vWorldPosition);\n      float fresnel = pow(1.0 - dot(viewDirection, vNormal), 3.0);\n\n      vec3 baseColor = vec3(0.0, 0.0, 0.5);\n      vec3 fresnelColor = vec3(0.5, 0.8, 1.0);\n\n      gl_FragColor = vec4(mix(baseColor, fresnelColor, fresnel), 1.0);\n    }\n  `,\n});\n```\n\n### Noise-Based Effects\n\n```glsl\n\u002F\u002F Simple noise function\nfloat random(vec2 st) {\n  return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\n\u002F\u002F Value noise\nfloat noise(vec2 st) {\n  vec2 i = floor(st);\n  vec2 f = fract(st);\n\n  float a = random(i);\n  float b = random(i + vec2(1.0, 0.0));\n  float c = random(i + vec2(0.0, 1.0));\n  float d = random(i + vec2(1.0, 1.0));\n\n  vec2 u = f * f * (3.0 - 2.0 * f);\n\n  return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;\n}\n\n\u002F\u002F Usage\nfloat n = noise(vUv * 10.0 + time);\n```\n\n### Gradient\n\n```glsl\n\u002F\u002F Linear gradient\nvec3 color = mix(colorA, colorB, vUv.y);\n\n\u002F\u002F Radial gradient\nfloat dist = distance(vUv, vec2(0.5));\nvec3 color = mix(centerColor, edgeColor, dist * 2.0);\n\n\u002F\u002F Smooth gradient with custom curve\nfloat t = smoothstep(0.0, 1.0, vUv.y);\nvec3 color = mix(colorA, colorB, t);\n```\n\n### Rim Lighting\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    varying vec3 vNormal;\n    varying vec3 vViewPosition;\n\n    void main() {\n      vNormal = normalize(normalMatrix * normal);\n      vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n      vViewPosition = mvPosition.xyz;\n      gl_Position = projectionMatrix * mvPosition;\n    }\n  `,\n  fragmentShader: `\n    varying vec3 vNormal;\n    varying vec3 vViewPosition;\n\n    void main() {\n      vec3 viewDir = normalize(-vViewPosition);\n      float rim = 1.0 - max(0.0, dot(viewDir, vNormal));\n      rim = pow(rim, 4.0);\n\n      vec3 baseColor = vec3(0.2, 0.2, 0.8);\n      vec3 rimColor = vec3(1.0, 0.5, 0.0);\n\n      gl_FragColor = vec4(baseColor + rimColor * rim, 1.0);\n    }\n  `,\n});\n```\n\n### Dissolve Effect\n\n```glsl\nuniform float progress;\nuniform sampler2D noiseMap;\n\nvoid main() {\n  float noise = texture2D(noiseMap, vUv).r;\n\n  if (noise \u003C progress) {\n    discard;\n  }\n\n  \u002F\u002F Edge glow\n  float edge = smoothstep(progress, progress + 0.1, noise);\n  vec3 edgeColor = vec3(1.0, 0.5, 0.0);\n  vec3 baseColor = vec3(0.5);\n\n  gl_FragColor = vec4(mix(edgeColor, baseColor, edge), 1.0);\n}\n```\n\n## Extending Built-in Materials\n\n### onBeforeCompile\n\nModify existing material shaders.\n\n```javascript\nconst material = new THREE.MeshStandardMaterial({ color: 0x00ff00 });\n\nmaterial.onBeforeCompile = (shader) => {\n  \u002F\u002F Add custom uniform\n  shader.uniforms.time = { value: 0 };\n\n  \u002F\u002F Store reference for updates\n  material.userData.shader = shader;\n\n  \u002F\u002F Modify vertex shader\n  shader.vertexShader = shader.vertexShader.replace(\n    \"#include \u003Cbegin_vertex>\",\n    `\n    #include \u003Cbegin_vertex>\n    transformed.y += sin(position.x * 10.0 + time) * 0.1;\n    `,\n  );\n\n  \u002F\u002F Add uniform declaration\n  shader.vertexShader = \"uniform float time;\\n\" + shader.vertexShader;\n};\n\n\u002F\u002F Update in animation loop\nif (material.userData.shader) {\n  material.userData.shader.uniforms.time.value = clock.getElapsedTime();\n}\n```\n\n### Common Injection Points\n\n```javascript\n\u002F\u002F Vertex shader chunks\n\"#include \u003Cbegin_vertex>\"; \u002F\u002F After position is calculated\n\"#include \u003Cproject_vertex>\"; \u002F\u002F After gl_Position\n\"#include \u003Cbeginnormal_vertex>\"; \u002F\u002F Normal calculation start\n\n\u002F\u002F Fragment shader chunks\n\"#include \u003Ccolor_fragment>\"; \u002F\u002F After diffuse color\n\"#include \u003Coutput_fragment>\"; \u002F\u002F Final output\n\"#include \u003Cfog_fragment>\"; \u002F\u002F After fog applied\n```\n\n## GLSL Built-in Functions\n\n### Math Functions\n\n```glsl\n\u002F\u002F Basic\nabs(x), sign(x), floor(x), ceil(x), fract(x)\nmod(x, y), min(x, y), max(x, y), clamp(x, min, max)\nmix(a, b, t), step(edge, x), smoothstep(edge0, edge1, x)\n\n\u002F\u002F Trigonometry\nsin(x), cos(x), tan(x)\nasin(x), acos(x), atan(y, x), atan(x)\nradians(degrees), degrees(radians)\n\n\u002F\u002F Exponential\npow(x, y), exp(x), log(x), exp2(x), log2(x)\nsqrt(x), inversesqrt(x)\n```\n\n### Vector Functions\n\n```glsl\n\u002F\u002F Length and distance\nlength(v), distance(p0, p1), dot(x, y), cross(x, y)\n\n\u002F\u002F Normalization\nnormalize(v)\n\n\u002F\u002F Reflection and refraction\nreflect(I, N), refract(I, N, eta)\n\n\u002F\u002F Component-wise\nlessThan(x, y), lessThanEqual(x, y)\ngreaterThan(x, y), greaterThanEqual(x, y)\nequal(x, y), notEqual(x, y)\nany(bvec), all(bvec)\n```\n\n### Texture Functions\n\n```glsl\n\u002F\u002F GLSL 1.0 (default) - use texture2D\u002FtextureCube\ntexture2D(sampler, coord)\ntexture2D(sampler, coord, bias)\ntextureCube(sampler, coord)\n\n\u002F\u002F GLSL 3.0 (glslVersion: THREE.GLSL3) - use texture()\n\u002F\u002F texture(sampler, coord) replaces texture2D\u002FtextureCube\n\u002F\u002F Also use: out vec4 fragColor instead of gl_FragColor\n\n\u002F\u002F Texture size (GLSL 1.30+)\ntextureSize(sampler, lod)\n```\n\n## Common Material Properties\n\n```javascript\nconst material = new THREE.ShaderMaterial({\n  uniforms: {\n    \u002F* ... *\u002F\n  },\n  vertexShader: \"\u002F* ... *\u002F\",\n  fragmentShader: \"\u002F* ... *\u002F\",\n\n  \u002F\u002F Rendering\n  transparent: true,\n  opacity: 1.0,\n  side: THREE.DoubleSide,\n  depthTest: true,\n  depthWrite: true,\n\n  \u002F\u002F Blending\n  blending: THREE.NormalBlending,\n  \u002F\u002F AdditiveBlending, SubtractiveBlending, MultiplyBlending\n\n  \u002F\u002F Wireframe\n  wireframe: false,\n  wireframeLinewidth: 1, \u002F\u002F Note: >1 has no effect on most platforms (WebGL limitation)\n\n  \u002F\u002F Extensions\n  extensions: {\n    derivatives: true, \u002F\u002F For fwidth, dFdx, dFdy\n    fragDepth: true, \u002F\u002F gl_FragDepth\n    drawBuffers: true, \u002F\u002F Multiple render targets\n    shaderTextureLOD: true, \u002F\u002F texture2DLod\n  },\n\n  \u002F\u002F GLSL version\n  glslVersion: THREE.GLSL3, \u002F\u002F For WebGL2 features\n});\n```\n\n## Shader Includes\n\n### Using Three.js Shader Chunks\n\n```javascript\nimport { ShaderChunk } from \"three\";\n\nconst fragmentShader = `\n  ${ShaderChunk.common}\n  ${ShaderChunk.packing}\n\n  uniform sampler2D depthTexture;\n  varying vec2 vUv;\n\n  void main() {\n    float depth = texture2D(depthTexture, vUv).r;\n    float linearDepth = perspectiveDepthToViewZ(depth, 0.1, 1000.0);\n    gl_FragColor = vec4(vec3(-linearDepth \u002F 100.0), 1.0);\n  }\n`;\n```\n\n### External Shader Files\n\n```javascript\n\u002F\u002F With vite\u002Fwebpack\nimport vertexShader from \".\u002Fshaders\u002Fvertex.glsl\";\nimport fragmentShader from \".\u002Fshaders\u002Ffragment.glsl\";\n\nconst material = new THREE.ShaderMaterial({\n  vertexShader,\n  fragmentShader,\n});\n```\n\n## Instanced Shaders\n\n```javascript\n\u002F\u002F Instanced attribute\nconst offsets = new Float32Array(instanceCount * 3);\n\u002F\u002F Fill offsets...\ngeometry.setAttribute(\"offset\", new THREE.InstancedBufferAttribute(offsets, 3));\n\nconst material = new THREE.ShaderMaterial({\n  vertexShader: `\n    attribute vec3 offset;\n\n    void main() {\n      vec3 pos = position + offset;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n    }\n  `,\n  fragmentShader: `\n    void main() {\n      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n  `,\n});\n```\n\n## Debugging Shaders\n\n```javascript\n\u002F\u002F Check for compile errors\nmaterial.onBeforeCompile = (shader) => {\n  console.log(\"Vertex Shader:\", shader.vertexShader);\n  console.log(\"Fragment Shader:\", shader.fragmentShader);\n};\n\n\u002F\u002F Visual debugging\nfragmentShader: `\n  void main() {\n    \u002F\u002F Debug UV\n    gl_FragColor = vec4(vUv, 0.0, 1.0);\n\n    \u002F\u002F Debug normals\n    gl_FragColor = vec4(vNormal * 0.5 + 0.5, 1.0);\n\n    \u002F\u002F Debug position\n    gl_FragColor = vec4(vPosition * 0.1 + 0.5, 1.0);\n  }\n`;\n\n\u002F\u002F Check WebGL errors\nrenderer.debug.checkShaderErrors = true;\n```\n\n## Performance Tips\n\n1. **Minimize uniforms**: Group related values into vectors\n2. **Avoid conditionals**: Use mix\u002Fstep instead of if\u002Felse\n3. **Precalculate**: Move calculations to JS when possible\n4. **Use textures**: For complex functions, use lookup tables\n5. **Limit overdraw**: Avoid transparent objects when possible\n\n```glsl\n\u002F\u002F Instead of:\nif (value > 0.5) {\n  color = colorA;\n} else {\n  color = colorB;\n}\n\n\u002F\u002F Use:\ncolor = mix(colorB, colorA, step(0.5, value));\n```\n\n## See Also\n\n- `threejs-materials` - Built-in material types\n- `threejs-postprocessing` - Full-screen shader effects\n- `threejs-textures` - Texture sampling in shaders\n",{"name":5,"description":7},"main","54811af304ee97dc5151722bfdc94788ab739436",".claude\u002Fskills\u002Fthreejs-shaders",0,"https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety","https:\u002F\u002Fninety-nu.vercel.app\u002Fterminal","https:\u002F\u002Fgithub.com\u002FSushant6095","👨‍💻 Full‑Stack Backend  Developer | Web3 Enthusiast | DevOps Engineer  \r\n| Building scalable cloud‑native apps & decentralized solutions sj317772@gmail.com","2026-07-20 00:16:18",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Sushant6095\u002Fninety --skill threejs-shaders",{"tool":39,"command":40},"bunx","bunx skills add Sushant6095\u002Fninety --skill threejs-shaders",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Sushant6095\u002Fninety --skill threejs-shaders","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fthreejs-shaders\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M78F72WY1AKMM5FT7FK1EDGX","ui-ux-pro-max","UI\u002FUX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn\u002Fui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI\u002FUX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn\u002Fui MCP for component search and examples.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fui-ux-pro-max\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M78F6WRQ6F94MS14HP7A7FBV","ui-craft","The ROUTER for all apps\u002Fweb frontend work. NOT a craft skill — a thin dispatcher. It reads the task and tells you which PROVEN published skill to invoke. Use before any apps\u002Fweb change. It has no design opinions of its own; the proven skills carry the craft, CLAUDE.md carries the constraints, this router connects them.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fui-craft\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M78F6TANFCA0XVS1E0K3TPXG","txline-integration","Use for any work touching TxLINE — adding endpoints, auth\u002Ftoken issues, stream handling, normalization, replay data, or filling packages\u002Ftxline.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftxline-integration\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M78F6P4746YSK45G9SYPWHK3","threejs-textures","Three.js textures - texture types, UV mapping, environment maps, texture settings. Use when working with images, UV coordinates, cubemaps, HDR environments, or texture optimization.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fthreejs-textures\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M78F6EMWRJTMTJZJE7DX0TDR","threejs-postprocessing","Three.js post-processing - EffectComposer, bloom, DOF, screen effects. Use when adding visual effects, color grading, blur, glow, or creating custom screen-space shaders.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fthreejs-postprocessing\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M78F69FMR7KJX43ZEJF17REV","threejs-materials","Three.js materials - PBR, basic, phong, shader materials, material properties. Use when styling meshes, working with textures, creating custom shaders, or optimizing material performance.","https:\u002F\u002Fgithub.com\u002FSushant6095\u002Fninety\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fthreejs-materials\u002FSKILL.md",[],[]]