summaryrefslogtreecommitdiff
path: root/glsl
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2024-03-23 19:05:26 -0300
committerFrederico Linhares <fred@linhares.blue>2024-03-23 19:12:24 -0300
commit8acb4a0aad7f4d1b2438010d487489a9641e30cb (patch)
tree50a0fc3094e1d5e29a1fbcc8d7f94ffa2561fa84 /glsl
parentbf240d7eeaa89657462b705849fde56e54e237db (diff)
fixt Make skeletal mesh work properly
Diffstat (limited to 'glsl')
-rw-r--r--glsl/shader_3d_skeletal.vert.glsl26
1 files changed, 17 insertions, 9 deletions
diff --git a/glsl/shader_3d_skeletal.vert.glsl b/glsl/shader_3d_skeletal.vert.glsl
index 169e1af..c078db9 100644
--- a/glsl/shader_3d_skeletal.vert.glsl
+++ b/glsl/shader_3d_skeletal.vert.glsl
@@ -55,16 +55,24 @@ main()
{
vec4 position = vec4(0.0f);
vec3 normal = in_normal;
- for(int i = 0; i < MAX_NUM_OF_INFLUENCING_BONES; i++)
- {
- if(in_bone_weights[i] == 0.0)
- break;
+ if(in_bone_weights[0] == 0.0)
+ {
+ position = vec4(in_position, 1.0);
+ normal = mat3(ubo_skeletal_model.base_matrix) * in_normal;
+ }
+ else
+ {
+ for(int i = 0; i < MAX_NUM_OF_INFLUENCING_BONES; i++)
+ {
+ if(in_bone_weights[i] == 0.0) break;
- vec4 local_position = ubo_skeletal_model.bone_matrices[in_bone_ids[i]] *
- vec4(in_position, 1.0f);
- position += local_position * in_bone_weights[i];
- normal = mat3(ubo_skeletal_model.bone_matrices[in_bone_ids[i]]) * normal;
- }
+ vec4 local_position =
+ ubo_skeletal_model.bone_matrices[in_bone_ids[i]] *
+ vec4(in_position, 1.0f);
+ position += local_position * in_bone_weights[i];
+ normal = mat3(ubo_skeletal_model.bone_matrices[in_bone_ids[i]]) * normal;
+ }
+ }
mat4 view_model = ubo_view.view * ubo_skeletal_model.base_matrix;
gl_Position = ubo_view.proj * view_model * position;