Use cube for light debug mesh instead of entirety of Sponza...

This commit is contained in:
Lauri Räsänen 2023-01-29 15:12:41 +02:00
parent 2ddc863ca5
commit 450fc7a518
4 changed files with 16 additions and 5 deletions

View file

@ -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

BIN
res/models/Cube.glb Normal file

Binary file not shown.

View file

@ -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<f32>(model.position * scale + light.position, 1.0);
out.color = light.color;

View file

@ -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,