Writing a shader by hand
A material can name a .wgsl file (Inspector > Shader file, or NEW SHADER FILE which makes Shaders/<Material>.wgsl from a starter and opens it in the code editor). The file replaces the material's surface; it takes the node graph's place.
The file defines one function:
fn graph_surface(in: VsOut, v: vec3<f32>, base: Surface, tex: vec3<f32>, time: f32) -> Surface
in: the pixel (world_pos,normal,local_pos,local_normal,uv,uv2);v: to the camera;time: seconds.base: what the material's own values make (albedo,emissive,shininess,spec,metallic,ao,nrm,alpha); return it changed.texis the albedo map's colour here.- Also available:
cam,sun,value_noise(vec3),sample_layer(layer, uv).
Saving the file updates the material within a third of a second. A mistake is written to the Console with the file's own line and the material keeps its normal look. Helper functions may be added above graph_surface.