From ccc6a06a8d4504d6b9f7af7905a414d2ee06ab76 Mon Sep 17 00:00:00 2001 From: Joshua Yanovski Date: Sat, 4 Jul 2020 18:04:34 +0200 Subject: [PATCH] Some minor changes. --- assets/voxygen/shaders/fluid-frag/shiny.glsl | 2 +- .../shaders/include/cloud/regular.glsl | 1 + voxygen/src/scene/figure/mod.rs | 49 +++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/assets/voxygen/shaders/fluid-frag/shiny.glsl b/assets/voxygen/shaders/fluid-frag/shiny.glsl index 896def6be8..5b3bc58fa1 100644 --- a/assets/voxygen/shaders/fluid-frag/shiny.glsl +++ b/assets/voxygen/shaders/fluid-frag/shiny.glsl @@ -281,7 +281,7 @@ void main() { // diffuse_light += point_light; // reflected_light += point_light; // vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light; - vec3 surf_color = illuminate(max_light, view_dir, emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflected_light/* * log(1.0 - MU_WATER)*/); + vec3 surf_color = illuminate(max_light, view_dir, emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * reflected_light/* * log(1.0 - MU_WATER)*/); // passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera)); /* surf_color = cam_attenuation.g < 0.5 ? diff --git a/assets/voxygen/shaders/include/cloud/regular.glsl b/assets/voxygen/shaders/include/cloud/regular.glsl index 60370f43ca..6e9ef6d947 100644 --- a/assets/voxygen/shaders/include/cloud/regular.glsl +++ b/assets/voxygen/shaders/include/cloud/regular.glsl @@ -45,6 +45,7 @@ vec2 cloud_at(vec3 pos) { vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) { const int ITERS = 12; const float INCR = 1.0 / ITERS; + origin = origin + focus_off.xyz; vec3 max_heights = get_cloud_heights(); float mind = (max_heights.y - origin.z) / dir.z; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 1bd16b82af..f85a1e643f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -440,32 +440,6 @@ impl FigureMgr { .map(|i| (Pos(i.pos), *i.ori)) .unwrap_or((*pos, Vec3::unit_y())); - // Don't display figures outside the frustum spectrum (this is important to do - // for any figure that potentially casts a shadow, since we use this - // to estimate bounds for shadow maps). The reason we do this - // before the udpate cull is to make sure infrequently updated - // figures are not clipped when they're visible; the vd_frac part is - // delayed until after that test to limit program pauses from too many - // figures being removed at once (rather than their being removed based on their - // update rates). - let radius = scale.unwrap_or(&Scale(1.0)).0 * 2.0; - let (in_frustum, lpindex) = if let Some(mut meta) = self.states.get_mut(body, &entity) { - let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), radius) - .coherent_test_against_frustum(frustum, meta.lpindex); - meta.visible = in_frustum; - meta.lpindex = lpindex; - (in_frustum, lpindex) - } else { - (true, 0) - }; - if in_frustum { - // Update visible bounds. - visible_aabb.expand_to_contain(Aabb { - min: pos.0 - radius, - max: pos.0 + radius, - }); - } - // Maintaining figure data and sending new figure data to the GPU turns out to // be a very expensive operation. We want to avoid doing it as much // as possible, so we make the assumption that players don't care so @@ -502,6 +476,29 @@ impl FigureMgr { continue; } + // Don't display figures outside the frustum spectrum (this is important to do + // for any figure that potentially casts a shadow, since we use this + // to estimate bounds for shadow maps). Currently, we don't do this before the update + // cull, so it's possible that faraway figures will not shadow correctly until their + // next update. For now, we treat this as an acceptable tradeoff. + let radius = scale.unwrap_or(&Scale(1.0)).0 * 2.0; + let (in_frustum, lpindex) = if let Some(mut meta) = self.states.get_mut(body, &entity) { + let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), radius) + .coherent_test_against_frustum(frustum, meta.lpindex); + meta.visible = in_frustum; + meta.lpindex = lpindex; + (in_frustum, lpindex) + } else { + (true, 0) + }; + if in_frustum { + // Update visible bounds. + visible_aabb.expand_to_contain(Aabb { + min: pos.0 - radius, + max: pos.0 + radius, + }); + } + // Change in health as color! let col = stats .map(|s| {