From c34cde210295c43cc90519bd024277cb469ed5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 15 Apr 2024 10:07:28 +0200 Subject: [PATCH] gfx: centralise model shading init --- engine/joint/v4k.h | 15 +-------------- engine/split/v4k_render.c | 15 +-------------- engine/v4k.c | 15 +-------------- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 0f37343..9ae207e 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -386385,18 +386385,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { model_set_renderstates(&m); const char *ptr = (const char *)mem; - // can't cache shader programs since we enable features via flags here - // static int shaderprog = -1; - // if( shaderprog < 0 ) { - 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", - va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); - // } - // ASSERT(shaderprog > 0); - iqm_t *q = CALLOC(1, sizeof(iqm_t)); - m.program = shaderprog; int error = 1; if( ptr && len ) { @@ -386456,9 +386445,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { glGenBuffers(1, &m.vao_instanced); model_set_state(m); - if (flags & MODEL_PBR) { - model_shading(&m, SHADING_PBR); - } + model_shading(&m, (flags & MODEL_PBR) ? SHADING_PBR : SHADING_PHONG); } return m; } diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 576f747..531f89f 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -3780,18 +3780,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { model_set_renderstates(&m); const char *ptr = (const char *)mem; - // can't cache shader programs since we enable features via flags here - // static int shaderprog = -1; - // if( shaderprog < 0 ) { - 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", - va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); - // } - // ASSERT(shaderprog > 0); - iqm_t *q = CALLOC(1, sizeof(iqm_t)); - m.program = shaderprog; int error = 1; if( ptr && len ) { @@ -3851,9 +3840,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { glGenBuffers(1, &m.vao_instanced); model_set_state(m); - if (flags & MODEL_PBR) { - model_shading(&m, SHADING_PBR); - } + model_shading(&m, (flags & MODEL_PBR) ? SHADING_PBR : SHADING_PHONG); } return m; } diff --git a/engine/v4k.c b/engine/v4k.c index f0f5a59..4361fda 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -20954,18 +20954,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { model_set_renderstates(&m); const char *ptr = (const char *)mem; - // can't cache shader programs since we enable features via flags here - // static int shaderprog = -1; - // if( shaderprog < 0 ) { - 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", - va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); - // } - // ASSERT(shaderprog > 0); - iqm_t *q = CALLOC(1, sizeof(iqm_t)); - m.program = shaderprog; int error = 1; if( ptr && len ) { @@ -21025,9 +21014,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { glGenBuffers(1, &m.vao_instanced); model_set_state(m); - if (flags & MODEL_PBR) { - model_shading(&m, SHADING_PBR); - } + model_shading(&m, (flags & MODEL_PBR) ? SHADING_PBR : SHADING_PHONG); } return m; }