struct VertexOut { @builtin(position) proj_position: vec4, @location(0) normal: vec3, @location(1) color: vec4, }; type FragmentIn = VertexOut; struct VertexIn { @location(0) pos: vec3, @location(1) normal: vec3, @location(2) color: vec4, }; @group(0) @binding(0) var u_pvm: mat4x4; @vertex fn vs_main( in: VertexIn ) -> VertexOut { var out: VertexOut; out.proj_position = u_pvm * vec4(in.pos, 1.0); out.color = in.color; out.normal = in.normal; return out; } @fragment fn fs_main( in: FragmentIn ) -> @location(0) vec4 { if (length(in.color) != 0.0) { return vec4(in.color.xyz, 1.0); } else { return vec4(in.normal, 1.0); } }