diff --git a/README.md b/README.md index 224865d..87fba70 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,5 @@ For miniserve, see: ## Assets - Sponza - Obtained from [KhronosGroup glTF-Sample-Models repository](https://github.com/KhronosGroup/glTF-Sample-Models/tree/16e2408d31e06d4b0bcf6123db472e802d71f081/2.0/Sponza), converted to .glb +- Cube + - Obtained from [KhronosGroup glTF-Sample-Models repository](https://github.com/KhronosGroup/glTF-Sample-Models/tree/16e2408d31e06d4b0bcf6123db472e802d71f081/2.0/Cube), converted to .glb diff --git a/res/models/Cube.glb b/res/models/Cube.glb new file mode 100644 index 0000000..d9de785 Binary files /dev/null and b/res/models/Cube.glb differ diff --git a/res/shaders/light.wgsl b/res/shaders/light.wgsl index 098499a..db3b8d5 100644 --- a/res/shaders/light.wgsl +++ b/res/shaders/light.wgsl @@ -28,7 +28,7 @@ struct VertexOutput { fn vs_main( model: VertexInput, ) -> VertexOutput { - let scale = 0.01; + let scale = 10.0; var out: VertexOutput; out.clip_position = camera.proj * camera.view * vec4(model.position * scale + light.position, 1.0); out.color = light.color; diff --git a/src/core/state.rs b/src/core/state.rs index 2247b4e..bc2d0b1 100644 --- a/src/core/state.rs +++ b/src/core/state.rs @@ -29,6 +29,7 @@ pub struct State { instance_buffer: wgpu::Buffer, depth_texture: Texture, model: Model, + light_model: Model, light_uniform: LightUniform, light_buffer: wgpu::Buffer, light_debug_pass: RenderPass, @@ -222,6 +223,15 @@ impl State { .await .unwrap(); + let light_model = resources::load_model_gltf( + "models/Cube.glb", + &device, + &queue, + &texture_bind_group_layout, + ) + .await + .unwrap(); + let instances = vec![Instance { position: [0.0, 0.0, 0.0].into(), rotation: cgmath::Quaternion::one(), @@ -276,6 +286,7 @@ impl State { instance_buffer, depth_texture, model, + light_model, light_uniform, light_buffer, light_debug_pass, @@ -366,16 +377,14 @@ impl State { }), }); - // TODO: only use for geom, not lights - render_pass.set_vertex_buffer(1, self.instance_buffer.slice(..)); - render_pass.set_pipeline(&self.light_debug_pass.pipeline); render_pass.draw_light_model( - &self.model, + &self.light_model, &self.camera_bind_group, &self.light_bind_group, ); + render_pass.set_vertex_buffer(1, self.instance_buffer.slice(..)); render_pass.set_pipeline(&self.geometry_pass.pipeline); render_pass.draw_model_instanced( &self.model,