summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/pbr.c34
-rw-r--r--src/render/render_types.h7
2 files changed, 26 insertions, 15 deletions
diff --git a/src/render/pbr.c b/src/render/pbr.c
index 57ca1d8..cfa02fc 100644
--- a/src/render/pbr.c
+++ b/src/render/pbr.c
@@ -1,4 +1,5 @@
#include "pbr.h"
+#include "animation.h"
#include "camera.h"
#include "core.h"
#include "file.h"
@@ -24,6 +25,12 @@ GPU_Renderpass* PBR_RPassCreate() {
}
void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) {
+ // Common shader bindings
+ ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL);
+ ShaderDataLayout model_data = Binding_Model_GetLayout(NULL);
+ ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL);
+ ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL);
+
// Static
{
const char* vert_path = "assets/shaders/static_geometry.vert";
@@ -31,11 +38,6 @@ void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) {
char* vert_shader = string_from_file(vert_path);
char* frag_shader = string_from_file(frag_path);
- ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL);
- ShaderDataLayout model_data = Binding_Model_GetLayout(NULL);
- ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL);
- ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL);
-
GraphicsPipelineDesc desc = {
.debug_name = "PBR (Static) Pipeline",
.vertex_desc = static_3d_vertex_description(),
@@ -60,14 +62,11 @@ void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) {
char* vert_shader = string_from_file(vert_path);
char* frag_shader = string_from_file(frag_path);
- ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL);
- ShaderDataLayout model_data = Binding_Model_GetLayout(NULL);
- ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL);
- ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL);
+ ShaderDataLayout anim_uniform = AnimData_GetLayout(NULL);
VertexDescription vertex_desc = { .debug_label = "Skinned vertices",
.use_full_vertex_size = true };
- VertexDesc_AddAttr(&vertex_desc, "inPos", ATTR_F32x3);
+ VertexDesc_AddAttr(&vertex_desc, "inPosition", ATTR_F32x3);
VertexDesc_AddAttr(&vertex_desc, "inNormal", ATTR_F32x3);
VertexDesc_AddAttr(&vertex_desc, "inTexCoords", ATTR_F32x2);
VertexDesc_AddAttr(&vertex_desc, "inBoneIndices", ATTR_I32x4);
@@ -76,8 +75,8 @@ void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) {
GraphicsPipelineDesc desc = {
.debug_name = "PBR (Skinned) Pipeline",
.vertex_desc = vertex_desc,
- .data_layouts = { camera_data, model_data, material_data, lights_data },
- .data_layouts_count = 4,
+ .data_layouts = { camera_data, model_data, material_data, lights_data, anim_uniform },
+ .data_layouts_count = 5,
.vs = { .debug_name = "PBR (textured) Vertex Shader",
.filepath = str8(vert_path),
.code = vert_shader },
@@ -102,7 +101,9 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te
GPU_CmdEncoder* enc = GPU_GetDefaultEncoder();
GPU_CmdEncoder_BeginRender(enc, storage->pbr_pass);
- GPU_EncodeBindPipeline(enc, storage->pbr_static_pipeline);
+
+ // TEMP: only do skinned
+ GPU_EncodeBindPipeline(enc, storage->pbr_skinned_pipeline);
// Feed shader data
Mat4 view, proj;
@@ -143,6 +144,13 @@ 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));
+ AnimDataUniform anim_data = {0};
+ for (int i =0; i < 4; i++) {
+ anim_data.bone_matrices[i] = mat4_ident();
+ }
+ GPU_EncodeBindShaderData(enc, 3, AnimData_GetLayout(&anim_data));
+ // Calculate matrices here
+
// set buffers
GPU_EncodeSetVertexBuffer(enc, mesh->vertex_buffer);
GPU_EncodeSetIndexBuffer(enc, mesh->index_buffer);
diff --git a/src/render/render_types.h b/src/render/render_types.h
index 5e2b282..dd09896 100644
--- a/src/render/render_types.h
+++ b/src/render/render_types.h
@@ -43,6 +43,7 @@ typedef struct Mesh {
Geometry geometry; // NULL means it has been freed CPU-side
MaterialHandle material;
bool is_skinned; // false = its static
+ Armature armature;
bool is_uploaded; // has the data been uploaded to the GPU
} Mesh;
#ifndef TYPED_MESH_CONTAINERS
@@ -96,8 +97,7 @@ typedef struct Model {
size_t mesh_count;
MaterialHandle* materials;
size_t material_count;
- Armature armature;
- bool has_joints;
+ arena anim_arena;
AnimationClip_darray* animations;
} Model;
#ifndef TYPED_MODEL_ARRAY
@@ -135,6 +135,9 @@ typedef u32 RenderEntityFlags;
typedef struct RenderEnt {
MeshHandle mesh;
MaterialHandle material;
+ AnimationClip animation_clip;
+ bool is_playing;
+ f32 t;
Mat4 affine; // In the future this should be updated by the transform graph
Bbox_3D bounding_box;
RenderEntityFlags flags;