From 76216f91aee936bc57d7e1a1b2c2b63a03ce976a Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:53:14 +1000 Subject: load pbr textures --- src/renderer/render.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/renderer/render.c') diff --git a/src/renderer/render.c b/src/renderer/render.c index 3a373dc..351a7e0 100644 --- a/src/renderer/render.c +++ b/src/renderer/render.c @@ -1,5 +1,6 @@ #include #include "maths_types.h" +#include "render_types.h" #define STB_IMAGE_IMPLEMENTATION #include @@ -260,3 +261,27 @@ texture_handle texture_data_upload(texture_data data, bool free_on_upload) { } return handle; } + +/** @brief load all of the texture for a PBR material and returns an unnamed material */ +material pbr_material_load(char* albedo_path, char* normal_path, bool metal_roughness_combined, + char* metallic_path, char* roughness_map, char* ao_map) { + material m = { 0 }; + m.kind = MAT_PBR; + + // For now we must have the required textures + assert(albedo_path); + assert(normal_path); + assert(metallic_path); + assert(metal_roughness_combined); + + m.mat_data.pbr.metal_roughness_combined = metal_roughness_combined; + texture_data tex_data; + tex_data = texture_data_load(albedo_path, false); + m.mat_data.pbr.albedo_map = texture_data_upload(tex_data, true); + tex_data = texture_data_load(normal_path, false); + m.mat_data.pbr.normal_map = texture_data_upload(tex_data, true); + tex_data = texture_data_load(metallic_path, false); + m.mat_data.pbr.metallic_map = texture_data_upload(tex_data, true); + + return m; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2