From fe24c0c5e7149aa528cc02448ad317b5d2f05869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 2 Dec 2023 10:58:18 +0100 Subject: [PATCH] improve lmap data --- MAKE.bat | 7 ++++++- engine/art/shaders/fs_32_4_model.glsl | 2 +- engine/art/shaders/vs_323444143_16_3322_model.glsl | 2 +- engine/v4k.c | 14 +++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/MAKE.bat b/MAKE.bat index 8abbe5d..6e259f9 100644 --- a/MAKE.bat +++ b/MAKE.bat @@ -218,8 +218,13 @@ if "%1"=="push" ( if "%2"=="dp" ( call MAKE.bat dpush auto ) - git add . + rem git add . git commit + git diff --quiet --exit-code --cached + if !ERRORLEVEL! neq 0 ( + echo Commit was cancelled or failed + exit /b %ERRORLEVEL% + ) if not "%2"=="local" ( git push ) diff --git a/engine/art/shaders/fs_32_4_model.glsl b/engine/art/shaders/fs_32_4_model.glsl index a2bd091..9a4d624 100644 --- a/engine/art/shaders/fs_32_4_model.glsl +++ b/engine/art/shaders/fs_32_4_model.glsl @@ -178,7 +178,7 @@ void main() { } if (u_texlit) { - vec4 litsample = texture(u_lightmap, v_texcoord); + vec4 litsample = texture(u_lightmap, v_texcoord2); if (u_texmod) { diffuse.rgb *= litsample.rgb; diff --git a/engine/art/shaders/vs_323444143_16_3322_model.glsl b/engine/art/shaders/vs_323444143_16_3322_model.glsl index b9e94c2..00bc7bc 100644 --- a/engine/art/shaders/vs_323444143_16_3322_model.glsl +++ b/engine/art/shaders/vs_323444143_16_3322_model.glsl @@ -56,8 +56,8 @@ in vec4 att_indexes; // @fixme: gles might use ivec4 instead? in vec4 att_weights; // @todo: downgrade from float to byte in float att_vertexindex; // for blendshapes in vec4 att_color; -in vec3 att_bitangent; // @todo: remove? also, ass2iqe might output this in vec2 att_texcoord2; +in vec3 att_bitangent; // @todo: remove? also, ass2iqe might output this out vec4 v_color; out vec3 v_position, v_position_ws; out vec3 v_normal, v_normal_ws; diff --git a/engine/v4k.c b/engine/v4k.c index 97bbfbb..dbcc024 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -19876,6 +19876,10 @@ void model_set_state(model_t m) { glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,color) ); glEnableVertexAttribArray(11); + // lmap data + glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) ); + glEnableVertexAttribArray(12); + // animation if(numframes > 0) { glVertexAttribPointer( 8, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,blendindexes) ); @@ -19911,10 +19915,6 @@ void model_set_state(model_t m) { glVertexAttribDivisor(7, 1); } - // lmap data - glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) ); - glEnableVertexAttribArray(12); - // 7 bitangent? into texcoord.z? glBindVertexArray( 0 ); @@ -20270,7 +20270,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { // 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", + "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor", va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); // } // ASSERT(shaderprog > 0); @@ -20679,7 +20679,7 @@ lightmap_t lightmap(int hmsize, float cnear, float cfar, vec3 color, int passes, const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM lm.shader = 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", + "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor", va("%s", "LIGHTMAP_BAKING")); return lm; @@ -20726,7 +20726,7 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm lmSetGeometry(lm->ctx, m->pivot, LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, position), sizeof(iqm_vertex), LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, normal), sizeof(iqm_vertex), - LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, texcoord), sizeof(iqm_vertex), + LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, texcoord2), sizeof(iqm_vertex), m->num_tris*3, LM_UNSIGNED_INT, m->tris); glDisable(GL_BLEND);