From d2582796a84f82536a55a9a0a518deb7d0306ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Tue, 26 Mar 2024 15:22:36 +0100 Subject: [PATCH] render: optimise pbr load --- engine/joint/v4k.h | 11 ++++------- engine/split/v4k_render.c | 11 ++++------- engine/v4k.c | 11 ++++------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 317f56e..cf3104b 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -373484,16 +373484,11 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, material_t mt = {0}; mt.name = STRDUP(&str[m->material]); - // initialise basic texture layer first + // initialise basic texture layer mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.color = material_color_hex ? material_color : vec4(1,1,1,1); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture = CALLOC(1, sizeof(texture_t)); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture->id = *out++; - // initialise PBR material workflow - if (_flags & MODEL_PBR) { - model_load_pbr(&mt); - } - array_push(model->materials, mt); } @@ -373905,7 +373900,9 @@ void model_shading(model_t *m, int shading) { } // rebind shader - // @fixme: destroy old shader program + // @fixme: app crashes rn + // glUseProgram(0); + // glDeleteProgram(m->program); const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 629a152..6fdd86e 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -3450,16 +3450,11 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, material_t mt = {0}; mt.name = STRDUP(&str[m->material]); - // initialise basic texture layer first + // initialise basic texture layer mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.color = material_color_hex ? material_color : vec4(1,1,1,1); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture = CALLOC(1, sizeof(texture_t)); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture->id = *out++; - // initialise PBR material workflow - if (_flags & MODEL_PBR) { - model_load_pbr(&mt); - } - array_push(model->materials, mt); } @@ -3871,7 +3866,9 @@ void model_shading(model_t *m, int shading) { } // rebind shader - // @fixme: destroy old shader program + // @fixme: app crashes rn + // glUseProgram(0); + // glDeleteProgram(m->program); const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", diff --git a/engine/v4k.c b/engine/v4k.c index 80e0939..e10cbd2 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -20624,16 +20624,11 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, material_t mt = {0}; mt.name = STRDUP(&str[m->material]); - // initialise basic texture layer first + // initialise basic texture layer mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.color = material_color_hex ? material_color : vec4(1,1,1,1); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture = CALLOC(1, sizeof(texture_t)); mt.layer[MATERIAL_CHANNEL_DIFFUSE].map.texture->id = *out++; - // initialise PBR material workflow - if (_flags & MODEL_PBR) { - model_load_pbr(&mt); - } - array_push(model->materials, mt); } @@ -21045,7 +21040,9 @@ void model_shading(model_t *m, int shading) { } // rebind shader - // @fixme: destroy old shader program + // @fixme: app crashes rn + // glUseProgram(0); + // glDeleteProgram(m->program); const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor",