summaryrefslogtreecommitdiff
path: root/glsl
diff options
context:
space:
mode:
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;