diff --git a/Cargo.lock b/Cargo.lock index 32bd085797..abfc59a4cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,6 +184,9 @@ name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +dependencies = [ + "serde", +] [[package]] name = "as-slice" @@ -6640,6 +6643,7 @@ dependencies = [ "naga", "parking_lot 0.11.1", "raw-window-handle", + "serde", "smallvec", "wasm-bindgen", "wasm-bindgen-futures", @@ -6673,6 +6677,8 @@ dependencies = [ "parking_lot 0.11.1", "profiling", "raw-window-handle", + "ron", + "serde", "smallvec", "thiserror", "wgpu-types", @@ -6694,6 +6700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556" dependencies = [ "bitflags", + "serde", ] [[package]] diff --git a/assets/voxygen/shaders/clouds-vert.glsl b/assets/voxygen/shaders/clouds-vert.glsl index 21a6b3d8c2..933d3a3dc3 100644 --- a/assets/voxygen/shaders/clouds-vert.glsl +++ b/assets/voxygen/shaders/clouds-vert.glsl @@ -27,6 +27,7 @@ void main() { float(gl_VertexIndex % 2) * 4.0 - 1.0 ); + // Flip y and transform into 0.0 to 1.0 range uv = (v_pos * vec2(1.0, -1.0) + 1.0) * 0.5; gl_Position = vec4(v_pos, 0.0, 1.0); diff --git a/assets/voxygen/shaders/include/globals.glsl b/assets/voxygen/shaders/include/globals.glsl index 47f038b31f..cc75645b39 100644 --- a/assets/voxygen/shaders/include/globals.glsl +++ b/assets/voxygen/shaders/include/globals.glsl @@ -24,7 +24,7 @@ layout(std140, set = 0, binding = 0) uniform u_globals { // 1 - ThirdPerson uint cam_mode; float sprite_render_distance; - float gloabls_dummy; // Fix alignment. + float globals_dummy; // Fix alignment. }; // Specifies the pattern used in the player dithering diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 88904356dd..1db1fe107f 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -45,7 +45,7 @@ i18n = {package = "veloren-i18n", path = "i18n"} # Graphics winit = {version = "0.24.0", features = ["serde"]} -wgpu = "0.8.1" +wgpu = { version = "0.8.1", features = ["trace"] } wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" } bytemuck = { version="1.4", features=["derive"] } shaderc = "0.6.2" diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 88756a5f1f..e3a9cb36ef 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -2200,7 +2200,7 @@ impl Hud { let gpu_timings = global_state.window.renderer().timings(); if !gpu_timings.is_empty() { let num_timings = gpu_timings.len(); - // Make sure we have enoung ids + // Make sure we have enough ids if self.ids.gpu_timings.len() < num_timings { self.ids .gpu_timings diff --git a/voxygen/src/render/error.rs b/voxygen/src/render/error.rs index cfb3daa0e6..d3736216c4 100644 --- a/voxygen/src/render/error.rs +++ b/voxygen/src/render/error.rs @@ -11,7 +11,6 @@ pub enum RenderError { } use std::fmt; -// TODO: just impl and use Display? impl fmt::Debug for RenderError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/voxygen/src/render/instances.rs b/voxygen/src/render/instances.rs index f07bb58dfd..0638dddbd6 100644 --- a/voxygen/src/render/instances.rs +++ b/voxygen/src/render/instances.rs @@ -9,7 +9,7 @@ pub struct Instances { impl Instances { pub fn new(device: &wgpu::Device, len: usize) -> Self { Self { - // TODO: examine if we have Intances that are not updated (e.g. sprites) and if there + // TODO: examine if we have Instances that are not updated (e.g. sprites) and if there // would be any gains from separating those out buf: DynamicBuffer::new(device, len, wgpu::BufferUsage::VERTEX), } diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index d453595579..c4af1c02ad 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -33,9 +33,8 @@ pub use self::{ shadow::{Locals as ShadowLocals, PointLightMatrix}, skybox::{create_mesh as create_skybox_mesh, Vertex as SkyboxVertex}, sprite::{ - create_verts_buffer as create_sprite_verts_buffer, Instance as SpriteInstance, - SpriteGlobalsBindGroup, Vertex as SpriteVertex, - VERT_PAGE_SIZE as SPRITE_VERT_PAGE_SIZE, + Instance as SpriteInstance, SpriteGlobalsBindGroup, SpriteVerts, + Vertex as SpriteVertex, VERT_PAGE_SIZE as SPRITE_VERT_PAGE_SIZE, }, terrain::{Locals as TerrainLocals, TerrainLayout, Vertex as TerrainVertex}, ui::{ diff --git a/voxygen/src/render/pipelines/clouds.rs b/voxygen/src/render/pipelines/clouds.rs index 613613e572..7796f47689 100644 --- a/voxygen/src/render/pipelines/clouds.rs +++ b/voxygen/src/render/pipelines/clouds.rs @@ -158,7 +158,6 @@ impl CloudsPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/debug.rs b/voxygen/src/render/pipelines/debug.rs index e8a3dc631c..e096510dc4 100644 --- a/voxygen/src/render/pipelines/debug.rs +++ b/voxygen/src/render/pipelines/debug.rs @@ -71,7 +71,6 @@ impl DebugPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/figure.rs b/voxygen/src/render/pipelines/figure.rs index afa461b165..662f5db4c6 100644 --- a/voxygen/src/render/pipelines/figure.rs +++ b/voxygen/src/render/pipelines/figure.rs @@ -192,7 +192,6 @@ impl FigurePipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/fluid.rs b/voxygen/src/render/pipelines/fluid.rs index 04da227b56..3d49fb95c3 100644 --- a/voxygen/src/render/pipelines/fluid.rs +++ b/voxygen/src/render/pipelines/fluid.rs @@ -74,7 +74,6 @@ impl FluidPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/lod_terrain.rs b/voxygen/src/render/pipelines/lod_terrain.rs index 3c22493b47..4257428dbd 100644 --- a/voxygen/src/render/pipelines/lod_terrain.rs +++ b/voxygen/src/render/pipelines/lod_terrain.rs @@ -163,7 +163,6 @@ impl LodTerrainPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index 5e1870ce4c..37832a7e7d 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -191,7 +191,6 @@ impl ParticlePipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/shadow.rs b/voxygen/src/render/pipelines/shadow.rs index 8ba334455e..cc3262b4d7 100644 --- a/voxygen/src/render/pipelines/shadow.rs +++ b/voxygen/src/render/pipelines/shadow.rs @@ -147,7 +147,6 @@ impl ShadowFigurePipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, @@ -221,7 +220,6 @@ impl ShadowPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, @@ -297,7 +295,6 @@ impl PointShadowPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/skybox.rs b/voxygen/src/render/pipelines/skybox.rs index 9c468d858e..76dc159614 100644 --- a/voxygen/src/render/pipelines/skybox.rs +++ b/voxygen/src/render/pipelines/skybox.rs @@ -50,7 +50,6 @@ impl SkyboxPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, @@ -111,12 +110,11 @@ impl SkyboxPipeline { } } -// TODO: generate mesh in vertex shader +#[rustfmt::skip] pub fn create_mesh() -> Mesh { let mut mesh = Mesh::new(); // -x - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [-1.0, -1.0, -1.0] }, Vertex { pos: [-1.0, 1.0, -1.0] }, @@ -124,7 +122,6 @@ pub fn create_mesh() -> Mesh { Vertex { pos: [-1.0, -1.0, 1.0] }, )); // +x - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [ 1.0, -1.0, 1.0] }, Vertex { pos: [ 1.0, 1.0, 1.0] }, @@ -132,7 +129,6 @@ pub fn create_mesh() -> Mesh { Vertex { pos: [ 1.0, -1.0, -1.0] }, )); // -y - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [ 1.0, -1.0, -1.0] }, Vertex { pos: [-1.0, -1.0, -1.0] }, @@ -140,7 +136,6 @@ pub fn create_mesh() -> Mesh { Vertex { pos: [ 1.0, -1.0, 1.0] }, )); // +y - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [ 1.0, 1.0, 1.0] }, Vertex { pos: [-1.0, 1.0, 1.0] }, @@ -148,7 +143,6 @@ pub fn create_mesh() -> Mesh { Vertex { pos: [ 1.0, 1.0, -1.0] }, )); // -z - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [-1.0, -1.0, -1.0] }, Vertex { pos: [ 1.0, -1.0, -1.0] }, @@ -156,7 +150,6 @@ pub fn create_mesh() -> Mesh { Vertex { pos: [-1.0, 1.0, -1.0] }, )); // +z - #[rustfmt::skip] mesh.push_quad(Quad::new( Vertex { pos: [-1.0, 1.0, 1.0] }, Vertex { pos: [ 1.0, 1.0, 1.0] }, diff --git a/voxygen/src/render/pipelines/sprite.rs b/voxygen/src/render/pipelines/sprite.rs index ddc638d382..6a98efcd96 100644 --- a/voxygen/src/render/pipelines/sprite.rs +++ b/voxygen/src/render/pipelines/sprite.rs @@ -1,7 +1,6 @@ use super::{ super::{ - buffer::Buffer, AaMode, GlobalsLayouts, Mesh, Renderer, TerrainLayout, Texture, - Vertex as VertexTrait, + buffer::Buffer, AaMode, GlobalsLayouts, Mesh, TerrainLayout, Texture, Vertex as VertexTrait, }, lod_terrain, GlobalModel, }; @@ -77,14 +76,19 @@ impl VertexTrait for Vertex { const STRIDE: wgpu::BufferAddress = mem::size_of::() as wgpu::BufferAddress; } -pub fn create_verts_buffer(renderer: &mut Renderer, mesh: Mesh) -> Buffer { - renderer.ensure_sufficient_index_length::(VERT_PAGE_SIZE as usize); - // TODO: type Buffer by Usage - Buffer::new( - &renderer.device, +pub struct SpriteVerts(Buffer); +//pub struct SpriteVerts(Texture); + +pub(in super::super) fn create_verts_buffer( + device: &wgpu::Device, + mesh: Mesh, +) -> SpriteVerts { + // TODO: type Buffer by wgpu::BufferUsage + SpriteVerts(Buffer::new( + &device, wgpu::BufferUsage::STORAGE, mesh.vertices(), - ) + )) } #[repr(C)] @@ -203,8 +207,7 @@ impl SpriteLayout { global_model: &GlobalModel, lod_data: &lod_terrain::LodData, noise: &Texture, - //sprite_verts: &Texture, - sprite_verts: &Buffer, + sprite_verts: &SpriteVerts, ) -> wgpu::BindGroup { let mut entries = GlobalsLayouts::bind_base_globals(global_model, lod_data, noise); @@ -212,7 +215,7 @@ impl SpriteLayout { // sprite_verts wgpu::BindGroupEntry { binding: 12, - resource: sprite_verts.buf.as_entire_binding(), + resource: sprite_verts.0.buf.as_entire_binding(), }, ]); @@ -229,7 +232,7 @@ impl SpriteLayout { global_model: &GlobalModel, lod_data: &lod_terrain::LodData, noise: &Texture, - sprite_verts: &Buffer, + sprite_verts: &SpriteVerts, ) -> SpriteGlobalsBindGroup { let bind_group = self.bind_globals_inner(device, global_model, lod_data, noise, sprite_verts); @@ -268,7 +271,6 @@ impl SpritePipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/pipelines/terrain.rs b/voxygen/src/render/pipelines/terrain.rs index 2cc3846c6b..6fc245e7d8 100644 --- a/voxygen/src/render/pipelines/terrain.rs +++ b/voxygen/src/render/pipelines/terrain.rs @@ -229,7 +229,6 @@ impl TerrainPipeline { let samples = match aa_mode { AaMode::None | AaMode::Fxaa => 1, - // TODO: Ensure sampling in the shader is exactly between the 4 texels AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 381842043d..4602da5e1b 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -100,8 +100,7 @@ enum State { /// GPU, along with pipeline state objects (PSOs) needed to renderer different /// kinds of models to the screen. pub struct Renderer { - // TODO: remove pub(super) - pub(super) device: Arc, + device: Arc, queue: wgpu::Queue, surface: wgpu::Surface, swap_chain: wgpu::SwapChain, @@ -165,7 +164,7 @@ impl Renderer { _ => None, }) .unwrap_or( - wgpu::BackendBit::PRIMARY, /* | wgpu::BackendBit::SECONDARY */ + (wgpu::BackendBit::PRIMARY | wgpu::BackendBit::SECONDARY) & !wgpu::BackendBit::GL, ); let instance = wgpu::Instance::new(backend_bit); @@ -196,12 +195,9 @@ impl Renderer { // TODO label: None, features: wgpu::Features::DEPTH_CLAMPING - | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER - | wgpu::Features::PUSH_CONSTANTS - // TODO: make optional based on enabling profiling setting? - // woould require recreating the device/queue if this setting changes - // alternatively it could be a compile time feature toggle - | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), + | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER + | wgpu::Features::PUSH_CONSTANTS + | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), limits, }, std::env::var_os("WGPU_TRACE_DIR") @@ -567,8 +563,6 @@ impl Renderer { .into_tuple(); let (width, height, sample_count) = match mode.aa { AaMode::None | AaMode::Fxaa => (upscaled.0, upscaled.1, 1), - // TODO: Ensure sampling in the shader is exactly between the 4 texels - // TODO: Figure out how to do upscaling correctly with SSAA AaMode::MsaaX4 => (upscaled.0, upscaled.1, 4), AaMode::MsaaX8 => (upscaled.0, upscaled.1, 8), AaMode::MsaaX16 => (upscaled.0, upscaled.1, 16), @@ -982,6 +976,11 @@ impl Renderer { } } + pub fn create_sprite_verts(&mut self, mesh: Mesh) -> sprite::SpriteVerts { + self.ensure_sufficient_index_length::(sprite::VERT_PAGE_SIZE as usize); + sprite::create_verts_buffer(&self.device, mesh) + } + /// Create a new model from the provided mesh. /// If the provided mesh is empty this returns None pub fn create_model(&mut self, mesh: &Mesh) -> Option> { @@ -1125,6 +1124,8 @@ impl Renderer { } } + // Consider reenabling at some time + // // /// Queue the rendering of the player silhouette in the upcoming frame. // pub fn render_player_shadow( // &mut self, diff --git a/voxygen/src/render/renderer/binding.rs b/voxygen/src/render/renderer/binding.rs index 69f109171e..f42808c0a8 100644 --- a/voxygen/src/render/renderer/binding.rs +++ b/voxygen/src/render/renderer/binding.rs @@ -1,6 +1,5 @@ use super::{ super::{ - buffer::Buffer, pipelines::{ debug, figure, lod_terrain, shadow, sprite, terrain, ui, ColLights, GlobalModel, GlobalsBindGroup, @@ -25,7 +24,7 @@ impl Renderer { &self, global_model: &GlobalModel, lod_data: &lod_terrain::LodData, - sprite_verts: &Buffer, + sprite_verts: &sprite::SpriteVerts, ) -> sprite::SpriteGlobalsBindGroup { self.layouts.sprite.bind_globals( &self.device, diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index 47d0f4c119..4e45488e13 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -49,7 +49,7 @@ impl<'frame> Pipelines<'frame> { } // Borrow the fields we need from the renderer so that the GpuProfiler can be -// dijointly borrowed mutably +// disjointly borrowed mutably struct RendererBorrow<'frame> { queue: &'frame wgpu::Queue, device: &'frame wgpu::Device, @@ -405,7 +405,7 @@ impl<'frame> Drop for Drawer<'frame> { fn drop(&mut self) { let mut encoder = self.encoder.take().unwrap(); - // If taking a screenshota and the blit pipeline is available + // If taking a screenshot and the blit pipeline is available // NOTE: blit pipeline should always be available for now so we don't report an // error if it isn't if let Some((screenshot, blit)) = self diff --git a/voxygen/src/render/renderer/shadow_map.rs b/voxygen/src/render/renderer/shadow_map.rs index cacede40dd..b7361adebe 100644 --- a/voxygen/src/render/renderer/shadow_map.rs +++ b/voxygen/src/render/renderer/shadow_map.rs @@ -204,7 +204,6 @@ impl ShadowMap { usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT, }; - //TODO: (0, levels - 1), ?? from master let point_shadow_view = wgpu::TextureViewDescriptor { label: None, format: Some(wgpu::TextureFormat::Depth24Plus), diff --git a/voxygen/src/run.rs b/voxygen/src/run.rs index 099bc94128..f1711dfc6a 100644 --- a/voxygen/src/run.rs +++ b/voxygen/src/run.rs @@ -168,20 +168,9 @@ fn handle_main_events_cleared( if let Some(last) = states.last_mut() { span!(guard, "Render"); let renderer = global_state.window.renderer_mut(); - // // Clear the shadow maps. - // renderer.clear_shadows(); - // // Clear the screen - // renderer.clear(); // Render the screen using the global renderer last.render(renderer, &global_state.settings); - // Finish the frame. - // TODO: do this as part of dropping rendering thing - //global_state.window.renderer_mut().flush().unwrap(); - // // Display the frame on the window. - // global_state - // .window - // .swap_buffers() - // .expect("Failed to swap window buffers!"); + drop(guard); } diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index fcf06cc1b8..d4aa8aa752 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -77,7 +77,7 @@ fn clamp_and_modulate(ori: Vec3) -> Vec3 { /// The only requirements on n and f are: 1/n ≠ 1/f, and 0 ≤ 1/n * 1/f. /// /// This ensures that the near and far plane are not identical (or else your -/// projection would not covver any distance), and that they have the same sign +/// projection would not cover any distance), and that they have the same sign /// (or else we cannot rely on clipping to properly fix your scene). This also /// ensures that at least one of 1/n and 1/f is not 0, and by construction it /// guarantees that neither n nor f are 0; these are required in order to make diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e4d919fe63..d5b55c3033 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -5267,7 +5267,7 @@ impl FigureColLights { (0, 0), gfx::format::Swizzle::new(), gfx::texture::SamplerInfo::new( - gfx::texture::FilterMetho>:Bilinear, + gfx::texture::FilterMethod::Bilinear, gfx::texture::WrapMode::Clamp, ), )?; diff --git a/voxygen/src/scene/lod.rs b/voxygen/src/scene/lod.rs index 4af75339ba..2e31737c08 100644 --- a/voxygen/src/scene/lod.rs +++ b/voxygen/src/scene/lod.rs @@ -31,7 +31,8 @@ impl Lod { client.world_data().lod_alt.raw(), client.world_data().lod_horizon.raw(), settings.graphics.lod_detail.max(100).min(2500), - // water_color().into_array().into(), + /* TODO: figure out how we want to do this without color borders? + * water_color().into_array().into(), */ ), } } diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index cec09333c7..1aa6022f75 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -9,10 +9,9 @@ use crate::{ terrain::{generate_mesh, SUNLIGHT}, }, render::{ - create_sprite_verts_buffer, pipelines::{self, ColLights}, - Buffer, ColLightInfo, FirstPassDrawer, FluidVertex, GlobalModel, Instances, LodData, Mesh, - Model, RenderError, Renderer, SpriteGlobalsBindGroup, SpriteInstance, SpriteVertex, + ColLightInfo, FirstPassDrawer, FluidVertex, GlobalModel, Instances, LodData, Mesh, Model, + RenderError, Renderer, SpriteGlobalsBindGroup, SpriteInstance, SpriteVertex, SpriteVerts, TerrainLocals, TerrainShadowDrawer, TerrainVertex, SPRITE_VERT_PAGE_SIZE, }, }; @@ -372,7 +371,7 @@ pub struct SpriteRenderContext { // Maps sprite kind + variant to data detailing how to render it sprite_data: Arc>, sprite_col_lights: Arc>, - sprite_verts_buffer: Arc>, + sprite_verts_buffer: Arc, } pub type SpriteRenderContextLazy = Box SpriteRenderContext>; @@ -521,7 +520,7 @@ impl SpriteRenderContext { let sprite_col_lights = renderer.sprite_bind_col_light(sprite_col_lights); // Write sprite model to a 1D texture - let sprite_verts_buffer = create_sprite_verts_buffer(renderer, sprite_mesh); + let sprite_verts_buffer = renderer.create_sprite_verts(sprite_mesh); Self { // TODO: these are all Arcs, would it makes sense to factor out the Arc? @@ -1069,20 +1068,12 @@ impl Terrain { // data structure (convert the mesh to a model first of course). Some(todo) if response.started_tick <= todo.started_tick => { let started_tick = todo.started_tick; - let sprite_instances = { - let mut iter = response.sprite_instances.iter().map(|instances| { - renderer - .create_instances(instances) - .expect("Failed to upload chunk sprite instances to the GPU!") - }); - [ - iter.next().unwrap(), - iter.next().unwrap(), - iter.next().unwrap(), - iter.next().unwrap(), - iter.next().unwrap(), - ] - }; + + let sprite_instances = response.sprite_instances.map(|instances| { + renderer + .create_instances(&instances) + .expect("Failed to upload chunk sprite instances to the GPU!") + }); if let Some(mesh) = response.mesh { // Full update, insert the whole chunk.