struct Camera { camera_matrix: mat4x4, projection: mat4x4, } struct Light { position: vec4, color: vec4, light_type: vec4, } struct Lights { lights: array, } struct SceneInfo { bk_color: vec4, resolution: vec2, time: f32, nlights: u32, } @group(0) @binding(0) var camera: Camera; @group(0) @binding(1) var lights: Lights; @group(0) @binding(2) var info: SceneInfo; const acm0: vec4 = vec4(1.0, 2.1, 3.2, 4.3); const acm1: vec4 = vec4(5.4, 6.5, 7.6, 8.7); const acm2: vec4 = vec4(9.8, 10.9, 11.0, 12.0); const acm3: vec4 = vec4(13.0, 14.0, 15.0, 16.23); const acp0: vec4 = vec4(11.714964805291158, -20.083602331793195, 0.2296881862103637, 1.0000000000018192); const acp1: vec4 = vec4(-7.919279773964541, 12.919469128453738, -1.3377250768579256, -2.0000000000036002); const acp2: vec4 = vec4(-23.645933626763625, 36.55672789512988, 1.9863855950847729, 1.0000000000017617); const acp3: vec4 = vec4(19.301563694896643, -28.84390979125007, -0.8783487044372066, 0.000000000000025531539193725142); const alp0: vec4 = vec4(0.1, 0.2, 0.3, 1.0); const alc0: vec4 = vec4(0.4, 0.5, 0.6, 1.0); const alt0: vec4 = vec4(0u, 0u, 0u, 0u); const alp1: vec4 = vec4(1.1, 1.2, 1.3, 1.0); const alc1: vec4 = vec4(1.4, 1.5, 1.6, 1.0); const alt1: vec4 = vec4(1u, 0u, 0u, 0u); const asnl: u32 = 2u; const abk: vec4 = vec4(0.1, 0.2, 0.3, 0.4); const arsl: vec2 = vec2(256u, 256u); const EPS: f32 = 1.0e-5; const e: vec2 = vec2(1.0, 0.0); @vertex fn vs_main(@location(0) idx: u32) -> @builtin(position) vec4 { var vertex: array, 4>; vertex[0] = vec2(-1.0, -1.0); vertex[1] = vec2(1.0, -1.0); vertex[2] = vec2(-1.0, 1.0); vertex[3] = vec2(1.0, 1.0); if (distance(camera.camera_matrix * e.xyyy, acm0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yxyy, acm1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyxy, acm2) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyyx, acm3) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.xyyy, acp0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.yxyy, acp1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.yyxy, acp2) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.yyyx, acp3) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(lights.lights[0].position, alp0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(lights.lights[0].color, alc0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (any(lights.lights[0].light_type != alt0)) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(lights.lights[1].position, alp1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(lights.lights[1].color, alc1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (any(lights.lights[1].light_type != alt1)) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (info.nlights != asnl) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(info.bk_color, abk) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (any(info.resolution != arsl)) { return vec4(0.0, 0.0, 0.0, 1.0); } else { return vec4(vertex[idx], 0.0, 1.0); } } @fragment fn fs_main() -> @location(0) vec4 { if (distance(camera.camera_matrix * e.xyyy, acm0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yxyy, acm1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyxy, acm2) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyyx, acm3) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.xyyy, acp0) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yxyy, acp1) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yyxy, acp2) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yyyx, acp3) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(lights.lights[0].position, alp0) > EPS) { return vec4(0.2, 0.2, 0.2, 1.0); } else if (distance(lights.lights[0].color, alc0) > EPS) { return vec4(0.3, 0.3, 0.3, 1.0); } else if (any(lights.lights[0].light_type != alt0)) { return vec4(0.4, 0.4, 0.4, 1.0); } else if (distance(lights.lights[1].position, alp1) > EPS) { return vec4(0.5, 0.5, 0.5, 1.0); } else if (distance(lights.lights[1].color, alc1) > EPS) { return vec4(0.6, 0.6, 0.6, 1.0); } else if (any(lights.lights[1].light_type != alt1)) { return vec4(0.7, 0.7, 0.7, 1.0); } else if (info.nlights != asnl) { return vec4(0.8, 0.8, 0.8, 1.0); } else if (distance(info.bk_color, abk) > EPS) { return vec4(0.9, 0.9, 0.9, 1.0); } else if (any(info.resolution != arsl)) { return vec4(0.9, 0.9, 0.9, 1.0); } else { return vec4(0.2, 0.4, 0.6, 0.8); } } @fragment fn fs_main_anti() -> @location(0) vec4 { if (distance(camera.camera_matrix * e.xyyy, acm0) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yxyy, acm1) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyxy, acm2) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.camera_matrix * e.yyyx, acm3) > EPS) { return vec4(0.0, 0.0, 0.0, 1.0); } else if (distance(camera.projection * e.xyyy, acp0) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yxyy, acp1) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yyxy, acp2) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(camera.projection * e.yyyx, acp3) > EPS) { return vec4(0.1, 0.1, 0.1, 1.0); } else if (distance(lights.lights[0].position, alp0) > EPS) { return vec4(0.2, 0.2, 0.2, 1.0); } else if (distance(lights.lights[0].color, alc0) > EPS) { return vec4(0.3, 0.3, 0.3, 1.0); } else if (any(lights.lights[0].light_type != alt0)) { return vec4(0.4, 0.4, 0.4, 1.0); } else if (distance(lights.lights[1].position, alp1) > EPS) { return vec4(0.5, 0.5, 0.5, 1.0); } else if (distance(lights.lights[1].color, alc1) > EPS) { return vec4(0.6, 0.6, 0.6, 1.0); } else if (any(lights.lights[1].light_type == alt1)) { return vec4(0.7, 0.7, 0.7, 1.0); } else if (info.nlights != asnl) { return vec4(0.8, 0.8, 0.8, 1.0); } else if (distance(info.bk_color, abk) > EPS) { return vec4(0.9, 0.9, 0.9, 1.0); } else if (any(info.resolution != arsl)) { return vec4(0.9, 0.9, 0.9, 1.0); } else { return vec4(0.2, 0.4, 0.6, 0.8); } }