From 7c6062dcedac599efe406e65aa1b78e8b085654b Mon Sep 17 00:00:00 2001 From: nullprop Date: Sat, 15 Apr 2023 19:52:58 +0300 Subject: [PATCH] fix light position offset --- README.md | 7 ++----- res/shaders/pbr.wgsl | 2 +- src/core/state.rs | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d1e65db..ca4fcdc 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,13 @@ Controls: ## Features -- Physically based shading - - (F: Fresnel-Schlick approximation) - - (G: Smith's Schlick-GGX) - - (D: Trowbridge-Reitz GGX) +- PBS - glTF models - 1 realtime pointlight - Simple wgsl preprocessor for includes - Runs on WASM and native desktop - Tested on: - - `Manjaro Linux 22.0.1 (6.1.7-1-MANJARO)` + - `Ubuntu 22.04 (Mesa 23.1.0-devel)` - `Windows 10 Pro 21H2` - `Firefox 109.0` - `Chrome 109.0.5414.120` diff --git a/res/shaders/pbr.wgsl b/res/shaders/pbr.wgsl index 7a6eece..c274862 100644 --- a/res/shaders/pbr.wgsl +++ b/res/shaders/pbr.wgsl @@ -100,7 +100,7 @@ fn fs_main(vert: VertexOutput) -> @location(0) vec4 { var in_light = 0.0; for (var i: i32 = 0; i < 6; i++) { - in_light = sample_direct_light(i, light.matrices[i] * vert.world_position); + in_light = sample_direct_light(i, light.matrices[i] * (vert.world_position - vec4(light.position, 0.0))); if (in_light > 0.0) { break; } diff --git a/src/core/state.rs b/src/core/state.rs index fb98f43..e1786cd 100644 --- a/src/core/state.rs +++ b/src/core/state.rs @@ -561,7 +561,6 @@ impl State { light_depth_render_pass.set_vertex_buffer(1, self.instance_buffer.slice(..)); light_depth_render_pass.set_pipeline(&self.light_depth_pass.pipeline); - // TODO separate func light_depth_render_pass.draw_model_instanced( &self.model, 0..self.instances.len() as u32,