From cea7636e29065d3a5f88b4fd32ad3332143c2238 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 18 Oct 2023 21:20:15 +0100 Subject: [PATCH] Reverted bad shader changes --- assets/voxygen/shaders/include/lod.glsl | 11 ++++++----- assets/voxygen/shaders/sprite-vert.glsl | 17 +++++++++++++++-- assets/voxygen/shaders/terrain-vert.glsl | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/assets/voxygen/shaders/include/lod.glsl b/assets/voxygen/shaders/include/lod.glsl index e6528643fc..76d26f9a51 100644 --- a/assets/voxygen/shaders/include/lod.glsl +++ b/assets/voxygen/shaders/include/lod.glsl @@ -78,12 +78,13 @@ vec4 textureBicubic(texture2D tex, sampler sampl, vec2 texCoords) { } vec4 textureMaybeBicubic(texture2D tex, sampler sampl, vec2 texCoords) { - #if (CLOUD_MODE >= CLOUD_MODE_HIGH) + // TODO: Allow regular `texture` to be used when cause of light leaking issues is found + //#if (CLOUD_MODE >= CLOUD_MODE_HIGH) return textureBicubic(tex, sampl, texCoords); - #else - vec2 offset = (texCoords + vec2(-1.0, 0.5)) / textureSize(sampler2D(tex, sampl), 0); - return texture(sampler2D(tex, sampl), offset); - #endif + //#else + // vec2 offset = (texCoords + vec2(-1.0, 0.5)) / textureSize(sampler2D(tex, sampl), 0); + // return texture(sampler2D(tex, sampl), offset); + //#endif } // 16 bit version (each of the 2 8-bit components are combined after bilinear sampling) diff --git a/assets/voxygen/shaders/sprite-vert.glsl b/assets/voxygen/shaders/sprite-vert.glsl index 770f12f928..8ef62e8945 100644 --- a/assets/voxygen/shaders/sprite-vert.glsl +++ b/assets/voxygen/shaders/sprite-vert.glsl @@ -111,7 +111,13 @@ void main() { uint v_atlas_pos = pos_atlas_pos_norm_ao.y; // Expand the model vertex position bits into float values - vec3 v_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 8, 16)) & uvec3(0xFFu, 0xFFu, 0x0FFFu)) - ivec3(VERT_EXTRA_NEG_XY, VERT_EXTRA_NEG_XY, VERT_EXTRA_NEG_Z)); + // TODO: Use this instead, see [https://gitlab.com/veloren/veloren/-/merge_requests/3091] + //vec3 v_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 8, 16)) & uvec3(0xFFu, 0xFFu, 0x0FFFu)) - ivec3(VERT_EXTRA_NEG_XY, VERT_EXTRA_NEG_XY, VERT_EXTRA_NEG_Z)); + vec3 v_pos = vec3( + float(v_pos_norm & 0xFFu) - VERT_EXTRA_NEG_XY, + float((v_pos_norm >> 8) & 0xFFu) - VERT_EXTRA_NEG_XY, + float((v_pos_norm >> 16) & 0x0FFFu) - VERT_EXTRA_NEG_Z + ); // Position of the sprite block in the chunk // Used for highlighting the selected sprite, and for opening doors @@ -188,7 +194,14 @@ void main() { // Shader@0x000001AABD89BEE0(112,43-53): error X4576: Input array signature parameter cannot be indexed dynamically. //vec3 norm = (inst_mat[(v_pos_norm >> 30u) & 3u].xyz); uint index = v_pos_norm >> 30u & 3u; - vec3 norm = (inst_mat[index].xyz); + vec3 norm; + if (index == 0) { + norm = (inst_mat[0].xyz); + } else if (index == 1) { + norm = (inst_mat[1].xyz); + } else { + norm = (inst_mat[2].xyz); + } f_norm = normalize(mix(-norm, norm, v_pos_norm >> 29u & 1u)); diff --git a/assets/voxygen/shaders/terrain-vert.glsl b/assets/voxygen/shaders/terrain-vert.glsl index b6a2c3771c..96e7fb4cb5 100644 --- a/assets/voxygen/shaders/terrain-vert.glsl +++ b/assets/voxygen/shaders/terrain-vert.glsl @@ -71,7 +71,9 @@ const float EXTRA_NEG_Z = 32768.0; void main() { // over it (if this vertex to see if it intersects. - vec3 f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0xFFFFu)) - ivec3(0, 0, EXTRA_NEG_Z)); + // TODO: Use the following, see [https://gitlab.com/veloren/veloren/-/merge_requests/3091] + //vec3 f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0xFFFFu)) - ivec3(0, 0, EXTRA_NEG_Z)); + vec3 f_chunk_pos = vec3(v_pos_norm & 0x3Fu, (v_pos_norm >> 6) & 0x3Fu, float((v_pos_norm >> 12) & 0xFFFFu) - EXTRA_NEG_Z); f_pos = (model_mat * vec4(f_chunk_pos, 1.0)).xyz - focus_off.xyz;