Skip to content

Commit

Permalink
Fix shader compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Aug 22, 2022
1 parent 331fefc commit 0583202
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions crates/fj-viewer/src/graphics/shader.wgsl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] normal: vec3<f32>;
[[location(1)]] color: vec4<f32>;
@builtin(position) position: vec4<f32>,
@location(0) normal: vec3<f32>,
@location(1) color: vec4<f32>,
};

struct Uniforms {
transform: mat4x4<f32>;
transform_normals: mat4x4<f32>;
transform: mat4x4<f32>,
transform_normals: mat4x4<f32>,
};

[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> uniforms: Uniforms;

[[stage(vertex)]]
@vertex
fn vertex(
[[location(0)]] position: vec3<f32>,
[[location(1)]] normal: vec3<f32>,
[[location(2)]] color: vec4<f32>,
@location(0) position: vec3<f32>,
@location(1) normal: vec3<f32>,
@location(2) color: vec4<f32>,
)
-> VertexOutput
{
Expand All @@ -31,8 +31,8 @@ fn vertex(

let pi: f32 = 3.14159265359;

[[stage(fragment)]]
fn frag_model(in: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn frag_model(in: VertexOutput) -> @location(0) vec4<f32> {
let light = vec3<f32>(0.0, 0.0, -1.0);

let angle = acos(dot(light, -in.normal));
Expand All @@ -45,12 +45,12 @@ fn frag_model(in: VertexOutput) -> [[location(0)]] vec4<f32> {
return color;
}

[[stage(fragment)]]
fn frag_mesh(in: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn frag_mesh(in: VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(1.0 - in.color.rgb, in.color.a);
}

[[stage(fragment)]]
fn frag_lines(in: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn frag_lines(in: VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(in.color.rgb, in.color.a);
}

0 comments on commit 0583202

Please sign in to comment.