mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Renable the figure and terrain drawing code (not working yet)
This commit is contained in:
parent
de103bee1c
commit
2bad1f22b0
@ -35,9 +35,9 @@ layout(location = 1) flat in vec3 f_norm;
|
|||||||
// const vec4 sun_pos = vec4(0.0);
|
// const vec4 sun_pos = vec4(0.0);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
layout(set = 1, binding = 2)
|
layout(set = 2, binding = 0)
|
||||||
uniform texture2D t_col_light;
|
uniform texture2D t_col_light;
|
||||||
layout(set = 1, binding = 3)
|
layout(set = 2, binding = 1)
|
||||||
uniform sampler s_col_light;
|
uniform sampler s_col_light;
|
||||||
|
|
||||||
//struct ShadowLocals {
|
//struct ShadowLocals {
|
||||||
|
@ -236,13 +236,9 @@ 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);
|
||||||
|
|
||||||
// Render the scene.
|
self.scene
|
||||||
//self.scene
|
.render(&mut drawer.first_pass(), client.get_tick(), humanoid_body, loadout);
|
||||||
// .render(renderer, client.get_tick(), humanoid_body, loadout);
|
|
||||||
|
|
||||||
// Render world
|
|
||||||
/* let mut first_pass = */
|
|
||||||
drawer.first_pass();
|
|
||||||
// Clouds
|
// Clouds
|
||||||
drawer.second_pass().draw_clouds();
|
drawer.second_pass().draw_clouds();
|
||||||
// PostProcess and UI
|
// PostProcess and UI
|
||||||
|
@ -13,7 +13,8 @@ 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::Buffer { self.buf }
|
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 }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a mesh that has been sent to the GPU.
|
/// Represents a mesh that has been sent to the GPU.
|
||||||
@ -79,3 +80,5 @@ impl<V: Vertex> DynamicModel<V> {
|
|||||||
|
|
||||||
pub fn len(&self) -> usize { self.vbuf.len() }
|
pub fn len(&self) -> usize { self.vbuf.len() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn map_range(range: &Range<u32>) -> Range<u64> { (range.start as u64)..(range.end as u64) }
|
||||||
|
@ -144,6 +144,7 @@ impl CloudsPipeline {
|
|||||||
vs_module: &wgpu::ShaderModule,
|
vs_module: &wgpu::ShaderModule,
|
||||||
fs_module: &wgpu::ShaderModule,
|
fs_module: &wgpu::ShaderModule,
|
||||||
global_layout: &GlobalsLayouts,
|
global_layout: &GlobalsLayouts,
|
||||||
|
sc_desc: &wgpu::SwapChainDescriptor,
|
||||||
layout: &CloudsLayout,
|
layout: &CloudsLayout,
|
||||||
aa_mode: AaMode,
|
aa_mode: AaMode,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -177,7 +178,7 @@ impl CloudsPipeline {
|
|||||||
rasterization_state: None,
|
rasterization_state: None,
|
||||||
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
|
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
|
||||||
color_states: &[wgpu::ColorStateDescriptor {
|
color_states: &[wgpu::ColorStateDescriptor {
|
||||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
format: sc_desc.format,
|
||||||
color_blend: wgpu::BlendDescriptor::REPLACE,
|
color_blend: wgpu::BlendDescriptor::REPLACE,
|
||||||
alpha_blend: wgpu::BlendDescriptor::REPLACE,
|
alpha_blend: wgpu::BlendDescriptor::REPLACE,
|
||||||
write_mask: wgpu::ColorWrite::ALL,
|
write_mask: wgpu::ColorWrite::ALL,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{AaMode, GlobalsLayouts, Mesh, Model},
|
super::{AaMode, Bound, Consts, GlobalsLayouts, Mesh, Model, Texture},
|
||||||
terrain::Vertex,
|
terrain::Vertex,
|
||||||
};
|
};
|
||||||
use crate::mesh::greedy::GreedyMesh;
|
use crate::mesh::greedy::GreedyMesh;
|
||||||
@ -24,6 +24,9 @@ pub struct BoneData {
|
|||||||
normals_mat: [[f32; 4]; 4],
|
normals_mat: [[f32; 4]; 4],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type BoundLocals = Bound<(Consts<Locals>, Consts<BoneData>)>;
|
||||||
|
pub type ColLights = Bound<Texture>;
|
||||||
|
|
||||||
impl Locals {
|
impl Locals {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
model_mat: anim::vek::Mat4<f32>,
|
model_mat: anim::vek::Mat4<f32>,
|
||||||
@ -97,6 +100,7 @@ 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 {
|
||||||
@ -127,9 +131,14 @@ impl FigureLayout {
|
|||||||
},
|
},
|
||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
col_light: device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
|
label: None,
|
||||||
|
entries: &[
|
||||||
// col lights
|
// col lights
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 2,
|
binding: 0,
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Texture {
|
ty: wgpu::BindingType::Texture {
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||||
@ -139,15 +148,67 @@ impl FigureLayout {
|
|||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 3,
|
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,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bind_locals(
|
||||||
|
&self,
|
||||||
|
device: &wgpu::Device,
|
||||||
|
locals: Consts<Locals>,
|
||||||
|
bone_data: Consts<BoneData>,
|
||||||
|
) -> 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(),
|
||||||
|
},
|
||||||
|
wgpu::BindGroupEntry {
|
||||||
|
binding: 1,
|
||||||
|
resource: bone_data.buf().as_entire_binding(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
BoundLocals {
|
||||||
|
bind_group,
|
||||||
|
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 {
|
||||||
@ -169,7 +230,7 @@ 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],
|
bind_group_layouts: &[&global_layout.globals, &layout.locals, &layout.col_light],
|
||||||
});
|
});
|
||||||
|
|
||||||
let samples = match aa_mode {
|
let samples = match aa_mode {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::super::{AaMode, GlobalsLayouts};
|
use super::super::{AaMode, Bound, Consts, GlobalsLayouts};
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -132,6 +132,8 @@ impl Locals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type BoundLocals = Bound<Consts<Locals>>;
|
||||||
|
|
||||||
pub struct TerrainLayout {
|
pub struct TerrainLayout {
|
||||||
pub locals: wgpu::BindGroupLayout,
|
pub locals: wgpu::BindGroupLayout,
|
||||||
}
|
}
|
||||||
|
@ -613,13 +613,13 @@ impl Renderer {
|
|||||||
mip_level_count: levels,
|
mip_level_count: levels,
|
||||||
sample_count,
|
sample_count,
|
||||||
dimension: wgpu::TextureDimension::D2,
|
dimension: wgpu::TextureDimension::D2,
|
||||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
|
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
|
||||||
});
|
});
|
||||||
|
|
||||||
tex.create_view(&wgpu::TextureViewDescriptor {
|
tex.create_view(&wgpu::TextureViewDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
format: Some(wgpu::TextureFormat::Rgba8UnormSrgb),
|
format: Some(wgpu::TextureFormat::Bgra8UnormSrgb),
|
||||||
dimension: Some(wgpu::TextureViewDimension::D2),
|
dimension: Some(wgpu::TextureViewDimension::D2),
|
||||||
// TODO: why is this not Color?
|
// TODO: why is this not Color?
|
||||||
aspect: wgpu::TextureAspect::All,
|
aspect: wgpu::TextureAspect::All,
|
||||||
@ -2161,6 +2161,7 @@ fn create_pipelines(
|
|||||||
&create_shader("clouds-frag", ShaderKind::Fragment)?,
|
&create_shader("clouds-frag", ShaderKind::Fragment)?,
|
||||||
// TODO: pass in format of intermediate color buffer
|
// TODO: pass in format of intermediate color buffer
|
||||||
&layouts.global,
|
&layouts.global,
|
||||||
|
sc_desc,
|
||||||
&layouts.clouds,
|
&layouts.clouds,
|
||||||
mode.aa,
|
mode.aa,
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
consts::Consts,
|
consts::Consts,
|
||||||
pipelines::{lod_terrain, ui, GlobalModel, GlobalsBindGroup},
|
pipelines::{figure, lod_terrain, ui, GlobalModel, GlobalsBindGroup},
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
},
|
},
|
||||||
Renderer,
|
Renderer,
|
||||||
@ -36,4 +36,20 @@ impl Renderer {
|
|||||||
pub fn ui_bind_texture(&self, texture: &Texture) -> ui::TextureBindGroup {
|
pub fn ui_bind_texture(&self, texture: &Texture) -> ui::TextureBindGroup {
|
||||||
self.layouts.ui.bind_texture(&self.device, texture)
|
self.layouts.ui.bind_texture(&self.device, texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_figure_bound_locals(
|
||||||
|
&mut self,
|
||||||
|
locals: &[figure::Locals],
|
||||||
|
bone_data: &[figure::BoneData],
|
||||||
|
) -> figure::BoundLocals {
|
||||||
|
let locals = self.create_consts(locals);
|
||||||
|
let bone_data = self.create_consts(bone_data);
|
||||||
|
self.layouts
|
||||||
|
.figure
|
||||||
|
.bind_locals(&self.device, locals, bone_data)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn figure_bind_texture(&self, col_light: Texture) -> figure::ColLights {
|
||||||
|
self.layouts.figure.bind_texture(&self.device, col_light)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use super::{
|
|||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
consts::Consts,
|
consts::Consts,
|
||||||
instances::Instances,
|
instances::Instances,
|
||||||
model::{DynamicModel, Model},
|
model::{DynamicModel, SubModel,Model},
|
||||||
pipelines::{
|
pipelines::{
|
||||||
clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, GlobalsBindGroup,
|
clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, GlobalsBindGroup,
|
||||||
Light, Shadow,
|
Light, Shadow,
|
||||||
@ -109,7 +109,6 @@ impl<'a> Drawer<'a> {
|
|||||||
store: true,
|
store: true,
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
// TODO: do we need this?
|
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -149,49 +148,37 @@ impl<'a> FirstPassDrawer<'a> {
|
|||||||
self.render_pass.set_bind_group(0, &globals.bind_group, &[]);
|
self.render_pass.set_bind_group(0, &globals.bind_group, &[]);
|
||||||
self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0);
|
self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0);
|
||||||
self.render_pass.draw(verts, 0..1);
|
self.render_pass.draw(verts, 0..1);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
pub fn draw_figure<'b: 'a>(
|
pub fn draw_figure<'b: 'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: &'b Model,
|
model: SubModel<'b, terrain::Vertex>,
|
||||||
locals: &'b Consts<figure::Locals>,
|
locals: &'b figure::BoundLocals,
|
||||||
bones: &'b Consts<figure::BoneData>,
|
col_lights: &'b figure::ColLights
|
||||||
globals: &'b Consts<Globals>,
|
|
||||||
lights: &'b Consts<Light>,
|
|
||||||
shadows: &'b Consts<Shadow>,
|
|
||||||
verts: Range<u32>,
|
|
||||||
) {
|
) {
|
||||||
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(0, &globals.bind_group, &[]);
|
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||||
self.render_pass.set_bind_group(1, &lights.bind_group, &[]);
|
self.render_pass.set_bind_group(2, &col_lights.bind_group, &[]);
|
||||||
self.render_pass.set_bind_group(2, &shadows.bind_group, &[]);
|
self.render_pass
|
||||||
self.render_pass.set_bind_group(3, &locals.bind_group, &[]);
|
.set_vertex_buffer(0, model.buf());
|
||||||
self.render_pass.set_bind_group(4, &bones.bind_group, &[]);
|
self.render_pass.draw(0..model.len(), 0..1);
|
||||||
self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0);
|
|
||||||
self.render_pass.draw(verts, 0..1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_terrain<'b: 'a>(
|
pub fn draw_terrain<'b: 'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: &'b Model,
|
model: &'b SubModel<terrain::Vertex>,
|
||||||
locals: &'b Consts<terrain::Locals>,
|
locals: &'b terrain::BoundLocals,
|
||||||
globals: &'b Consts<Globals>,
|
|
||||||
lights: &'b Consts<Light>,
|
|
||||||
shadows: &'b Consts<Shadow>,
|
|
||||||
verts: Range<u32>,
|
|
||||||
) {
|
) {
|
||||||
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(0, &globals.bind_group, &[]);
|
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||||
self.render_pass.set_bind_group(1, &lights.bind_group, &[]);
|
self.render_pass
|
||||||
self.render_pass.set_bind_group(2, &shadows.bind_group, &[]);
|
.set_vertex_buffer(0, model.buf());
|
||||||
self.render_pass.set_bind_group(3, &locals.bind_group, &[]);
|
self.render_pass.draw(0..model.len(), 0..1)
|
||||||
self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0);
|
|
||||||
self.render_pass.draw(verts, 0..1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_fluid<'b: 'a>(
|
/*pub fn draw_fluid<'b: 'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
model: &'b Model,
|
model: &'b Model,
|
||||||
locals: &'b Consts<terrain::Locals>,
|
locals: &'b Consts<terrain::Locals>,
|
||||||
|
@ -61,8 +61,7 @@ pub type CameraData<'a> = (&'a Camera, f32);
|
|||||||
|
|
||||||
/// Enough data to render a figure model.
|
/// Enough data to render a figure model.
|
||||||
pub type FigureModelRef<'a> = (
|
pub type FigureModelRef<'a> = (
|
||||||
&'a Consts<FigureLocals>,
|
&'a pipelines::figure::BoundLocals,
|
||||||
&'a Consts<FigureBoneData>,
|
|
||||||
SubModel<'a, TerrainVertex>,
|
SubModel<'a, TerrainVertex>,
|
||||||
&'a Texture, /* <ColLightFmt> */
|
&'a Texture, /* <ColLightFmt> */
|
||||||
);
|
);
|
||||||
@ -80,7 +79,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: Texture, /* <ColLightFmt> */
|
col_lights: pipelines::figure::ColLights,
|
||||||
/// 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],
|
||||||
@ -3562,7 +3561,7 @@ impl FigureMgr {
|
|||||||
// Don't render dead entities
|
// Don't render dead entities
|
||||||
.filter(|(_, _, _, _, health, _, _)| health.map_or(true, |h| !h.is_dead))
|
.filter(|(_, _, _, _, health, _, _)| health.map_or(true, |h| !h.is_dead))
|
||||||
.for_each(|(entity, pos, _, body, _, inventory, _)| {
|
.for_each(|(entity, pos, _, body, _, inventory, _)| {
|
||||||
if let Some((locals, bone_consts, model, _)) = self.get_model_for_render(
|
if let Some((bound, model, _)) = self.get_model_for_render(
|
||||||
tick,
|
tick,
|
||||||
camera,
|
camera,
|
||||||
None,
|
None,
|
||||||
@ -3620,7 +3619,7 @@ impl FigureMgr {
|
|||||||
let is_player = entity == player_entity;
|
let is_player = entity == player_entity;
|
||||||
|
|
||||||
if !is_player {
|
if !is_player {
|
||||||
if let Some((locals, bone_consts, model, col_lights)) = self.get_model_for_render(
|
if let Some((bound, model, col_lights)) = self.get_model_for_render(
|
||||||
tick,
|
tick,
|
||||||
camera,
|
camera,
|
||||||
character_state,
|
character_state,
|
||||||
@ -3669,7 +3668,7 @@ impl FigureMgr {
|
|||||||
let inventory_storage = ecs.read_storage::<Inventory>();
|
let inventory_storage = ecs.read_storage::<Inventory>();
|
||||||
let inventory = inventory_storage.get(player_entity);
|
let inventory = inventory_storage.get(player_entity);
|
||||||
|
|
||||||
if let Some((locals, bone_consts, model, col_lights)) = self.get_model_for_render(
|
if let Some((bound, model, col_lights)) = self.get_model_for_render(
|
||||||
tick,
|
tick,
|
||||||
camera,
|
camera,
|
||||||
character_state,
|
character_state,
|
||||||
@ -3751,14 +3750,13 @@ impl FigureMgr {
|
|||||||
},
|
},
|
||||||
} = self;
|
} = self;
|
||||||
let col_lights = &*col_lights_;
|
let col_lights = &*col_lights_;
|
||||||
if let Some((locals, bone_consts, model_entry)) = match body {
|
if let Some((bound, model_entry)) = match body {
|
||||||
Body::Humanoid(body) => character_states
|
Body::Humanoid(body) => character_states
|
||||||
.get(&entity)
|
.get(&entity)
|
||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
model_cache.get_model(
|
model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3774,8 +3772,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
quadruped_small_model_cache.get_model(
|
quadruped_small_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3791,8 +3788,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
quadruped_medium_model_cache.get_model(
|
quadruped_medium_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3808,8 +3804,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
quadruped_low_model_cache.get_model(
|
quadruped_low_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3825,8 +3820,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
bird_medium_model_cache.get_model(
|
bird_medium_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3842,8 +3836,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
fish_medium_model_cache.get_model(
|
fish_medium_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3859,8 +3852,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
theropod_model_cache.get_model(
|
theropod_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3876,8 +3868,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
dragon_model_cache.get_model(
|
dragon_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3893,8 +3884,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
bird_small_model_cache.get_model(
|
bird_small_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3910,8 +3900,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
fish_small_model_cache.get_model(
|
fish_small_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3927,8 +3916,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
biped_large_model_cache.get_model(
|
biped_large_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3944,8 +3932,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
golem_model_cache.get_model(
|
golem_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3961,8 +3948,7 @@ impl FigureMgr {
|
|||||||
.filter(|state| filter_state(&*state))
|
.filter(|state| filter_state(&*state))
|
||||||
.map(move |state| {
|
.map(move |state| {
|
||||||
(
|
(
|
||||||
state.locals(),
|
state.bound(),
|
||||||
state.bone_consts(),
|
|
||||||
object_model_cache.get_model(
|
object_model_cache.get_model(
|
||||||
col_lights,
|
col_lights,
|
||||||
*body,
|
*body,
|
||||||
@ -3987,7 +3973,7 @@ impl FigureMgr {
|
|||||||
model_entry.lod_model(0)
|
model_entry.lod_model(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
Some((locals, bone_consts, model, col_lights_.texture(model_entry)))
|
Some((bound, model, col_lights_.texture(model_entry)))
|
||||||
} else {
|
} else {
|
||||||
// trace!("Body has no saved figure");
|
// trace!("Body has no saved figure");
|
||||||
None
|
None
|
||||||
@ -4013,8 +3999,10 @@ impl FigureColLights {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Find the correct texture for this model entry.
|
/// Find the correct texture for this model entry.
|
||||||
pub fn texture<'a, const N: usize>(&'a self, model: &'a FigureModelEntry<N>) -> &'a Texture /* <ColLightFmt> */
|
pub fn texture<'a, const N: usize>(
|
||||||
{
|
&'a self,
|
||||||
|
model: &'a FigureModelEntry<N>,
|
||||||
|
) -> &'a pipelines::figure::ColLights {
|
||||||
/* &self.col_lights */
|
/* &self.col_lights */
|
||||||
&model.col_lights
|
&model.col_lights
|
||||||
}
|
}
|
||||||
@ -4038,6 +4026,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 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)?;
|
||||||
@ -4097,8 +4086,6 @@ impl FigureColLights {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct FigureStateMeta {
|
pub struct FigureStateMeta {
|
||||||
bone_consts: Consts<FigureBoneData>,
|
|
||||||
locals: Consts<FigureLocals>,
|
|
||||||
lantern_offset: anim::vek::Vec3<f32>,
|
lantern_offset: anim::vek::Vec3<f32>,
|
||||||
state_time: f64,
|
state_time: f64,
|
||||||
last_ori: anim::vek::Quaternion<f32>,
|
last_ori: anim::vek::Quaternion<f32>,
|
||||||
@ -4110,6 +4097,7 @@ pub struct FigureStateMeta {
|
|||||||
last_light: f32,
|
last_light: f32,
|
||||||
last_glow: f32,
|
last_glow: f32,
|
||||||
acc_vel: f32,
|
acc_vel: f32,
|
||||||
|
bound: pipelines::figure::BoundLocals,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FigureStateMeta {
|
impl FigureStateMeta {
|
||||||
@ -4144,8 +4132,6 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
let bone_consts = figure_bone_data_from_anim(&buf);
|
let bone_consts = figure_bone_data_from_anim(&buf);
|
||||||
Self {
|
Self {
|
||||||
meta: FigureStateMeta {
|
meta: FigureStateMeta {
|
||||||
bone_consts: renderer.create_consts(bone_consts),
|
|
||||||
locals: renderer.create_consts(&[FigureLocals::default()]),
|
|
||||||
lantern_offset,
|
lantern_offset,
|
||||||
state_time: 0.0,
|
state_time: 0.0,
|
||||||
last_ori: Ori::default().into(),
|
last_ori: Ori::default().into(),
|
||||||
@ -4157,6 +4143,7 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
last_light: 1.0,
|
last_light: 1.0,
|
||||||
last_glow: 0.0,
|
last_glow: 0.0,
|
||||||
acc_vel: 0.0,
|
acc_vel: 0.0,
|
||||||
|
bound: renderer.create_figure_bound_locals(&[FigureLocals::default()], bone_consts),
|
||||||
},
|
},
|
||||||
skeleton,
|
skeleton,
|
||||||
}
|
}
|
||||||
@ -4267,16 +4254,13 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
self.last_light,
|
self.last_light,
|
||||||
self.last_glow,
|
self.last_glow,
|
||||||
);
|
);
|
||||||
renderer.update_consts(&mut self.locals, &[locals]);
|
renderer.update_consts(&mut self.meta.bound.0, &[locals]);
|
||||||
|
|
||||||
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, buf);
|
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, buf);
|
||||||
|
|
||||||
let new_bone_consts = figure_bone_data_from_anim(buf);
|
let new_bone_consts = figure_bone_data_from_anim(buf);
|
||||||
|
|
||||||
renderer.update_consts(
|
renderer.update_consts(&mut self.meta.bound.1, &new_bone_consts[0..S::BONE_COUNT]);
|
||||||
&mut self.meta.bone_consts,
|
|
||||||
&new_bone_consts[0..S::BONE_COUNT],
|
|
||||||
);
|
|
||||||
self.lantern_offset = lantern_offset;
|
self.lantern_offset = lantern_offset;
|
||||||
|
|
||||||
let smoothing = (5.0 * dt).min(1.0);
|
let smoothing = (5.0 * dt).min(1.0);
|
||||||
@ -4293,9 +4277,7 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn locals(&self) -> &Consts<FigureLocals> { &self.locals }
|
pub fn bound(&self) -> &pipelines::figure::BoundLocals { &self.bound }
|
||||||
|
|
||||||
pub fn bone_consts(&self) -> &Consts<FigureBoneData> { &self.bone_consts }
|
|
||||||
|
|
||||||
pub fn skeleton_mut(&mut self) -> &mut S { &mut self.skeleton }
|
pub fn skeleton_mut(&mut self) -> &mut S { &mut self.skeleton }
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
mesh::{greedy::GreedyMesh, segment::generate_mesh_base_vol_terrain},
|
mesh::{greedy::GreedyMesh, segment::generate_mesh_base_vol_terrain},
|
||||||
render::{
|
render::{
|
||||||
create_skybox_mesh, BoneMeshes, Consts, FigureModel, GlobalModel, Globals,
|
create_skybox_mesh, BoneMeshes, Consts, FigureModel, FirstPassDrawer, GlobalModel, Globals,
|
||||||
GlobalsBindGroup, Light, LodData, Mesh, Model, Renderer, Shadow, ShadowLocals,
|
GlobalsBindGroup, Light, LodData, Mesh, Model, Renderer, Shadow, ShadowLocals,
|
||||||
SkyboxVertex, TerrainVertex,
|
SkyboxVertex, TerrainVertex,
|
||||||
},
|
},
|
||||||
@ -339,20 +339,13 @@ impl Scene {
|
|||||||
|
|
||||||
pub fn global_bind_group(&self) -> &GlobalsBindGroup { &self.globals_bind_group }
|
pub fn global_bind_group(&self) -> &GlobalsBindGroup { &self.globals_bind_group }
|
||||||
|
|
||||||
pub fn render(
|
pub fn render<'a>(
|
||||||
&mut self,
|
&'a self,
|
||||||
renderer: &mut Renderer,
|
drawer: &mut FirstPassDrawer<'a>,
|
||||||
tick: u64,
|
tick: u64,
|
||||||
body: Option<humanoid::Body>,
|
body: Option<humanoid::Body>,
|
||||||
inventory: Option<&Inventory>,
|
inventory: Option<&Inventory>,
|
||||||
) {
|
) {
|
||||||
/*renderer.render_skybox(
|
|
||||||
&self.skybox.model,
|
|
||||||
&self.data,
|
|
||||||
&self.skybox.locals,
|
|
||||||
&self.lod,
|
|
||||||
);*/
|
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
let model = &self.figure_model_cache.get_model(
|
let model = &self.figure_model_cache.get_model(
|
||||||
&self.col_lights,
|
&self.col_lights,
|
||||||
@ -364,40 +357,20 @@ impl Scene {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if let Some(model) = model {
|
if let Some(model) = model {
|
||||||
// renderer.render_figure(
|
drawer.draw_figure(
|
||||||
// &model.models[0],
|
model.lod_model(0),
|
||||||
// &self.col_lights.texture(model),
|
self.figure_state.bound(),
|
||||||
// &self.data,
|
&self.col_lights.texture(model),
|
||||||
// self.figure_state.locals(),
|
);
|
||||||
// self.figure_state.bone_consts(),
|
|
||||||
// &self.lod,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((model, state)) = &self.backdrop {
|
if let Some((model, state)) = &self.backdrop {
|
||||||
/*renderer.render_figure(
|
drawer.draw_figure(
|
||||||
&model.models[0],
|
model.lod_model(0),
|
||||||
|
state.bound(),
|
||||||
&self.col_lights.texture(model),
|
&self.col_lights.texture(model),
|
||||||
&self.data,
|
);
|
||||||
state.locals(),
|
}
|
||||||
state.bone_consts(),
|
|
||||||
&self.lod,
|
|
||||||
);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// renderer.render_clouds(
|
|
||||||
// &self.clouds.model,
|
|
||||||
// &self.data.globals,
|
|
||||||
// &self.clouds.locals,
|
|
||||||
// &self.lod,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// renderer.render_post_process(
|
|
||||||
// &self.postprocess.model,
|
|
||||||
// &self.data.globals,
|
|
||||||
// &self.postprocess.locals,
|
|
||||||
// &self.lod,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user