still trying to get this thing to render. it, for a split second rendered correctly. But now no dice..

master
mitchellhansen 4 years ago
parent 8d7a62da7f
commit 3d87d11485

@ -7,7 +7,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use bytemuck::__core::ops::Range; use bytemuck::__core::ops::Range;
use cgmath::{Matrix4, Point3}; use cgmath::{Matrix4, Point3, Decomposed, Quaternion, Rotation3, Deg, InnerSpace, SquareMatrix};
use futures::task::LocalSpawn; use futures::task::LocalSpawn;
use legion::*; use legion::*;
use wgpu::{BindGroup, Buffer, TextureView}; use wgpu::{BindGroup, Buffer, TextureView};
@ -138,6 +138,9 @@ pub struct Mesh {
fn main() { fn main() {
// #[cfg(not(target_arch = "wasm32"))] // #[cfg(not(target_arch = "wasm32"))]
// { // {
// let chrome_tracing_dir = std::env::var("WGPU_CHROME_TRACE"); // let chrome_tracing_dir = std::env::var("WGPU_CHROME_TRACE");
@ -215,9 +218,18 @@ fn main() {
let mut renderer = render::Renderer::init(window); let mut renderer = render::Renderer::init(window);
let untitled_mesh = let untitled_mesh =
renderer.load_mesh_to_buffer("./resources/untitled.obj"); renderer.load_mesh_to_buffer("./resources/monkey.obj");
// This could be used for relationships between entities...??? // This could be used for relationships between entities...???
let light_entity: Entity = world.push((
cgmath::Point3 {
x: 7.0 as f32,
y: -5.0 as f32,
z: 10.0 as f32,
},
renderer.create_light(),
));
let light_entity: Entity = world.push(( let light_entity: Entity = world.push((
cgmath::Point3 { cgmath::Point3 {
x: -5.0 as f32, x: -5.0 as f32,
@ -227,12 +239,19 @@ fn main() {
renderer.create_light(), renderer.create_light(),
)); ));
let offset = cgmath::vec3(2.0, 2.0, 2.0);
let transform = Decomposed {
disp: offset.clone(),
rot: Quaternion::from_axis_angle(offset.normalize(), Deg(50.0)),
scale: 1.0,
};
let mesh_entity: Entity = world.push(( let mesh_entity: Entity = world.push((
Position { Position {
x: -5.0, x: 17.0,
y: 7.0, y: 15.0,
z: 10.0, z: 10.0,
mx: OPENGL_TO_WGPU_MATRIX, mx: cgmath::Matrix4::from(transform),
}, },
untitled_mesh, untitled_mesh,
Color { Color {
@ -243,47 +262,25 @@ fn main() {
}, },
)); ));
let entities: &[Entity] = world.extend(vec![ let plane_mesh =
( renderer.create_plane(7.0);
Position {
x: 0.0, // let plane_entity: Entity = world.push((
y: 0.0, // Position {
z: 0.0, // x: 0.0,
mx: OPENGL_TO_WGPU_MATRIX, // y: 0.0,
}, // z: 0.0,
Velocity { // mx: cgmath::Matrix4::identity(),
dx: 0.0, // },
dy: 0.0, // plane_mesh,
rs: 0.0, // Color {
}, // r: 1.0,
), // g: 0.5,
( // b: 0.5,
Position { // a: 1.0,
x: 1.0, // },
y: 1.0, // ));
z: 0.0,
mx: OPENGL_TO_WGPU_MATRIX,
},
Velocity {
dx: 0.0,
dy: 0.0,
rs: 0.0,
},
),
(
Position {
x: 2.0,
y: 2.0,
z: 0.0,
mx: OPENGL_TO_WGPU_MATRIX,
},
Velocity {
dx: 0.0,
dy: 0.0,
rs: 0.0,
},
),
]);
// Init, this wants the references to the buffers... // Init, this wants the references to the buffers...
let mut runtime = runtime::Runtime::init(); let mut runtime = runtime::Runtime::init();

@ -8,16 +8,18 @@ use futures::executor::LocalPool;
use legion::world::SubWorld; use legion::world::SubWorld;
use legion::*; use legion::*;
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use wgpu::{BindGroup, BindGroupLayout, Buffer, Device, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, TextureView}; use wgpu::{
BindGroup, BindGroupLayout, Buffer, Device, Instance, Queue, Surface, SwapChain,
SwapChainDescriptor, SwapChainFrame, TextureView,
};
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use winit::platform::unix::x11::ffi::Time; use winit::platform::unix::x11::ffi::Time;
use winit::window::Window; use winit::window::Window;
use crate::geometry::{create_plane, import_mesh, Vertex}; use crate::geometry::{create_plane, import_mesh, vertex, Vertex};
use crate::light::LightRaw; use crate::light::LightRaw;
use crate::{Color, DirectionalLight, Mesh, Position, RangeCopy, Velocity, OPENGL_TO_WGPU_MATRIX}; use crate::{Color, DirectionalLight, Mesh, Position, RangeCopy, Velocity, OPENGL_TO_WGPU_MATRIX};
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct ForwardUniforms { pub struct ForwardUniforms {
@ -69,6 +71,7 @@ pub struct Renderer {
entity_bind_group_layout: BindGroupLayout, entity_bind_group_layout: BindGroupLayout,
shadow_target_views: Vec<Arc<TextureView>>, shadow_target_views: Vec<Arc<TextureView>>,
views_given: u32,
light_uniform_buf: wgpu::Buffer, light_uniform_buf: wgpu::Buffer,
} }
@ -102,14 +105,21 @@ impl Renderer {
#[write_component(Color)] #[write_component(Color)]
#[write_component(DirectionalLight)] #[write_component(DirectionalLight)]
pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) { pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
let mut encoder = renderer
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.push_debug_group("start render function");
let frame = renderer.get_current_frame(); let frame = renderer.get_current_frame();
let mut query = <(&mut Position, &mut Mesh, &mut Color)>::query(); let mut query = <(&mut Position, &mut Mesh, &mut Color)>::query();
let mut mesh_stack = Vec::new();
// Update the entity uniforms // Update the entity uniforms
for (pos, mesh, color) in query.iter_mut(world) { for (pos, mesh, color) in query.iter_mut(world) {
let rotation = cgmath::Matrix4::from_angle_x(cgmath::Deg(1.0)); // let rotation = cgmath::Matrix4::from_angle_x(cgmath::Deg(1.0));
pos.mx = pos.mx * rotation; // pos.mx = pos.mx * rotation;
let data = EntityUniforms { let data = EntityUniforms {
model: pos.mx.into(), model: pos.mx.into(),
@ -123,10 +133,12 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
renderer renderer
.queue .queue
.write_buffer(&mesh.uniform_buffer, 0, bytemuck::bytes_of(&data)); .write_buffer(&mesh.uniform_buffer, 0, bytemuck::bytes_of(&data));
mesh_stack.push(mesh.clone());
} }
if renderer.lights_are_dirty { if renderer.lights_are_dirty {
renderer.lights_are_dirty = false; //renderer.lights_are_dirty = false;
let mut query = <(&mut DirectionalLight, &mut Position)>::query(); let mut query = <(&mut DirectionalLight, &mut Position)>::query();
for (i, (light, pos)) in query.iter_mut(world).enumerate() { for (i, (light, pos)) in query.iter_mut(world).enumerate() {
renderer.queue.write_buffer( renderer.queue.write_buffer(
@ -137,22 +149,13 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
} }
} }
let mut encoder = renderer
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.push_debug_group("shadow passes"); encoder.push_debug_group("shadow passes");
let mut query = <(&mut DirectionalLight, &mut Point3<f32>)>::query(); let mut query = <(&mut DirectionalLight, &mut Point3<f32>)>::query();
let mut light_stack = Vec::new();
for (i, (light, pos)) in query.iter_mut(world).enumerate() { for (i, (light, pos)) in query.iter_mut(world).enumerate() {
light_stack.push(light.clone()); encoder.insert_debug_marker(&format!("shadow pass {} (light at position {:?})", i, pos));
encoder.push_debug_group(&format!(
"shadow pass {} (light at position {:?})",
i, pos
));
// The light uniform buffer already has the projection, // The light uniform buffer already has the projection,
// let's just copy it over to the shadow uniform buffer. // let's just copy it over to the shadow uniform buffer.
@ -164,12 +167,8 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
64, 64,
); );
encoder.pop_debug_group();
}
for light in light_stack {
encoder.insert_debug_marker("render entities"); encoder.insert_debug_marker("render entities");
{
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[], color_attachments: &[],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor { depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor {
@ -184,21 +183,17 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
pass.set_pipeline(&renderer.shadow_pass.pipeline); pass.set_pipeline(&renderer.shadow_pass.pipeline);
pass.set_bind_group(0, &renderer.shadow_pass.bind_group, &[]); pass.set_bind_group(0, &renderer.shadow_pass.bind_group, &[]);
let mut query = <(&mut Position, &mut Mesh, &mut Color)>::query(); for mesh in &mesh_stack {
for (pos, mesh, color) in query.iter_mut(world) {
pass.set_bind_group(1, &mesh.bind_group, &[]); pass.set_bind_group(1, &mesh.bind_group, &[]);
pass.set_index_buffer(mesh.index_buffer.slice(..)); pass.set_index_buffer(mesh.index_buffer.slice(..));
pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..)); pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..));
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1); pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
}
}
}
}
}
encoder.pop_debug_group(); encoder.pop_debug_group();
// forward pass // forward pass
encoder.push_debug_group("forward rendering pass"); encoder.push_debug_group("forward rendering pass");
{ {
@ -235,21 +230,10 @@ pub fn render_test(world: &mut SubWorld, #[resource] renderer: &mut Renderer) {
pass.set_index_buffer(mesh.index_buffer.slice(..)); pass.set_index_buffer(mesh.index_buffer.slice(..));
pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..)); pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..));
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1); pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
let data = EntityUniforms {
model: pos.mx.into(),
color: [
color.r as f32,
color.g as f32,
color.b as f32,
color.a as f32,
],
};
renderer
.queue
.write_buffer(&mesh.uniform_buffer, 0, bytemuck::bytes_of(&data));
} }
} }
encoder.pop_debug_group(); encoder.pop_debug_group();
encoder.pop_debug_group();
renderer.queue.submit(iter::once(encoder.finish())); renderer.queue.submit(iter::once(encoder.finish()));
} }
@ -275,9 +259,6 @@ impl Renderer {
indices: Vec<u32>, indices: Vec<u32>,
vertices: Vec<Vertex>, vertices: Vec<Vertex>,
) -> (Arc<Buffer>, Arc<Buffer>) { ) -> (Arc<Buffer>, Arc<Buffer>) {
// Creates the vertex and index buffers for the cube
let vertex_size = mem::size_of::<Vertex>();
//import_mesh("/home/mrh/source/3d-min-viable-eng/resources/my_tree.obj");
let vertex_buf = Arc::new( let vertex_buf = Arc::new(
device.create_buffer_init(&wgpu::util::BufferInitDescriptor { device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@ -298,9 +279,9 @@ impl Renderer {
(vertex_buf, index_buf) (vertex_buf, index_buf)
} }
pub fn create_light(&self) -> DirectionalLight { pub fn create_light(&mut self) -> DirectionalLight {
let target = self.shadow_target_views.get(self.views_given as usize).take().unwrap();
let target = self.shadow_target_views.get(0).take().unwrap(); self.views_given = self.views_given + 1;
DirectionalLight { DirectionalLight {
color: wgpu::Color { color: wgpu::Color {
r: 1.0, r: 1.0,
@ -313,7 +294,46 @@ impl Renderer {
start: 1.0, start: 1.0,
end: 20.0, end: 20.0,
}, },
target_view: target.clone() target_view: target.clone(),
}
}
pub fn create_plane(&self, size: f32) -> Mesh {
let vertices = [
vertex([size, -size, 0.0], [0.0, 0.0, 1.0]),
vertex([size, size, 0.0], [0.0, 0.0, 1.0]),
vertex([-size, -size, 0.0], [0.0, 0.0, 1.0]),
vertex([-size, size, 0.0], [0.0, 0.0, 1.0]),
];
let indices: &[u32] = &[0, 1, 2, 2, 1, 3];
let index_count = indices.len();
let (vertex_buf, index_buf) =
Renderer::create_buffer(&self.device, indices.to_vec(), vertices.to_vec());
let uniform_buf = Arc::new(self.device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Plane Uniform Buf"),
size: mem::size_of::<EntityUniforms>() as wgpu::BufferAddress,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false,
}));
let bind_group = Arc::new(self.device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &self.entity_bind_group_layout,
entries: &[wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::Buffer(uniform_buf.slice(..)),
}],
label: Some("Plane Bind Group"),
}));
Mesh {
index_buffer: index_buf,
index_count: index_count,
vertex_buffer: vertex_buf,
uniform_buffer: uniform_buf,
bind_group: bind_group,
} }
} }
@ -323,7 +343,7 @@ impl Renderer {
let (vertex_buf, index_buf) = Renderer::create_buffer(&self.device, indices, vertices); let (vertex_buf, index_buf) = Renderer::create_buffer(&self.device, indices, vertices);
let uniform_buf = Arc::new(self.device.create_buffer(&wgpu::BufferDescriptor { let uniform_buf = Arc::new(self.device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("Mesh Uniform Buf"),
size: mem::size_of::<EntityUniforms>() as wgpu::BufferAddress, size: mem::size_of::<EntityUniforms>() as wgpu::BufferAddress,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
@ -335,7 +355,7 @@ impl Renderer {
binding: 0, binding: 0,
resource: wgpu::BindingResource::Buffer(uniform_buf.slice(..)), resource: wgpu::BindingResource::Buffer(uniform_buf.slice(..)),
}], }],
label: None, label: Some("Mesh Bind Group"),
})); }));
Mesh { Mesh {
@ -440,12 +460,6 @@ impl Renderer {
let mut swap_chain = device.create_swap_chain(&surface, &sc_desc); let mut swap_chain = device.create_swap_chain(&surface, &sc_desc);
let entity_uniform_size = mem::size_of::<EntityUniforms>() as wgpu::BufferAddress; let entity_uniform_size = mem::size_of::<EntityUniforms>() as wgpu::BufferAddress;
let plane_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: entity_uniform_size,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false,
});
// This seems way way way way easier than what I was doing in tracer // This seems way way way way easier than what I was doing in tracer
// Though the attr thing is still a macro. Which would cause issues if // Though the attr thing is still a macro. Which would cause issues if
@ -461,7 +475,7 @@ impl Renderer {
// This is also in the runtime which really shouldn't have this // This is also in the runtime which really shouldn't have this
let entity_bind_group_layout = let entity_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("Entity Bind Group Layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, binding: 0,
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
@ -486,7 +500,7 @@ impl Renderer {
// I believe this is just making a_Pos or u_ViewProj available in the vert shader // I believe this is just making a_Pos or u_ViewProj available in the vert shader
let bind_group_layout = let bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: Some("Shadow pass bind group layout"),
entries: &[wgpu::BindGroupLayoutEntry { entries: &[wgpu::BindGroupLayoutEntry {
binding: 0, // global binding: 0, // global
visibility: wgpu::ShaderStage::VERTEX, visibility: wgpu::ShaderStage::VERTEX,
@ -500,14 +514,14 @@ impl Renderer {
// Pipeline is similar between passes, but with a different label // Pipeline is similar between passes, but with a different label
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("shadow"), label: Some("shadow pass pipeline layout"),
bind_group_layouts: &[&bind_group_layout, &entity_bind_group_layout], bind_group_layouts: &[&bind_group_layout, &entity_bind_group_layout],
push_constant_ranges: &[], push_constant_ranges: &[],
}); });
// Holds the shadow uniforms, which is just a 4 vec of quaternians // Holds the shadow uniforms, which is just a 4 vec of quaternians
let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("shadow pass shadow uniform buffer"),
size: uniform_size, size: uniform_size,
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false, mapped_at_creation: false,
@ -520,7 +534,7 @@ impl Renderer {
binding: 0, binding: 0,
resource: wgpu::BindingResource::Buffer(uniform_buf.slice(..)), resource: wgpu::BindingResource::Buffer(uniform_buf.slice(..)),
}], }],
label: None, label: Some("Shadow uniform bind group"),
}); });
// Create the render pipeline // Create the render pipeline
@ -577,7 +591,7 @@ impl Renderer {
(Self::MAX_LIGHTS * mem::size_of::<LightRaw>()) as wgpu::BufferAddress; (Self::MAX_LIGHTS * mem::size_of::<LightRaw>()) as wgpu::BufferAddress;
let light_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { let light_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: Some("Light uniform buffer"),
size: light_uniform_size, size: light_uniform_size,
usage: wgpu::BufferUsage::UNIFORM usage: wgpu::BufferUsage::UNIFORM
| wgpu::BufferUsage::COPY_SRC | wgpu::BufferUsage::COPY_SRC
@ -592,7 +606,7 @@ impl Renderer {
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
format: Self::SHADOW_FORMAT, format: Self::SHADOW_FORMAT,
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT | wgpu::TextureUsage::SAMPLED, usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT | wgpu::TextureUsage::SAMPLED,
label: None, label: Some("Shadow texture"),
}); });
let mut shadow_target_views = (0..2) let mut shadow_target_views = (0..2)
@ -654,7 +668,7 @@ impl Renderer {
count: None, count: None,
}, },
], ],
label: None, label: Some("Forward pass bind group layout"),
}); });
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -669,21 +683,15 @@ impl Renderer {
let forward_uniforms = ForwardUniforms { let forward_uniforms = ForwardUniforms {
proj: *mx_total.as_ref(), proj: *mx_total.as_ref(),
//num_lights: [lights.len() as u32, 0, 0, 0], //num_lights: [lights.len() as u32, 0, 0, 0],
num_lights: [1 as u32, 0, 0, 0], num_lights: [2 as u32, 0, 0, 0],
}; };
let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let uniform_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Uniform Buffer"), label: Some("Forward pass binding 0 uniform buffer"),
contents: bytemuck::bytes_of(&forward_uniforms), contents: bytemuck::bytes_of(&forward_uniforms),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
}); });
// shadow_target_views[0].take().unwrap(),
// pub(crate) target_view: wgpu::TextureView,
let shadow_view = shadow_texture.create_view(&wgpu::TextureViewDescriptor::default());
let shadow_sampler = device.create_sampler(&wgpu::SamplerDescriptor { let shadow_sampler = device.create_sampler(&wgpu::SamplerDescriptor {
label: Some("shadow"), label: Some("shadow"),
address_mode_u: wgpu::AddressMode::ClampToEdge, address_mode_u: wgpu::AddressMode::ClampToEdge,
@ -696,6 +704,8 @@ impl Renderer {
..Default::default() ..Default::default()
}); });
let shadow_view = shadow_texture.create_view(&wgpu::TextureViewDescriptor::default());
// Create bind group // Create bind group
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout, layout: &bind_group_layout,
@ -717,7 +727,7 @@ impl Renderer {
resource: wgpu::BindingResource::Sampler(&shadow_sampler), resource: wgpu::BindingResource::Sampler(&shadow_sampler),
}, },
], ],
label: None, label: Some("Forward pass bind group"),
}); });
// Create the render pipeline // Create the render pipeline
@ -777,7 +787,7 @@ impl Renderer {
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
format: Self::DEPTH_FORMAT, format: Self::DEPTH_FORMAT,
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
label: None, label: Some("Depth Texture"),
}); });
Renderer { Renderer {
@ -786,7 +796,7 @@ impl Renderer {
queue: queue, queue: queue,
size, size,
device: device, device: device,
lights_are_dirty: false, lights_are_dirty: true,
shadow_pass, shadow_pass,
forward_pass, forward_pass,
forward_depth: depth_texture.create_view(&wgpu::TextureViewDescriptor::default()), forward_depth: depth_texture.create_view(&wgpu::TextureViewDescriptor::default()),
@ -796,6 +806,7 @@ impl Renderer {
swapchain_description: sc_desc, swapchain_description: sc_desc,
surface, surface,
instance: Arc::new(instance), instance: Arc::new(instance),
views_given: 0,
} }
} }
@ -828,7 +839,7 @@ impl Renderer {
dimension: wgpu::TextureDimension::D2, dimension: wgpu::TextureDimension::D2,
format: Self::DEPTH_FORMAT, format: Self::DEPTH_FORMAT,
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
label: None, label: Some("Depth Texture"),
}); });
self.forward_depth = depth_texture.create_view(&wgpu::TextureViewDescriptor::default()); self.forward_depth = depth_texture.create_view(&wgpu::TextureViewDescriptor::default());
} }

Loading…
Cancel
Save