summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/pbr.c22
-rw-r--r--src/render/render_types.h5
2 files changed, 21 insertions, 6 deletions
diff --git a/src/render/pbr.c b/src/render/pbr.c
index 044e6eb..6ea5746 100644
--- a/src/render/pbr.c
+++ b/src/render/pbr.c
@@ -13,6 +13,7 @@
#include "render_types.h"
#include "shader_layouts.h"
+
void PBR_Init(PBR_Storage* storage) {
INFO("PBR shaders init");
storage->pbr_pass = PBR_RPassCreate();
@@ -144,12 +145,27 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te
Binding_Model model_data = { .model = renderable.affine };
GPU_EncodeBindShaderData(enc, 1, Binding_Model_GetLayout(&model_data));
+ // Skinning matrices
+
+ // 1. calculate matrices
AnimDataUniform anim_data = { 0 };
- for (int i = 0; i < 4; i++) {
- anim_data.bone_matrices[i] = mat4_ident();
+ CASSERT(renderable.armature);
+ Armature* skeleton = renderable.armature;
+ // Skip the first one as we assume its root for this test
+ for (int j_i = 1; j_i < skeleton->joints->len; j_i++) {
+ Joint* j = &skeleton->joints->data[j_i];
+ j->local_transform = transform_to_mat(&j->transform_components);
+ Mat4 m = mat4_mult(j->local_transform, j->inverse_bind_matrix);
+ Joint* p = &skeleton->joints->data[j->parent];
+ j->local_transform = mat4_mult(j->local_transform, p->local_transform);
+ printf("Quat %f \n", j->transform_components.rotation.z);
+ }
+
+ // 2. bind and upload
+ for (int j_i = 1; j_i < skeleton->joints->len; j_i++) {
+ anim_data.bone_matrices[j_i] = skeleton->joints->data[j_i].local_transform;
}
GPU_EncodeBindShaderData(enc, 3, AnimData_GetLayout(&anim_data));
- // Calculate matrices here
// set buffers
GPU_EncodeSetVertexBuffer(enc, mesh->vertex_buffer);
diff --git a/src/render/render_types.h b/src/render/render_types.h
index dd09896..16dee1d 100644
--- a/src/render/render_types.h
+++ b/src/render/render_types.h
@@ -135,9 +135,8 @@ typedef u32 RenderEntityFlags;
typedef struct RenderEnt {
MeshHandle mesh;
MaterialHandle material;
- AnimationClip animation_clip;
- bool is_playing;
- f32 t;
+ /** If NULL, no armature and the mesh is static geometry, else it is to be skinned */
+ Armature* armature;
Mat4 affine; // In the future this should be updated by the transform graph
Bbox_3D bounding_box;
RenderEntityFlags flags;