From 4b5695ce26a8f821dfac987e8e11a6ba5eeff610 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Mon, 17 Jun 2024 22:17:48 +1000 Subject: start working on a immediate mode drawing API --- src/renderer/builtin_materials.h | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/renderer/builtin_materials.h') diff --git a/src/renderer/builtin_materials.h b/src/renderer/builtin_materials.h index 7748599..1a04f32 100644 --- a/src/renderer/builtin_materials.h +++ b/src/renderer/builtin_materials.h @@ -102,3 +102,56 @@ static void* shader_layout_get_binding(shader_data_layout* layout, u32 nth_bindi assert(nth_binding < layout->bindings_count); return &layout->bindings[nth_binding].data; } + +typedef struct pbr_textures { + texture_handle albedo_tex; + texture_handle metal_roughness_tex; + texture_handle ao_tex; + texture_handle normal_tex; +} pbr_textures; + +typedef struct pbr_textured_bindgroup { + mvp_matrix_uniforms mvp_matrices; + pbr_params_light_uniforms lights; + pbr_textures textures; +} pbr_textured_bindgroup; + +static shader_data_layout pbr_textured_shader_layout(void* data) { + pbr_textured_bindgroup* d = (pbr_textured_bindgroup*)data; + bool has_data = data != NULL; + + shader_binding b1 = { .label = "MVP_Matrices", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes = { .size = sizeof(mvp_matrix_uniforms) } } }; + + shader_binding b2 = { .label = "Scene_Lights", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes = { .size = sizeof(pbr_params_light_uniforms) } } }; + + shader_binding b3 = {.label = "Albedo", + .type = SHADER_BINDING_TEXTURE, + .stores_data = has_data }; + shader_binding b4 = {.label = "Metallic Roughness", + .type = SHADER_BINDING_TEXTURE, + .stores_data = has_data }; + shader_binding b5 = {.label = "Ambient Occlusion", + .type = SHADER_BINDING_TEXTURE, + .stores_data = has_data }; + shader_binding b6 = {.label = "Normal Vectors", + .type = SHADER_BINDING_TEXTURE, + .stores_data = has_data }; + + if (has_data) { + b1.data.bytes.data = &d->mvp_matrices; + b2.data.bytes.data = &d->lights; + b3.data.texture.handle = d->textures.albedo_tex; + b4.data.texture.handle = d->textures.metal_roughness_tex; + b5.data.texture.handle = d->textures.ao_tex; + b6.data.texture.handle = d->textures.normal_tex; + } + + return (shader_data_layout){ .name = "pbr_params", .bindings = { b1, b2, b3, b4, b5, b6 }, .bindings_count = 6 + }; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2