From 7c33e7d714adbb0111210b715dd257ab68356d70 Mon Sep 17 00:00:00 2001 From: Lippy13 Date: Mon, 31 Aug 2020 19:50:45 +0100 Subject: [PATCH] Work around an issue with Intel Gen7/7.5 GPUs where matrices default to being row major if they are not directly assigned to a matrix that has a column major layout. --- assets/voxygen/shaders/figure-vert.glsl | 7 ++++--- assets/voxygen/shaders/include/shadows.glsl | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/voxygen/shaders/figure-vert.glsl b/assets/voxygen/shaders/figure-vert.glsl index 43a9f5decc..cb4f4414b0 100644 --- a/assets/voxygen/shaders/figure-vert.glsl +++ b/assets/voxygen/shaders/figure-vert.glsl @@ -73,8 +73,9 @@ void main() { // Pre-calculate bone matrix /* uint bone_idx = (v_ao_bone >> 2) & 0x3Fu; */ uint bone_idx = (v_pos_norm >> 27) & 0xFu; - BoneData bone_data = bones[bone_idx]; - mat4 bone_mat = bone_data.bone_mat; + + mat4 bone_mat = bones[bone_idx].bone_mat; + mat4 normals_mat = bones[bone_idx].normals_mat; mat4 combined_mat = /*model_mat * */bone_mat; vec3 pos = (vec3((uvec3(v_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0; @@ -105,7 +106,7 @@ void main() { // vec3 norm = normals[normal_idx]; uint axis_idx = v_atlas_pos & 3u; - vec3 norm = bone_data.normals_mat[axis_idx].xyz; + vec3 norm = normals_mat[axis_idx].xyz; // norm = normalize(norm); // vec3 norm = norm_mat * vec4(uvec3(1 << axis_idx) & uvec3(0x1u, 0x3u, 0x7u), 1); diff --git a/assets/voxygen/shaders/include/shadows.glsl b/assets/voxygen/shaders/include/shadows.glsl index e5968a0a2a..ab63bf858f 100644 --- a/assets/voxygen/shaders/include/shadows.glsl +++ b/assets/voxygen/shaders/include/shadows.glsl @@ -154,8 +154,8 @@ float ShadowCalculationDirected(in vec3 fragPos)//in vec4 /*light_pos[2]*/sun_po } */ // vec3 fragPos = sun_pos.xyz;// / sun_pos.w;//light_pos[lightIndex].xyz; // sun_pos.z += sun_pos.w * bias; - ShadowLocals sun_shadow = shadowMats[0]; - vec4 sun_pos = sun_shadow.texture_mat * vec4(fragPos, 1.0); + mat4 texture_mat = shadowMats[0].texture_mat; + vec4 sun_pos = texture_mat * vec4(fragPos, 1.0); // sun_pos.z -= sun_pos.w * bias; float visibility = textureProj(t_directed_shadow_maps, sun_pos); /* float visibilityLeft = textureProj(t_directed_shadow_maps, sun_shadow.texture_mat * vec4(fragPos + vec3(0.0, -diskRadius, 0.0), 1.0));