mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made directed shadows take advantage of culling
This commit is contained in:
parent
de1c961141
commit
4699569eae
@ -794,11 +794,24 @@ impl<'pass_ref, 'pass: 'pass_ref> TerrainShadowDrawer<'pass_ref, 'pass> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
model: &'data Model<terrain::Vertex>,
|
model: &'data Model<terrain::Vertex>,
|
||||||
locals: &'data terrain::BoundLocals,
|
locals: &'data terrain::BoundLocals,
|
||||||
|
alt_indices: &'data crate::scene::terrain::AltIndices,
|
||||||
|
is_underground: bool,
|
||||||
) {
|
) {
|
||||||
|
// Don't render anything if there's nothing to render!
|
||||||
|
if is_underground || alt_indices.deep_end == model.len() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let submodel = if is_underground {
|
||||||
|
model.submodel(0..alt_indices.underground_end as u32)
|
||||||
|
} else {
|
||||||
|
model.submodel(alt_indices.deep_end as u32..model.len() as u32)
|
||||||
|
};
|
||||||
|
|
||||||
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||||
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
|
self.render_pass.set_vertex_buffer(0, submodel.buf());
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.draw_indexed(0..model.len() as u32 / 4 * 6, 0, 0..1);
|
.draw_indexed(0..submodel.len() / 4 * 6, 0, 0..1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,8 +1262,11 @@ impl Scene {
|
|||||||
prof_span!("directed shadows");
|
prof_span!("directed shadows");
|
||||||
if let Some(mut shadow_pass) = drawer.shadow_pass() {
|
if let Some(mut shadow_pass) = drawer.shadow_pass() {
|
||||||
// Render terrain directed shadows.
|
// Render terrain directed shadows.
|
||||||
self.terrain
|
self.terrain.render_shadows(
|
||||||
.render_shadows(&mut shadow_pass.draw_terrain_shadows(), focus_pos);
|
&mut shadow_pass.draw_terrain_shadows(),
|
||||||
|
focus_pos,
|
||||||
|
is_underground,
|
||||||
|
);
|
||||||
|
|
||||||
// Render figure directed shadows.
|
// Render figure directed shadows.
|
||||||
self.figure_mgr.render_shadows(
|
self.figure_mgr.render_shadows(
|
||||||
|
@ -1536,6 +1536,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
&'a self,
|
&'a self,
|
||||||
drawer: &mut TerrainShadowDrawer<'_, 'a>,
|
drawer: &mut TerrainShadowDrawer<'_, 'a>,
|
||||||
focus_pos: Vec3<f32>,
|
focus_pos: Vec3<f32>,
|
||||||
|
is_underground: bool,
|
||||||
) {
|
) {
|
||||||
span!(_guard, "render_shadows", "Terrain::render_shadows");
|
span!(_guard, "render_shadows", "Terrain::render_shadows");
|
||||||
let focus_chunk = Vec2::from(focus_pos).map2(TerrainChunk::RECT_SIZE, |e: f32, sz| {
|
let focus_chunk = Vec2::from(focus_pos).map2(TerrainChunk::RECT_SIZE, |e: f32, sz| {
|
||||||
@ -1558,12 +1559,15 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
.filter(|chunk| chunk.can_shadow_sun())
|
.filter(|chunk| chunk.can_shadow_sun())
|
||||||
.chain(self.shadow_chunks.iter().map(|(_, chunk)| chunk))
|
.chain(self.shadow_chunks.iter().map(|(_, chunk)| chunk))
|
||||||
.filter_map(|chunk| {
|
.filter_map(|chunk| {
|
||||||
chunk
|
Some((
|
||||||
.opaque_model
|
chunk.opaque_model.as_ref()?,
|
||||||
.as_ref()
|
&chunk.locals,
|
||||||
.map(|model| (model, &chunk.locals))
|
&chunk.alt_indices,
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.for_each(|(model, locals)| drawer.draw(model, locals));
|
.for_each(|(model, locals, alt_indices)| {
|
||||||
|
drawer.draw(model, locals, alt_indices, is_underground)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_rain_occlusion<'a>(
|
pub fn render_rain_occlusion<'a>(
|
||||||
@ -1585,13 +1589,14 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
chunk_iter
|
chunk_iter
|
||||||
// Find a way to keep this?
|
// Find a way to keep this?
|
||||||
// .filter(|chunk| chunk.can_shadow_sun())
|
// .filter(|chunk| chunk.can_shadow_sun())
|
||||||
.filter_map(|chunk| {
|
.filter_map(|chunk| Some((
|
||||||
chunk
|
chunk
|
||||||
.opaque_model
|
.opaque_model
|
||||||
.as_ref()
|
.as_ref()?,
|
||||||
.map(|model| (model, &chunk.locals))
|
&chunk.locals,
|
||||||
})
|
&chunk.alt_indices,
|
||||||
.for_each(|(model, locals)| drawer.draw(model, locals));
|
)))
|
||||||
|
.for_each(|(model, locals, alt_indices)| drawer.draw(model, locals, alt_indices, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chunks_for_point_shadows(
|
pub fn chunks_for_point_shadows(
|
||||||
|
Loading…
Reference in New Issue
Block a user