struct VertexOutput @builtin(position) position: vec4 uv: vec2 end struct Camera view_proj: mat4 position: vec3 end struct FragmentOutput color: vec4 end struct Lighting direction: vec3 color: vec3 intensity: float end group frame = 0 uniform camera: Camera uniform lighting: Lighting end group material = 1 texture diffuse_tex: sampler2D texture normal_tex: sampler2D end @entry(fragment) function fs_main(input: VertexOutput) -> FragmentOutput let diffuse = sample(diffuse_tex, input.uv) let normal_sample = sample(normal_tex, input.uv) let n = normalize(normal_sample.xyz * 2.0 - vec3(1.0, 1.0, 1.0)) let l = normalize(lighting.direction) let ndotl = max(dot(n, l), 0.0) let lit = diffuse.rgb * lighting.color * ndotl * lighting.intensity return FragmentOutput { color = vec4(lit, diffuse.a), } end