# custom-shader-material

Write a custom GLSL ShaderMaterial (time-animated vertex displacement + fragment gradient) that compiles cleanly and reports shader errors loudly

- **Space:** threejs-public (https://github.com/Tech-Realm/space-threejs-public/tree/main/custom-shader-material)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3, playwright-python, chromium
- **Routes:** static-local; checks: 1
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use threejs-public/custom-shader-material` or MCP `get_pack threejs-public/custom-shader-material`
- **Files:** CHANGELOG.md, code/boot.js, code/index.html, code/main.js, code/shaders.js, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal
A working ShaderMaterial template with uniforms (time, resolution, colour), vertex displacement and a fragment effect, plus a compile-error hook so broken shaders fail loudly in checks.

## Steps
1. Copy `code/`; edit `shaders.js` (vertex + fragment strings).
2. Uniforms update in the loop; keep per-frame JS work to uniform writes.
3. Compile errors are caught by `renderer.debug.onShaderError` and reported as console errors (so checks fail).
4. Check: `python3 ../tools/webgl_check.py code --js "window.__shader.compiled"`.

## Edge cases
- Precision: use `highp` for positions; mobile GPUs may lack highp in fragment shaders (rare today).
- Use onBeforeCompile to extend built-in materials instead when you need lighting.

## Don'ts
- Don't branch heavily per pixel; prefer mix/step.
- Don't allocate new uniforms objects per frame.



---

Canonical URL: https://logicpacks.io/packs/threejs-public/custom-shader-material

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
