diff --git a/Cargo.toml b/Cargo.toml index f46b48b92f..db67efc3e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,8 +110,3 @@ nativeBuildInputs = ["pkg-config"] # macos CI fix isn't merged yet winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" } vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" } - -# Pending https://github.com/gfx-rs/wgpu/pull/1080 -[patch.'https://github.com/gfx-rs/wgpu'] -wgpu-core = { git="https://github.com/JCapucho/wgpu" } -wgpu-types = { git="https://github.com/JCapucho/wgpu" } diff --git a/assets/voxygen/shaders/include/srgb.glsl b/assets/voxygen/shaders/include/srgb.glsl index a9f0585e48..118221a137 100644 --- a/assets/voxygen/shaders/include/srgb.glsl +++ b/assets/voxygen/shaders/include/srgb.glsl @@ -648,6 +648,6 @@ vec3 greedy_extract_col_light_attr(texture2D t_col_light, sampler s_col_light, v vec3 greedy_extract_col_light_glow(texture2D t_col_light, sampler s_col_light, vec2 f_uv_pos, out float f_light, out float f_glow) { uint f_attr; - return greedy_extract_col_light_attr(t_col_light, f_uv_pos, f_light, f_glow, f_attr); + return greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_light, f_glow, f_attr); } #endif diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 337dbf5d0f..86869abf9b 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 = { git="https://github.com/gfx-rs/wgpu-rs.git", rev = "ab8b0e3766558d541206da2790dfd63f15b13bc4" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "ab8b0e3766558d541206da2790dfd63f15b13bc4" } bytemuck = { version="1.4", features=["derive"] } shaderc = "0.6.2" diff --git a/voxygen/src/mesh/greedy.rs b/voxygen/src/mesh/greedy.rs index 63defad0b0..839d443cd1 100644 --- a/voxygen/src/mesh/greedy.rs +++ b/voxygen/src/mesh/greedy.rs @@ -150,7 +150,7 @@ impl<'a> GreedyMesh<'a> { FO: for<'r> FnMut(&'r mut D, Vec3) -> bool + 'a, FS: for<'r> FnMut(&'r mut D, Vec3, Vec3, Vec2>) -> Option<(bool, M)>, FP: FnMut(Vec2, Vec2>, Vec3, Vec2>, Vec3, &M), - FT: for<'r> FnMut(&'r mut D, Vec3, u8, u8) -> <::Surface as gfx::format::SurfaceTyped>::DataType + 'a, + FT: for<'r> FnMut(&'r mut D, Vec3, u8, u8) -> [u8; 4] + 'a, { span!(_guard, "push", "GreedyMesh::push"); let cont = greedy_mesh( @@ -211,7 +211,7 @@ where FO: for<'r> FnMut(&'r mut D, Vec3) -> bool + 'a, FS: for<'r> FnMut(&'r mut D, Vec3, Vec3, Vec2>) -> Option<(bool, M)>, FP: FnMut(Vec2, Vec2>, Vec3, Vec2>, Vec3, &M), - FT: for<'r> FnMut(&'r mut D, Vec3, u8, u8) -> <::Surface as gfx::format::SurfaceTyped>::DataType + 'a, + FT: for<'r> FnMut(&'r mut D, Vec3, u8, u8) -> [u8; 4] + 'a, { span!(_guard, "greedy_mesh"); // TODO: Collect information to see if we can choose a good value here. diff --git a/voxygen/src/render/pipelines/clouds.rs b/voxygen/src/render/pipelines/clouds.rs index eef0f226be..b657e2dcd1 100644 --- a/voxygen/src/render/pipelines/clouds.rs +++ b/voxygen/src/render/pipelines/clouds.rs @@ -148,7 +148,7 @@ impl CloudsPipeline { layout: &CloudsLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "CloudsPipeline::new"); + common_base::span!(_guard, "CloudsPipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Clouds pipeline layout"), diff --git a/voxygen/src/render/pipelines/figure.rs b/voxygen/src/render/pipelines/figure.rs index 3f1b82f4e6..799f42087f 100644 --- a/voxygen/src/render/pipelines/figure.rs +++ b/voxygen/src/render/pipelines/figure.rs @@ -178,7 +178,7 @@ impl FigurePipeline { layout: &FigureLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "FigurePipeline::new"); + common_base::span!(_guard, "FigurePipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Figure pipeline layout"), diff --git a/voxygen/src/render/pipelines/fluid.rs b/voxygen/src/render/pipelines/fluid.rs index 219c5561f9..a8a8fa55b9 100644 --- a/voxygen/src/render/pipelines/fluid.rs +++ b/voxygen/src/render/pipelines/fluid.rs @@ -121,7 +121,7 @@ impl FluidPipeline { terrain_layout: &TerrainLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "FluidPipeline::new"); + common_base::span!(_guard, "FluidPipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Fluid pipeline layout"), diff --git a/voxygen/src/render/pipelines/particle.rs b/voxygen/src/render/pipelines/particle.rs index 2653782216..009589a290 100644 --- a/voxygen/src/render/pipelines/particle.rs +++ b/voxygen/src/render/pipelines/particle.rs @@ -181,7 +181,7 @@ impl ParticlePipeline { global_layout: &GlobalsLayouts, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "ParticlePipeline::new"); + common_base::span!(_guard, "ParticlePipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Particle pipeline layout"), diff --git a/voxygen/src/render/pipelines/postprocess.rs b/voxygen/src/render/pipelines/postprocess.rs index c367eb168e..09ec66baba 100644 --- a/voxygen/src/render/pipelines/postprocess.rs +++ b/voxygen/src/render/pipelines/postprocess.rs @@ -116,7 +116,7 @@ impl PostProcessPipeline { layout: &PostProcessLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "PostProcessPipeline::new"); + common_base::span!(_guard, "PostProcessPipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Post process pipeline layout"), diff --git a/voxygen/src/render/pipelines/shadow.rs b/voxygen/src/render/pipelines/shadow.rs index 9a01faaf32..56ba0ff024 100644 --- a/voxygen/src/render/pipelines/shadow.rs +++ b/voxygen/src/render/pipelines/shadow.rs @@ -137,7 +137,7 @@ impl ShadowFigurePipeline { figure_layout: &FigureLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "new"); + common_base::span!(_guard, "new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { diff --git a/voxygen/src/render/pipelines/skybox.rs b/voxygen/src/render/pipelines/skybox.rs index f682ba9472..c041c89d90 100644 --- a/voxygen/src/render/pipelines/skybox.rs +++ b/voxygen/src/render/pipelines/skybox.rs @@ -39,7 +39,7 @@ impl SkyboxPipeline { layouts: &GlobalsLayouts, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "SkyboxPipeline::new"); + common_base::span!(_guard, "SkyboxPipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Skybox pipeline layout"), diff --git a/voxygen/src/render/pipelines/sprite.rs b/voxygen/src/render/pipelines/sprite.rs index f07f52e41e..442fe16648 100644 --- a/voxygen/src/render/pipelines/sprite.rs +++ b/voxygen/src/render/pipelines/sprite.rs @@ -212,7 +212,7 @@ impl SpritePipeline { terrain_layout: &TerrainLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "SpritePipeline::new"); + common_base::span!(_guard, "SpritePipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Sprite pipeline layout"), diff --git a/voxygen/src/render/pipelines/terrain.rs b/voxygen/src/render/pipelines/terrain.rs index 54eb29e3c4..f9ff492229 100644 --- a/voxygen/src/render/pipelines/terrain.rs +++ b/voxygen/src/render/pipelines/terrain.rs @@ -212,7 +212,7 @@ impl TerrainPipeline { layout: &TerrainLayout, aa_mode: AaMode, ) -> Self { - common::span!(_guard, "TerrainPipeline::new"); + common_base::span!(_guard, "TerrainPipeline::new"); let render_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("Terrain pipeline layout"), diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 8efa2bc220..7aa4672650 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -67,10 +67,10 @@ impl assets::Compound for Shaders { "include.cloud.none", "include.cloud.regular", "figure-vert", - "light-shadows-vert", - "light-shadows-directed-vert", "light-shadows-figure-vert", + "light-shadows-directed-vert", "light-shadows-directed-frag", + "point-light-shadows-vert", "skybox-vert", "skybox-frag", "figure-frag", @@ -97,7 +97,7 @@ impl assets::Compound for Shaders { ]; let shaders = shaders - .into_iter() + .iter() .map(|shader| { let full_specifier = ["voxygen.shaders.", shader].concat(); let asset = AssetExt::load(&full_specifier)?; @@ -327,7 +327,6 @@ impl Renderer { | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER | wgpu::Features::PUSH_CONSTANTS, limits, - shader_validation: true, }, None, ))?; @@ -780,6 +779,7 @@ impl Renderer { }); let mut clear = |tex: &Texture| { encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("Clear dummy shadow texture"), color_attachments: &[], depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor { attachment: &tex.view, @@ -2135,7 +2135,10 @@ fn create_pipelines( }); let mut create_shader = |name, kind| { - let glsl = &shaders.get(name).unwrap().0; + let glsl = &shaders + .get(name) + .unwrap_or_else(|| panic!("Can't retrieve shader: {}", name)) + .0; let file_name = format!("{}.glsl", name); create_shader_module(device, &mut compiler, glsl, kind, &file_name, &options) }; @@ -2359,6 +2362,6 @@ fn create_shader_module( Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor { label: Some(source), source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())), - experimental_translation: false, + flags: wgpu::ShaderFlags::VALIDATION, })) } diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index efd764eac1..837a44146b 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -43,6 +43,7 @@ impl<'a> Drawer<'a> { .as_mut() .unwrap() .begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("shadow pass"), color_attachments: &[], depth_stencil_attachment: Some( wgpu::RenderPassDepthStencilAttachmentDescriptor { @@ -74,6 +75,7 @@ impl<'a> Drawer<'a> { .as_mut() .unwrap() .begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("first pass"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &self.renderer.tgt_color_view, resolve_target: None, @@ -109,6 +111,7 @@ impl<'a> Drawer<'a> { .as_mut() .unwrap() .begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("second pass (clouds)"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &self.renderer.tgt_color_pp_view, resolve_target: None, @@ -135,6 +138,7 @@ impl<'a> Drawer<'a> { .as_mut() .unwrap() .begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("third pass (postprocess + ui)"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &self.tex.view, resolve_target: None, @@ -180,11 +184,13 @@ impl<'a> Drawer<'a> { array_layer_count: NonZeroU32::new(1), }); + let label = format!("point shadow face: {} pass", face); let mut render_pass = self.encoder .as_mut() .unwrap() .begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some(&label), color_attachments: &[], depth_stencil_attachment: Some( wgpu::RenderPassDepthStencilAttachmentDescriptor { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e667394b11..788f4142d2 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -4772,9 +4772,9 @@ impl FigureMgr { ) .join() // 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)) // Don't render player - .filter(|(entity, _, _, _, _)| *entity != player_entity) + .filter(|(entity, _, _, _, _, _)| *entity != player_entity) { if let Some((bound, model, col_lights)) = self.get_model_for_render( tick, diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 907ba2ff54..6337aa391d 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -740,14 +740,10 @@ impl Scene { v_p.z = 0.0; v_p.normalize(); let l_r: math::Mat4 = if factor > EPSILON_UPSILON { -<<<<<<< HEAD - math::Mat4::look_at_rh(math::Vec3::zero(), -math::Vec3::unit_z(), v_p) -======= // NOTE: Our coordinates are now in left-handed space, but v_p isn't; however, // v_p has no z component, so we don't have to adjust it for left-handed // spaces. - math::Mat4::look_at_lh(math::Vec3::zero(), math::Vec3::forward_lh(), v_p) ->>>>>>> 00820cebc (Fix directed shadows, mostly.) + math::Mat4::look_at_lh(math::Vec3::zero(), math::Vec3::unit_z(), v_p) } else { math::Mat4::identity() }; @@ -788,23 +784,23 @@ impl Scene { // moves from view-space (right-handed) to world-space (right-handed). let view_point = view_inv * math::Vec4::from_point( - math::Vec3::forward_rh() * p_z, /* + math::Vec4::unit_w() */ + -math::Vec3::unit_z() * p_z, /* + math::Vec4::unit_w() */ ); - let view_plane = view_mat.transposed() * math::Vec4::forward_rh(); + let view_plane = view_mat.transposed() * -math::Vec4::unit_z(); // moves from rotated light space (left-handed) to world space (right-handed). let light_point = light_all_inv * math::Vec4::from_point( - math::Vec3::up() * p_y, /* + math::Vec4::unit_w() */ + math::Vec3::unit_y() * p_y, /* + math::Vec4::unit_w() */ ); - let light_plane = light_all_mat.transposed() * math::Vec4::up(); + let light_plane = light_all_mat.transposed() * math::Vec4::unit_y(); // moves from rotated light space (left-handed) to world space (right-handed). let shadow_point = light_all_inv * math::Vec4::from_point( - math::Vec3::right() * p_x, /* + math::Vec4::unit_w() */ + math::Vec3::unit_x() * p_x, /* + math::Vec4::unit_w() */ ); - let shadow_plane = light_all_mat.transposed() * math::Vec4::right(); + let shadow_plane = light_all_mat.transposed() * math::Vec4::unit_x(); // Find the point at the intersection of the three planes; note that since the // equations are already in right-handed world space, we don't need to negate @@ -848,8 +844,8 @@ impl Scene { // NOTE: I don't think the w component should be anything but 1 here, but // better safe than sorry. ( - f64::from(z0.homogenized().dot(math::Vec4::forward_rh())), - f64::from(z1.homogenized().dot(math::Vec4::forward_rh())), + f64::from(z0.homogenized().dot(-math::Vec4::unit_z())), + f64::from(z1.homogenized().dot(-math::Vec4::unit_z())), ) };