Skip to content

Commit

Permalink
Merge pull request #979 from hannobraun/shader
Browse files Browse the repository at this point in the history
Fix shader compilation errors
  • Loading branch information
hannobraun authored Aug 22, 2022
2 parents 331fefc + 0583202 commit 777aeba
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 777aeba

Please sign in to comment.