diff --git a/examples/gkurve/main.zig b/examples/gkurve/main.zig index d77a08c9..118da372 100644 --- a/examples/gkurve/main.zig +++ b/examples/gkurve/main.zig @@ -12,13 +12,12 @@ const glfw = @import("glfw"); pub const Vertex = struct { pos: @Vector(4, f32), uv: @Vector(2, f32), - bary: @Vector(3, f32) = .{ 0, 0, 0 }, }; // Simple triangle pub const vertices = [_]Vertex{ - .{ .pos = .{ 0, 250, 0, 1 }, .uv = .{ 0.5, 1 }, .bary = .{ 0, 0, 1 } }, - .{ .pos = .{ -250, -250, 0, 1 }, .uv = .{ 0, 0 }, .bary = .{ 1, 0, 0 } }, - .{ .pos = .{ 250, -250, 0, 1 }, .uv = .{ 1, 0 }, .bary = .{ 0, 1, 0 } }, + .{ .pos = .{ 0, 250, 0, 1 }, .uv = .{ 0.5, 1 } }, + .{ .pos = .{ -250, -250, 0, 1 }, .uv = .{ 0, 0 } }, + .{ .pos = .{ 250, -250, 0, 1 }, .uv = .{ 1, 0 } }, }; // TODO: Need to ask Ayush about this, ideally we have a square window in this example because it @@ -73,7 +72,6 @@ pub fn init(app: *App, engine: *mach.Engine) !void { const vertex_attributes = [_]gpu.VertexAttribute{ .{ .format = .float32x4, .offset = @offsetOf(Vertex, "pos"), .shader_location = 0 }, .{ .format = .float32x2, .offset = @offsetOf(Vertex, "uv"), .shader_location = 1 }, - .{ .format = .float32x3, .offset = @offsetOf(Vertex, "bary"), .shader_location = 2 }, }; const vertex_buffer_layout = gpu.VertexBufferLayout{ .array_stride = @sizeOf(Vertex), diff --git a/examples/gkurve/vert.wgsl b/examples/gkurve/vert.wgsl index 1c008a8d..5e7cf473 100644 --- a/examples/gkurve/vert.wgsl +++ b/examples/gkurve/vert.wgsl @@ -12,14 +12,18 @@ struct VertexOut { @stage(vertex) fn main( @builtin(instance_index) instanceIdx: u32, + @builtin(vertex_index) vertex_index: u32, @location(0) position: vec4, @location(1) uv: vec2, - @location(2) bary: vec3, ) -> VertexOut { - var output: VertexOut; + var output : VertexOut; output.position_clip = ubos[instanceIdx].matrix * position; output.frag_uv = uv; - output.frag_bary = bary; + output.frag_bary = vec3( + f32(vertex_index % 3u == 1u), + f32(vertex_index % 3u == 2u), + f32(vertex_index % 3u == 0u), + ); output.instance_index = instanceIdx; return output; }