08 What Three.js writes for you
ShaderMaterial: write the whole material yourself
The sphere on the left is coloured entirely by the code on the right. Edit it, and switch material type and GLSL version.
Exercise
Runs once per pixelDrag numbers, or edit the code
JS side
material.uniforms.uTime.value = 0.00ShaderMaterial injects the matrix and attribute declarations for you; RawShaderMaterial adds nothing. GLSL 3.00 uses in/out and texture().
Try it
- Change 12.0 in the fragment code for more stripes
- Switch to RawShaderMaterial and read the extra declarations
- Switch to GLSL 3.00 and compare how names change
- Press “Full code” to see the source Three.js actually compiles