From e7726f61dec04e1c5882f5dde376fd43dd090294 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 6 Jul 2020 22:41:21 +0100 Subject: [PATCH] Fixed sprite select flickering --- assets/voxygen/shaders/include/srgb.glsl | 10 +++++++++- assets/voxygen/shaders/sprite-vert.glsl | 2 +- voxygen/src/session.rs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/voxygen/shaders/include/srgb.glsl b/assets/voxygen/shaders/include/srgb.glsl index 4eaf579e17..a56a97b384 100644 --- a/assets/voxygen/shaders/include/srgb.glsl +++ b/assets/voxygen/shaders/include/srgb.glsl @@ -5,4 +5,12 @@ vec3 srgb_to_linear(vec3 srgb) { vec3 lower = srgb/vec3(12.92); return mix(higher, lower, cutoff); -} \ No newline at end of file +} + +vec3 linear_to_srgb(vec3 linear) { + bvec3 cutoff = lessThan(linear, vec3(0.0031308)); + vec3 higher = vec3(1.055) * pow(linear, vec3(1.0 / 2.4)) - vec3(0.055); + vec3 lower = linear * vec3(12.92); + + return mix(higher, lower, cutoff); +} diff --git a/assets/voxygen/shaders/sprite-vert.glsl b/assets/voxygen/shaders/sprite-vert.glsl index f22018bef3..11de3a8b2f 100644 --- a/assets/voxygen/shaders/sprite-vert.glsl +++ b/assets/voxygen/shaders/sprite-vert.glsl @@ -50,7 +50,7 @@ void main() { // Select glowing if (select_pos.w > 0 && select_pos.xyz == floor(sprite_pos)) { - f_col *= 4.0; + f_col = f_col * 8.0; } f_light = 1.0; diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 32e8609d0e..c22d4e81f8 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -249,7 +249,7 @@ impl PlayState for SessionState { { ( Some((cam_pos + cam_dir * (cam_dist - 0.01)).map(|e| e.floor() as i32)), - Some((cam_pos + cam_dir * cam_dist).map(|e| e.floor() as i32)), + Some((cam_pos + cam_dir * (cam_dist + 0.01)).map(|e| e.floor() as i32)), ) }, _ => (None, None),