diff --git a/.cargo/config b/.cargo/config index 4407be603f..c46e78f8c9 100644 --- a/.cargo/config +++ b/.cargo/config @@ -12,4 +12,4 @@ tracy-world-server = "-Zunstable-options run --bin veloren-server-cli --features test-voxygen = "run --bin veloren-voxygen --no-default-features --features gl,simd" tracy-voxygen = "-Zunstable-options run --bin veloren-voxygen --no-default-features --features tracy,gl,simd --profile no_overflow" server = "run --bin veloren-server-cli" - +dbg-voxygen = "run --bin veloren-voxygen -Zunstable-options --profile debuginfo" diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index e148c2595a..8cb717be95 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -42,16 +42,9 @@ uniform u_locals { layout(location = 0) out vec4 tgt_color; -float depth_at(vec2 uv) { - float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x; - vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0); - vec4 view_space = proj_mat_inv * clip_space; - view_space /= view_space.w; - return -view_space.z; -} vec3 wpos_at(vec2 uv) { - float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x * 2.0 - 1.0; + float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x; mat4 inv = view_mat_inv * proj_mat_inv;//inverse(all_mat); vec4 clip_space = vec4((uv * 2.0 - 1.0) * vec2(1, -1), buf_depth, 1.0); vec4 view_space = inv * clip_space; diff --git a/assets/voxygen/shaders/postprocess-frag.glsl b/assets/voxygen/shaders/postprocess-frag.glsl index cd14c0711d..2f05428ab7 100644 --- a/assets/voxygen/shaders/postprocess-frag.glsl +++ b/assets/voxygen/shaders/postprocess-frag.glsl @@ -149,30 +149,6 @@ vec3 _illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitte // return /*srgb_to_linear*/(/*0.5*//*0.125 * */vec3(pow(color.x, gamma), pow(color.y, gamma), pow(color.z, gamma))); } -/* -float depth_at(vec2 uv) { - float buf_depth = texture(src_depth, uv).x; - vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0); - vec4 view_space = proj_mat_inv * clip_space; - view_space /= view_space.w; - return -view_space.z; -} - -vec3 wpos_at(vec2 uv) { - float buf_depth = texture(src_depth, uv).x * 2.0 - 1.0; - mat4 inv = view_mat_inv * proj_mat_inv;//inverse(all_mat); - vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0); - vec4 view_space = inv * clip_space; - view_space /= view_space.w; - if (buf_depth == 1.0) { - vec3 direction = normalize(view_space.xyz); - return direction.xyz * 100000.0 + cam_pos.xyz; - } else { - return view_space.xyz; - } -} -*/ - void main() { // TODO: precompute in the vertex shader? vec2 uv = (f_pos + 1.0) * 0.5; diff --git a/assets/voxygen/shaders/skybox-vert.glsl b/assets/voxygen/shaders/skybox-vert.glsl index b6d56dce74..7b89d0aefd 100644 --- a/assets/voxygen/shaders/skybox-vert.glsl +++ b/assets/voxygen/shaders/skybox-vert.glsl @@ -23,19 +23,13 @@ layout(location = 0) in vec3 v_pos; layout(location = 0) out vec3 f_pos; void main() { - /* vec3 v_pos = v_pos; - v_pos.y = -v_pos.y; */ f_pos = v_pos; + // TODO: is this todo below still valid? is cam_pos jittery // TODO: Make this position-independent to avoid rounding error jittering gl_Position = - /* proj_mat * - view_mat * */ all_mat * - /* proj_mat * - view_mat * */ - vec4(/*100000 * */v_pos + cam_pos.xyz, 1); - // vec4(v_pos * (100000.0/* + 0.5*/) + cam_pos.xyz, 1); + vec4(v_pos + cam_pos.xyz, 1); // gl_Position = vec4(gl_Position.xy, sign(gl_Position.z) * gl_Position.w, gl_Position.w); gl_Position.z = gl_Position.w; // gl_Position.z = gl_Position.w - 0.000001;//0.0; diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index 0bdc3086b1..a949c07740 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -5,7 +5,7 @@ use super::{ instances::Instances, model::{DynamicModel, Model, SubModel}, pipelines::{ - clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, ColLights, + clouds, figure, fluid, particle, postprocess, skybox, sprite, terrain, ui, ColLights, GlobalsBindGroup, Light, Shadow, }, }, @@ -137,18 +137,12 @@ pub struct FirstPassDrawer<'a> { } impl<'a> FirstPassDrawer<'a> { - /*pub fn draw_skybox<'b: 'a>( - &mut self, - model: &'b Model, - globals: &'b Consts, - verts: Range, - ) { + pub fn draw_skybox<'b: 'a>(&mut self, model: &'b Model) { self.render_pass .set_pipeline(&self.renderer.skybox_pipeline.pipeline); - self.render_pass.set_bind_group(0, &globals.bind_group, &[]); - self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0); - self.render_pass.draw(verts, 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_figure<'b: 'a>( &mut self, diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index 196ca31e02..7bc8e2fa35 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -140,7 +140,7 @@ impl Camera { self.dependents.proj_mat_inv = self.dependents.proj_mat.inverted(); // TODO: Make this more efficient. - self.dependents.cam_pos = Vec3::from(self.dependents.view_mat.inverted() * Vec4::unit_w()); + self.dependents.cam_pos = Vec3::from(self.dependents.view_mat_inv * Vec4::unit_w()); self.frustum = Frustum::from_modelview_projection( (self.dependents.proj_mat * self.dependents.view_mat @@ -148,7 +148,7 @@ impl Camera { .into_col_arrays(), ); - self.dependents.cam_dir = Vec3::from(self.dependents.view_mat.inverted() * -Vec4::unit_z()); + self.dependents.cam_dir = Vec3::from(self.dependents.view_mat_inv * -Vec4::unit_z()); } pub fn frustum(&self) -> &Frustum { &self.frustum } diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 553f79a3be..7ded6b98d3 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -1034,7 +1034,7 @@ impl Scene { self.lod.render(renderer, global);*/ // Render the skybox. - // TODO: renderer.render_skybox(&self.skybox.model, global, lod); + drawer.draw_skybox(&self.skybox.model); /*self.terrain.render_translucent( renderer, diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index fb938ebe90..01da2effff 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -353,6 +353,10 @@ impl Scene { body: Option, inventory: Option<&Inventory>, ) { + // TODO: can probably be drawn last but it crashes when drawn first and we + // should figure that out + // drawer.draw_skybox(&self.skybox.model); + if let Some(body) = body { let model = &self.figure_model_cache.get_model( &self.col_lights,