Skip to content

Commit

Permalink
added the suggested solution, but not working currently
Browse files Browse the repository at this point in the history
  • Loading branch information
aabdullah27182845 committed Sep 28, 2024
1 parent ef5830f commit 343db5a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/fj-viewer/src/graphics/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ const pi: f32 = 3.14159265359;
@fragment
fn frag_model(in: VertexOutput) -> FragmentOutput {
let light = vec3<f32>(0.0, 0.0, -1.0);
let distance_from_camera = length(in.position.xyz);

let darkening_factor = 0.5 + 1.0/ (1.0 + exp(distance_from_camera));

let angle = acos(dot(light, -in.normal));
let f_angle = angle / (pi * 0.75);

let f_normal = max(1.0 - f_angle, 0.0);

var out: FragmentOutput;
out.color = vec4<f32>(in.color.rgb * f_normal, in.color.a);
out.color = vec4<f32>(in.color.rgb * f_normal * darkening_factor, in.color.a);

return out;
}
Expand Down

0 comments on commit 343db5a

Please sign in to comment.