Skip to content

Commit

Permalink
Fix ambient light
Browse files Browse the repository at this point in the history
  • Loading branch information
jgayfer committed Aug 4, 2024
1 parent d42c4fb commit 2d9507c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/render/light_map/light_map.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
let pos = ndc_to_world(frag_coord_to_ndc(in.position.xy));

if get_distance(pos) <= 0.0 {
return ambient_light.color;
return vec4(ambient_light.color.rgb, 1.0);
}

var lighting_color = vec4(1.0);
var lighting_color = vec3(1.0);

// WebGL2 does not support storage buffers (or runtime sized arrays), so we
// need to use a fixed number of point lights.
Expand All @@ -61,12 +61,12 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
let raymarch = raymarch(pos, light.center);

if raymarch > 0.0 {
lighting_color += light.color * attenuation(light, dist);
lighting_color += light.color.rgb * attenuation(light, dist);
}
}
}

return ambient_light.color * lighting_color;
return vec4(ambient_light.color.rgb, 1.0) * vec4(lighting_color, 1.0);
}

fn square(x: f32) -> f32 {
Expand Down

0 comments on commit 2d9507c

Please sign in to comment.