Apply shadow map shadows to train tracks.

This commit is contained in:
Avi Weinstock 2022-11-06 18:09:07 -05:00
parent f5c1293e9f
commit db251273ed
4 changed files with 11 additions and 18 deletions

View File

@ -1,5 +1,7 @@
#version 420 core
#define HAS_SHADOW_MAPS
#include <constants.glsl>
#include <globals.glsl>
#include <srgb.glsl>
@ -14,7 +16,7 @@ in vec3 f_pos;
layout (location = 2)
in vec3 f_norm;
layout (std140, set = 1, binding = 0)
layout (std140, set = 3, binding = 0)
uniform u_locals {
vec4 w_pos;
vec4 w_color;

View File

@ -9,7 +9,7 @@ in vec4 v_color;
layout (location = 2)
in vec3 v_norm;
layout (std140, set = 1, binding = 0)
layout (std140, set = 3, binding = 0)
uniform u_locals {
vec4 w_pos;
vec4 w_color;

View File

@ -80,7 +80,12 @@ impl DebugPipeline {
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Debug pipeline layout"),
push_constant_ranges: &[],
bind_group_layouts: &[&global_layouts.globals, &layout.locals],
bind_group_layouts: &[
&global_layouts.globals,
&global_layouts.shadow_textures,
&global_layouts.col_light,
&layout.locals
],
});
let samples = aa_mode.samples();

View File

@ -6,7 +6,6 @@ use super::{
pipelines::{
blit, bloom, clouds, debug, figure, fluid, lod_object, lod_terrain, particle, shadow,
skybox, sprite, terrain, trail, ui, ColLights, GlobalsBindGroup,
ShadowTexturesBindGroup,
},
},
rain_occlusion_map::{RainOcclusionMap, RainOcclusionMapRenderer},
@ -250,7 +249,6 @@ impl<'frame> Drawer<'frame> {
borrow: &self.borrow,
pipelines,
globals: self.globals,
shadows: &shadow.bind,
})
}
@ -757,7 +755,6 @@ pub struct FirstPassDrawer<'pass> {
borrow: &'pass RendererBorrow<'pass>,
pipelines: &'pass super::Pipelines,
globals: &'pass GlobalsBindGroup,
shadows: &'pass ShadowTexturesBindGroup,
}
impl<'pass> FirstPassDrawer<'pass> {
@ -778,7 +775,6 @@ impl<'pass> FirstPassDrawer<'pass> {
DebugDrawer {
render_pass,
shadows: self.shadows,
}
}
@ -862,7 +858,6 @@ impl<'pass> FirstPassDrawer<'pass> {
#[must_use]
pub struct DebugDrawer<'pass_ref, 'pass: 'pass_ref> {
render_pass: Scope<'pass_ref, wgpu::RenderPass<'pass>>,
shadows: &'pass ShadowTexturesBindGroup,
}
impl<'pass_ref, 'pass: 'pass_ref> DebugDrawer<'pass_ref, 'pass> {
@ -871,21 +866,12 @@ impl<'pass_ref, 'pass: 'pass_ref> DebugDrawer<'pass_ref, 'pass> {
model: &'data Model<debug::Vertex>,
locals: &'data debug::BoundLocals,
) {
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
self.render_pass.set_bind_group(3, &locals.bind_group, &[]);
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
self.render_pass.draw(0..model.len() as u32, 0..1);
}
}
impl<'pass_ref, 'pass: 'pass_ref> Drop for DebugDrawer<'pass_ref, 'pass> {
fn drop(&mut self) {
// Maintain that the shadow bind group is set in
// slot 1 by default during the main pass
self.render_pass
.set_bind_group(1, &self.shadows.bind_group, &[]);
}
}
#[must_use]
pub struct FigureDrawer<'pass_ref, 'pass: 'pass_ref> {
render_pass: Scope<'pass_ref, wgpu::RenderPass<'pass>>,