mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reenable terrain rendering
Refractor col lights
This commit is contained in:
parent
cd60e70664
commit
d6062dc854
@ -45,9 +45,9 @@ in vec4 sun_pos;
|
|||||||
const vec4 sun_pos = vec4(0.0);
|
const vec4 sun_pos = vec4(0.0);
|
||||||
#endif */
|
#endif */
|
||||||
|
|
||||||
layout(set = 1, binding = 1)
|
layout(set = 2, binding = 0)
|
||||||
uniform texture2D t_col_light;
|
uniform texture2D t_col_light;
|
||||||
layout(set = 1, binding = 2)
|
layout(set = 2, binding = 1)
|
||||||
uniform sampler s_col_light;
|
uniform sampler s_col_light;
|
||||||
|
|
||||||
layout (std140, set = 1, binding = 0)
|
layout (std140, set = 1, binding = 0)
|
||||||
|
@ -237,8 +237,12 @@ impl PlayState for CharSelectionState {
|
|||||||
let (humanoid_body, loadout) =
|
let (humanoid_body, loadout) =
|
||||||
Self::get_humanoid_body_inventory(&self.char_selection_ui, &client);
|
Self::get_humanoid_body_inventory(&self.char_selection_ui, &client);
|
||||||
|
|
||||||
self.scene
|
self.scene.render(
|
||||||
.render(&mut drawer.first_pass(), client.get_tick(), humanoid_body, loadout);
|
&mut drawer.first_pass(),
|
||||||
|
client.get_tick(),
|
||||||
|
humanoid_body,
|
||||||
|
loadout,
|
||||||
|
);
|
||||||
|
|
||||||
// Clouds
|
// Clouds
|
||||||
drawer.second_pass().draw_clouds();
|
drawer.second_pass().draw_clouds();
|
||||||
|
@ -13,7 +13,10 @@ pub struct SubModel<'a, V: Vertex> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, V: Vertex> SubModel<'a, V> {
|
impl<'a, V: Vertex> SubModel<'a, V> {
|
||||||
pub(super) fn buf(&self) -> wgpu::BufferSlice<'a> { self.buf.slice(map_range(&self.vertex_range)) }
|
pub(super) fn buf(&self) -> wgpu::BufferSlice<'a> {
|
||||||
|
self.buf.slice(map_range(&self.vertex_range))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn len(&self) -> u32 { self.vertex_range.end - self.vertex_range.start }
|
pub fn len(&self) -> u32 { self.vertex_range.end - self.vertex_range.start }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{AaMode, Bound, Consts, GlobalsLayouts, Mesh, Model, Texture},
|
super::{AaMode, Bound, Consts, GlobalsLayouts, Mesh, Model},
|
||||||
terrain::Vertex,
|
terrain::Vertex,
|
||||||
};
|
};
|
||||||
use crate::mesh::greedy::GreedyMesh;
|
use crate::mesh::greedy::GreedyMesh;
|
||||||
@ -26,7 +26,6 @@ pub struct BoneData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type BoundLocals = Bound<(Consts<Locals>, Consts<BoneData>)>;
|
pub type BoundLocals = Bound<(Consts<Locals>, Consts<BoneData>)>;
|
||||||
pub type ColLights = Bound<Texture>;
|
|
||||||
|
|
||||||
impl Locals {
|
impl Locals {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
@ -102,7 +101,6 @@ pub type BoneMeshes = (Mesh<Vertex>, anim::vek::Aabb<f32>);
|
|||||||
|
|
||||||
pub struct FigureLayout {
|
pub struct FigureLayout {
|
||||||
pub locals: wgpu::BindGroupLayout,
|
pub locals: wgpu::BindGroupLayout,
|
||||||
pub col_light: wgpu::BindGroupLayout,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FigureLayout {
|
impl FigureLayout {
|
||||||
@ -135,31 +133,6 @@ impl FigureLayout {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
col_light: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
|
||||||
label: None,
|
|
||||||
entries: &[
|
|
||||||
// col lights
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 0,
|
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Texture {
|
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
|
||||||
view_dimension: wgpu::TextureViewDimension::D2,
|
|
||||||
multisampled: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 1,
|
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Sampler {
|
|
||||||
filtering: true,
|
|
||||||
comparison: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,28 +162,6 @@ impl FigureLayout {
|
|||||||
with: (locals, bone_data),
|
with: (locals, bone_data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_texture(&self, device: &wgpu::Device, col_light: Texture) -> ColLights {
|
|
||||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
|
||||||
label: None,
|
|
||||||
layout: &self.col_light,
|
|
||||||
entries: &[
|
|
||||||
wgpu::BindGroupEntry {
|
|
||||||
binding: 0,
|
|
||||||
resource: wgpu::BindingResource::TextureView(&col_light.view),
|
|
||||||
},
|
|
||||||
wgpu::BindGroupEntry {
|
|
||||||
binding: 1,
|
|
||||||
resource: wgpu::BindingResource::Sampler(&col_light.sampler),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
ColLights {
|
|
||||||
bind_group,
|
|
||||||
with: col_light,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FigurePipeline {
|
pub struct FigurePipeline {
|
||||||
@ -232,7 +183,11 @@ impl FigurePipeline {
|
|||||||
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("Figure pipeline layout"),
|
label: Some("Figure pipeline layout"),
|
||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
bind_group_layouts: &[&global_layout.globals, &layout.locals, &layout.col_light],
|
bind_group_layouts: &[
|
||||||
|
&global_layout.globals,
|
||||||
|
&layout.locals,
|
||||||
|
&global_layout.col_light,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = match aa_mode {
|
let samples = match aa_mode {
|
||||||
|
@ -66,7 +66,10 @@ impl FluidLayout {
|
|||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 1,
|
binding: 1,
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Sampler { filtering: true, comparison: false },
|
ty: wgpu::BindingType::Sampler {
|
||||||
|
filtering: true,
|
||||||
|
comparison: false,
|
||||||
|
},
|
||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -15,6 +15,7 @@ use crate::scene::camera::CameraMode;
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use common::terrain::BlockKind;
|
use common::terrain::BlockKind;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
use wgpu::BindGroup;
|
||||||
|
|
||||||
pub const MAX_POINT_LIGHT_COUNT: usize = 31;
|
pub const MAX_POINT_LIGHT_COUNT: usize = 31;
|
||||||
pub const MAX_FIGURE_SHADOW_COUNT: usize = 24;
|
pub const MAX_FIGURE_SHADOW_COUNT: usize = 24;
|
||||||
@ -231,6 +232,13 @@ pub struct GlobalsBindGroup {
|
|||||||
|
|
||||||
pub struct GlobalsLayouts {
|
pub struct GlobalsLayouts {
|
||||||
pub globals: wgpu::BindGroupLayout,
|
pub globals: wgpu::BindGroupLayout,
|
||||||
|
pub col_light: wgpu::BindGroupLayout,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ColLights<Locals> {
|
||||||
|
pub bind_group: BindGroup,
|
||||||
|
pub texture: Texture,
|
||||||
|
phantom: std::marker::PhantomData<Locals>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalsLayouts {
|
impl GlobalsLayouts {
|
||||||
@ -406,7 +414,33 @@ impl GlobalsLayouts {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Self { globals }
|
let col_light = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
|
label: None,
|
||||||
|
entries: &[
|
||||||
|
// col lights
|
||||||
|
wgpu::BindGroupLayoutEntry {
|
||||||
|
binding: 0,
|
||||||
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Texture {
|
||||||
|
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||||
|
view_dimension: wgpu::TextureViewDimension::D2,
|
||||||
|
multisampled: false,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
},
|
||||||
|
wgpu::BindGroupLayoutEntry {
|
||||||
|
binding: 1,
|
||||||
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
|
ty: wgpu::BindingType::Sampler {
|
||||||
|
filtering: true,
|
||||||
|
comparison: false,
|
||||||
|
},
|
||||||
|
count: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Self { globals, col_light }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind(
|
pub fn bind(
|
||||||
@ -500,4 +534,31 @@ impl GlobalsLayouts {
|
|||||||
|
|
||||||
GlobalsBindGroup { bind_group }
|
GlobalsBindGroup { bind_group }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bind_col_light<Locals>(
|
||||||
|
&self,
|
||||||
|
device: &wgpu::Device,
|
||||||
|
col_light: Texture,
|
||||||
|
) -> ColLights<Locals> {
|
||||||
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
label: None,
|
||||||
|
layout: &self.col_light,
|
||||||
|
entries: &[
|
||||||
|
wgpu::BindGroupEntry {
|
||||||
|
binding: 0,
|
||||||
|
resource: wgpu::BindingResource::TextureView(&col_light.view),
|
||||||
|
},
|
||||||
|
wgpu::BindGroupEntry {
|
||||||
|
binding: 1,
|
||||||
|
resource: wgpu::BindingResource::Sampler(&col_light.sampler),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
ColLights {
|
||||||
|
texture: col_light,
|
||||||
|
bind_group,
|
||||||
|
phantom: std::marker::PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,30 +172,26 @@ impl TerrainLayout {
|
|||||||
},
|
},
|
||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
// col lights
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 1,
|
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Texture {
|
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
|
||||||
view_dimension: wgpu::TextureViewDimension::D2,
|
|
||||||
multisampled: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
wgpu::BindGroupLayoutEntry {
|
|
||||||
binding: 2,
|
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
|
||||||
ty: wgpu::BindingType::Sampler {
|
|
||||||
filtering: true,
|
|
||||||
comparison: false,
|
|
||||||
},
|
|
||||||
count: None,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bind_locals(&self, device: &wgpu::Device, locals: Consts<Locals>) -> BoundLocals {
|
||||||
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
label: None,
|
||||||
|
layout: &self.locals,
|
||||||
|
entries: &[wgpu::BindGroupEntry {
|
||||||
|
binding: 0,
|
||||||
|
resource: locals.buf().as_entire_binding(),
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
BoundLocals {
|
||||||
|
bind_group,
|
||||||
|
with: locals,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TerrainPipeline {
|
pub struct TerrainPipeline {
|
||||||
@ -217,7 +213,11 @@ impl TerrainPipeline {
|
|||||||
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("Terrain pipeline layout"),
|
label: Some("Terrain pipeline layout"),
|
||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
bind_group_layouts: &[&global_layout.globals, &layout.locals],
|
bind_group_layouts: &[
|
||||||
|
&global_layout.globals,
|
||||||
|
&layout.locals,
|
||||||
|
&global_layout.col_light,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = match aa_mode {
|
let samples = match aa_mode {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
consts::Consts,
|
consts::Consts,
|
||||||
pipelines::{figure, lod_terrain, ui, GlobalModel, GlobalsBindGroup},
|
pipelines::{figure, lod_terrain, terrain, ui, ColLights, GlobalModel, GlobalsBindGroup},
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
},
|
},
|
||||||
Renderer,
|
Renderer,
|
||||||
@ -49,7 +49,19 @@ impl Renderer {
|
|||||||
.bind_locals(&self.device, locals, bone_data)
|
.bind_locals(&self.device, locals, bone_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn figure_bind_texture(&self, col_light: Texture) -> figure::ColLights {
|
pub fn create_terrain_bound_locals(
|
||||||
self.layouts.figure.bind_texture(&self.device, col_light)
|
&mut self,
|
||||||
|
locals: &[terrain::Locals],
|
||||||
|
) -> terrain::BoundLocals {
|
||||||
|
let locals = self.create_consts(locals);
|
||||||
|
self.layouts.terrain.bind_locals(&self.device, locals)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn figure_bind_col_light(&self, col_light: Texture) -> ColLights<figure::Locals> {
|
||||||
|
self.layouts.global.bind_col_light(&self.device, col_light)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn terrain_bind_col_light(&self, col_light: Texture) -> ColLights<terrain::Locals> {
|
||||||
|
self.layouts.global.bind_col_light(&self.device, col_light)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ use super::{
|
|||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
consts::Consts,
|
consts::Consts,
|
||||||
instances::Instances,
|
instances::Instances,
|
||||||
model::{DynamicModel, SubModel,Model},
|
model::{DynamicModel, Model, SubModel},
|
||||||
pipelines::{
|
pipelines::{
|
||||||
clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, GlobalsBindGroup,
|
clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, ColLights,
|
||||||
Light, Shadow,
|
GlobalsBindGroup, Light, Shadow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Renderer,
|
Renderer,
|
||||||
@ -154,28 +154,30 @@ impl<'a> FirstPassDrawer<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
model: SubModel<'b, terrain::Vertex>,
|
model: SubModel<'b, terrain::Vertex>,
|
||||||
locals: &'b figure::BoundLocals,
|
locals: &'b figure::BoundLocals,
|
||||||
col_lights: &'b figure::ColLights
|
col_lights: &'b ColLights<figure::Locals>,
|
||||||
) {
|
) {
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.set_pipeline(&self.renderer.figure_pipeline.pipeline);
|
.set_pipeline(&self.renderer.figure_pipeline.pipeline);
|
||||||
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||||
self.render_pass.set_bind_group(2, &col_lights.bind_group, &[]);
|
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.set_vertex_buffer(0, model.buf());
|
.set_bind_group(2, &col_lights.bind_group, &[]);
|
||||||
|
self.render_pass.set_vertex_buffer(0, model.buf());
|
||||||
self.render_pass.draw(0..model.len(), 0..1);
|
self.render_pass.draw(0..model.len(), 0..1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_terrain<'b: 'a>(
|
pub fn draw_terrain<'b: 'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: &'b SubModel<terrain::Vertex>,
|
model: &'b Model<terrain::Vertex>,
|
||||||
locals: &'b terrain::BoundLocals,
|
locals: &'b terrain::BoundLocals,
|
||||||
|
col_lights: &'b ColLights<terrain::Locals>,
|
||||||
) {
|
) {
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.set_pipeline(&self.renderer.terrain_pipeline.pipeline);
|
.set_pipeline(&self.renderer.terrain_pipeline.pipeline);
|
||||||
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.set_vertex_buffer(0, model.buf());
|
.set_bind_group(2, &col_lights.bind_group, &[]);
|
||||||
self.render_pass.draw(0..model.len(), 0..1)
|
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
|
||||||
|
self.render_pass.draw(0..model.len() as u32, 0..1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*pub fn draw_fluid<'b: 'a>(
|
/*pub fn draw_fluid<'b: 'a>(
|
||||||
|
@ -7,8 +7,9 @@ pub use load::load_mesh; // TODO: Don't make this public.
|
|||||||
use crate::{
|
use crate::{
|
||||||
ecs::comp::Interpolated,
|
ecs::comp::Interpolated,
|
||||||
render::{
|
render::{
|
||||||
pipelines, ColLightInfo, FigureBoneData, FigureLocals, FigureModel, FirstPassDrawer,
|
pipelines::{self, ColLights},
|
||||||
GlobalModel, LodData, Mesh, RenderError, Renderer, SubModel, TerrainVertex,
|
ColLightInfo, FigureBoneData, FigureLocals, FigureModel, FirstPassDrawer, GlobalModel,
|
||||||
|
LodData, Mesh, RenderError, Renderer, SubModel, TerrainVertex,
|
||||||
},
|
},
|
||||||
scene::{
|
scene::{
|
||||||
camera::{Camera, CameraMode, Dependents},
|
camera::{Camera, CameraMode, Dependents},
|
||||||
@ -63,7 +64,7 @@ pub type CameraData<'a> = (&'a Camera, f32);
|
|||||||
pub type FigureModelRef<'a> = (
|
pub type FigureModelRef<'a> = (
|
||||||
&'a pipelines::figure::BoundLocals,
|
&'a pipelines::figure::BoundLocals,
|
||||||
SubModel<'a, TerrainVertex>,
|
SubModel<'a, TerrainVertex>,
|
||||||
&'a pipelines::figure::ColLights, /* <ColLightFmt> */
|
&'a ColLights<pipelines::figure::Locals>,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// An entry holding enough information to draw or destroy a figure in a
|
/// An entry holding enough information to draw or destroy a figure in a
|
||||||
@ -79,7 +80,7 @@ pub struct FigureModelEntry<const N: usize> {
|
|||||||
/// Texture used to store color/light information for this figure entry.
|
/// Texture used to store color/light information for this figure entry.
|
||||||
/* TODO: Consider using mipmaps instead of storing multiple texture atlases for different
|
/* TODO: Consider using mipmaps instead of storing multiple texture atlases for different
|
||||||
* LOD levels. */
|
* LOD levels. */
|
||||||
col_lights: pipelines::figure::ColLights,
|
col_lights: ColLights<pipelines::figure::Locals>,
|
||||||
/// Vertex ranges stored in this figure entry; there may be several for one
|
/// Vertex ranges stored in this figure entry; there may be several for one
|
||||||
/// figure, because of LOD models.
|
/// figure, because of LOD models.
|
||||||
lod_vertex_ranges: [Range<u32>; N],
|
lod_vertex_ranges: [Range<u32>; N],
|
||||||
@ -5207,7 +5208,7 @@ impl FigureColLights {
|
|||||||
pub fn texture<'a, const N: usize>(
|
pub fn texture<'a, const N: usize>(
|
||||||
&'a self,
|
&'a self,
|
||||||
model: &'a FigureModelEntry<N>,
|
model: &'a FigureModelEntry<N>,
|
||||||
) -> &'a pipelines::figure::ColLights {
|
) -> &'a ColLights<pipelines::figure::Locals> {
|
||||||
/* &self.col_lights */
|
/* &self.col_lights */
|
||||||
&model.col_lights
|
&model.col_lights
|
||||||
}
|
}
|
||||||
@ -5231,7 +5232,7 @@ impl FigureColLights {
|
|||||||
.allocate(guillotiere::Size::new(tex_size.x as i32, tex_size.y as i32))
|
.allocate(guillotiere::Size::new(tex_size.x as i32, tex_size.y as i32))
|
||||||
.expect("Not yet implemented: allocate new atlas on allocation failure.");
|
.expect("Not yet implemented: allocate new atlas on allocation failure.");
|
||||||
let col_lights = pipelines::shadow::create_col_lights(renderer, &(tex, tex_size));
|
let col_lights = pipelines::shadow::create_col_lights(renderer, &(tex, tex_size));
|
||||||
let col_lights = renderer.figure_bind_texture(col_lights);
|
let col_lights = renderer.figure_bind_col_light(col_lights);
|
||||||
let model_len = u32::try_from(opaque.vertices().len())
|
let model_len = u32::try_from(opaque.vertices().len())
|
||||||
.expect("The model size for this figure does not fit in a u32!");
|
.expect("The model size for this figure does not fit in a u32!");
|
||||||
let model = renderer.create_model(&opaque)?;
|
let model = renderer.create_model(&opaque)?;
|
||||||
|
@ -1017,20 +1017,12 @@ impl Scene {
|
|||||||
}*/
|
}*/
|
||||||
let lod = self.lod.get_data();
|
let lod = self.lod.get_data();
|
||||||
|
|
||||||
self.figure_mgr.render_player(
|
self.figure_mgr
|
||||||
drawer,
|
.render_player(drawer, state, player_entity, tick, global, lod, camera_data);
|
||||||
state,
|
|
||||||
player_entity,
|
|
||||||
tick,
|
|
||||||
global,
|
|
||||||
lod,
|
|
||||||
camera_data,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Render terrain and figures.
|
self.terrain.render(drawer, global, lod, focus_pos);
|
||||||
/*self.terrain.render(renderer, global, lod, focus_pos);
|
|
||||||
|
|
||||||
self.figure_mgr.render(
|
/* self.figure_mgr.render(
|
||||||
renderer,
|
renderer,
|
||||||
state,
|
state,
|
||||||
player_entity,
|
player_entity,
|
||||||
|
@ -8,8 +8,9 @@ use crate::{
|
|||||||
terrain::{generate_mesh, SUNLIGHT},
|
terrain::{generate_mesh, SUNLIGHT},
|
||||||
},
|
},
|
||||||
render::{
|
render::{
|
||||||
pipelines, ColLightInfo, Consts, FluidVertex, GlobalModel, Instances, LodData, Mesh, Model,
|
pipelines::{self, ColLights},
|
||||||
RenderError, Renderer, SpriteInstance, SpriteLocals, SpriteVertex, TerrainLocals,
|
ColLightInfo, Consts, FirstPassDrawer, FluidVertex, GlobalModel, Instances, LodData, Mesh,
|
||||||
|
Model, RenderError, Renderer, SpriteInstance, SpriteLocals, SpriteVertex, TerrainLocals,
|
||||||
TerrainVertex, Texture,
|
TerrainVertex, Texture,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -75,11 +76,11 @@ pub struct TerrainChunkData {
|
|||||||
/// shadow chunks will still keep it alive; we could deal with this by
|
/// shadow chunks will still keep it alive; we could deal with this by
|
||||||
/// making this an `Option`, but it probably isn't worth it since they
|
/// making this an `Option`, but it probably isn't worth it since they
|
||||||
/// shouldn't be that much more nonlocal than regular chunks).
|
/// shouldn't be that much more nonlocal than regular chunks).
|
||||||
texture: Arc<Texture>, // TODO: make this actually work with a bind group
|
col_lights: Arc<ColLights<pipelines::terrain::Locals>>,
|
||||||
light_map: LightMapFn,
|
light_map: LightMapFn,
|
||||||
glow_map: LightMapFn,
|
glow_map: LightMapFn,
|
||||||
sprite_instances: HashMap<(SpriteKind, usize), Instances<SpriteInstance>>,
|
sprite_instances: HashMap<(SpriteKind, usize), Instances<SpriteInstance>>,
|
||||||
locals: Consts<TerrainLocals>,
|
locals: pipelines::terrain::BoundLocals,
|
||||||
pub blocks_of_interest: BlocksOfInterest,
|
pub blocks_of_interest: BlocksOfInterest,
|
||||||
|
|
||||||
visible: Visibility,
|
visible: Visibility,
|
||||||
@ -330,7 +331,7 @@ pub struct Terrain<V: RectRasterableVol = TerrainChunk> {
|
|||||||
/// we allocate. Code cannot assume that this is the assigned texture
|
/// we allocate. Code cannot assume that this is the assigned texture
|
||||||
/// for any particular chunk; look at the `texture` field in
|
/// for any particular chunk; look at the `texture` field in
|
||||||
/// `TerrainChunkData` for that.
|
/// `TerrainChunkData` for that.
|
||||||
col_lights: Texture, /* <ColLightFmt> */
|
col_lights: ColLights<pipelines::terrain::Locals>,
|
||||||
waves: Texture,
|
waves: Texture,
|
||||||
|
|
||||||
phantom: PhantomData<V>,
|
phantom: PhantomData<V>,
|
||||||
@ -577,7 +578,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
|
|
||||||
fn make_atlas(
|
fn make_atlas(
|
||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
) -> Result<(AtlasAllocator, Texture /* <ColLightFmt> */), RenderError> {
|
) -> Result<(AtlasAllocator, ColLights<pipelines::terrain::Locals>), RenderError> {
|
||||||
span!(_guard, "make_atlas", "Terrain::make_atlas");
|
span!(_guard, "make_atlas", "Terrain::make_atlas");
|
||||||
let max_texture_size = renderer.max_texture_size();
|
let max_texture_size = renderer.max_texture_size();
|
||||||
let atlas_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32);
|
let atlas_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32);
|
||||||
@ -622,7 +623,8 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Ok((atlas, texture))
|
let col_light = renderer.terrain_bind_col_light(texture);
|
||||||
|
Ok((atlas, col_light))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_chunk_meta(&mut self, _pos: Vec2<i32>, chunk: &TerrainChunkData) {
|
fn remove_chunk_meta(&mut self, _pos: Vec2<i32>, chunk: &TerrainChunkData) {
|
||||||
@ -1134,7 +1136,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
allocation.rectangle.min.y as u32,
|
allocation.rectangle.min.y as u32,
|
||||||
);
|
);
|
||||||
renderer.update_texture(
|
renderer.update_texture(
|
||||||
col_lights,
|
&col_lights,
|
||||||
atlas_offs.into_array(),
|
atlas_offs.into_array(),
|
||||||
tex_size.into_array(),
|
tex_size.into_array(),
|
||||||
&tex,
|
&tex,
|
||||||
@ -1159,7 +1161,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
light_map: mesh.light_map,
|
light_map: mesh.light_map,
|
||||||
glow_map: mesh.glow_map,
|
glow_map: mesh.glow_map,
|
||||||
sprite_instances,
|
sprite_instances,
|
||||||
locals: renderer.create_consts(&[TerrainLocals {
|
locals: renderer.create_terrain_bound_locals(&[TerrainLocals {
|
||||||
model_offs: Vec3::from(
|
model_offs: Vec3::from(
|
||||||
response.pos.map2(VolGrid2d::<V>::chunk_size(), |e, sz| {
|
response.pos.map2(VolGrid2d::<V>::chunk_size(), |e, sz| {
|
||||||
e as f32 * sz as f32
|
e as f32 * sz as f32
|
||||||
@ -1452,9 +1454,9 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(
|
pub fn render<'a>(
|
||||||
&self,
|
&'a self,
|
||||||
renderer: &mut Renderer,
|
drawer: &mut FirstPassDrawer<'a>,
|
||||||
global: &GlobalModel,
|
global: &GlobalModel,
|
||||||
lod: &LodData,
|
lod: &LodData,
|
||||||
focus_pos: Vec3<f32>,
|
focus_pos: Vec3<f32>,
|
||||||
@ -1473,13 +1475,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
|
|
||||||
for (_, chunk) in chunk_iter {
|
for (_, chunk) in chunk_iter {
|
||||||
if chunk.visible.is_visible() {
|
if chunk.visible.is_visible() {
|
||||||
/* renderer.render_terrain_chunk(
|
drawer.draw_terrain(&chunk.opaque_model, &chunk.locals, &self.col_lights)
|
||||||
&chunk.opaque_model,
|
|
||||||
&chunk.texture,
|
|
||||||
global,
|
|
||||||
&chunk.locals,
|
|
||||||
lod,
|
|
||||||
);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user