diff options
author | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-07 13:50:40 +1000 |
---|---|---|
committer | Omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-07 13:50:40 +1000 |
commit | 42924fe7b32e93bf55ce034467ceb52e0436c303 (patch) | |
tree | fbdf14de2bab718cadb6492d3774d33a0f50ff2f /assets | |
parent | d9f9479694d8a4d74822a876516282329db5ea3d (diff) |
visualising bone indices
Diffstat (limited to 'assets')
-rw-r--r-- | assets/shaders/blinn_phong.frag | 4 | ||||
-rw-r--r-- | assets/shaders/skinned.vert | 46 |
2 files changed, 32 insertions, 18 deletions
diff --git a/assets/shaders/blinn_phong.frag b/assets/shaders/blinn_phong.frag index 095b19a..adcc53e 100644 --- a/assets/shaders/blinn_phong.frag +++ b/assets/shaders/blinn_phong.frag @@ -33,6 +33,7 @@ in VS_OUT { vec3 Normal; vec2 TexCoords; vec4 FragPosLightSpace; + vec4 Color; } fs_in; // --- Uniforms @@ -55,7 +56,8 @@ void main() { result += CalcPointLight(pointLights[i], norm, fs_in.FragPos, viewDir); } - FragColor = vec4(result, 1.0); + // FragColor = vec4(result, 1.0); + FragColor = fs_in.Color + 0.5; } vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir) diff --git a/assets/shaders/skinned.vert b/assets/shaders/skinned.vert index 3d0c2cd..cb2ca85 100644 --- a/assets/shaders/skinned.vert +++ b/assets/shaders/skinned.vert @@ -13,7 +13,7 @@ uniform mat4 lightSpaceMatrix; const int MAX_BONES = 100; const int MAX_BONE_INFLUENCES = 4; -uniform mat4 finalBoneMatrices[MAX_BONES]; +uniform mat4 boneMatrices[MAX_BONES]; // TODO! // Output out VS_OUT { @@ -21,27 +21,39 @@ out VS_OUT { vec3 Normal; vec2 TexCoords; vec4 FragPosLightSpace; + vec4 Color; } vs_out; void main() { - vec4 totalPosition = vec4(0.0f); - for(int i = 0 ; i < MAX_BONE_INFLUENCES ; i++) { - if(inBoneIndices[i] == -1) - continue; - if(inBoneIndices[i] >=MAX_BONES) - { - totalPosition = vec4(inPos,1.0f); - break; - } - vec4 localPosition = finalBoneMatrices[inBoneIndices[i]] * vec4(inPos,1.0f); - totalPosition += localPosition * inWeights[i]; - vec3 localNormal = mat3(finalBoneMatrices[inBoneIndices[i]]) * inNormal; - vs_out.Normal = localNormal; - } - - vs_out.FragPos = vec3(model * vec4(inPos, 1.0)); + // vec4 totalPosition = vec4(0.0f); + // for(int i = 0 ; i < MAX_BONE_INFLUENCES ; i++) { + // if(inBoneIndices[i] == 0) + // continue; + // if(inBoneIndices[i] >=MAX_BONES) + // { + // totalPosition = vec4(inPos,1.0f); + // break; + // } + // vec4 localPosition = finalBoneMatrices[inBoneIndices[i]] * vec4(inPos,1.0f); + // totalPosition += localPosition * inWeights[i]; + // vec3 localNormal = mat3(finalBoneMatrices[inBoneIndices[i]]) * inNormal; + // vs_out.Normal = localNormal; + // } + + + mat4 skinMatrix = // mat4(1.0) + // boneMatrices[int(inBoneIndices.z)]; // should just be the identtiy + inWeights.x * boneMatrices[int(inBoneIndices.x)] + + inWeights.y * boneMatrices[int(inBoneIndices.y)] + + inWeights.z * boneMatrices[int(inBoneIndices.z)] + + inWeights.w * boneMatrices[int(inBoneIndices.w)]; + + vec4 totalPosition = skinMatrix * vec4(inPos, 1.0); + + vs_out.FragPos = vec3(model * totalPosition); // vs_out.Normal = inNormal; vs_out.TexCoords = inTexCoords; vs_out.FragPosLightSpace = lightSpaceMatrix * vec4(vs_out.FragPos, 1.0); + vs_out.Color = inWeights; gl_Position = projection * view * model * totalPosition; }
\ No newline at end of file |