0

I'm following this WebGPU tutorial, and I copied the below shader code (shader.wgsl, full file is here):

// vertex shader

struct Output {
    @builtin(position) Position : vec4<f32>; // <-- error in this line
    @location(0) vColor : vec4<f32>;
};

I get an error in the dev console saying:

Tint WGSL reader failure: :4:44 error: expected '}' for struct declaration
    @builtin(position) Position : vec4<f32>;

Is this an error with the actual code, or with the way I'm loading it? I'm using ts-shader-loader because I'm inside an Angular/TypeScript application.

The way I'm using the shader.wgsl file can be seen here.

Any pointers as to what might be going wrong would be highly appreciated!

Hoff
  • 38,776
  • 17
  • 74
  • 99

1 Answers1

1

structure fields in WGSL end with , not with ;

struct Output {
    @builtin(position) Position : vec4<f32>,
    @location(0) vColor : vec4<f32>,
};
gman
  • 100,619
  • 31
  • 269
  • 393