From 038386ef2da8d9714a1d079ba30071811f9dec39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Thu, 18 Apr 2024 01:42:40 +0200 Subject: [PATCH] new: frame_time uniform --- engine/joint/v4k.h | 9 ++++++++- engine/split/v4k_render.c | 9 ++++++++- engine/v4k.c | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 6aec453..9c5c716 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -385942,6 +385942,14 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, if ((loc = glGetUniformLocation(shader, "u_matcaps")) >= 0) { glUniform1i(loc, m.flags & MODEL_MATCAPS ? GL_TRUE:GL_FALSE); } + + if ((loc = glGetUniformLocation(shader, "frame_count")) >= 0) { + glUniform1i(loc, (unsigned)window_frame()); + } + + if ((loc = glGetUniformLocation(shader, "frame_time")) >= 0) { + glUniform1f(loc, (float)window_time()); + } if (m.shading == SHADING_PBR) { handle old_shader = last_shader; @@ -385961,7 +385969,6 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, shader_texture( "tex_skyenv", m.sky_env ); } shader_texture( "tex_brdf_lut", brdf_lut() ); - shader_uint( "frame_count", (unsigned)window_frame() ); shader_bind(old_shader); } } diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 27b72d5..9b6a0fb 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -3308,6 +3308,14 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, if ((loc = glGetUniformLocation(shader, "u_matcaps")) >= 0) { glUniform1i(loc, m.flags & MODEL_MATCAPS ? GL_TRUE:GL_FALSE); } + + if ((loc = glGetUniformLocation(shader, "frame_count")) >= 0) { + glUniform1i(loc, (unsigned)window_frame()); + } + + if ((loc = glGetUniformLocation(shader, "frame_time")) >= 0) { + glUniform1f(loc, (float)window_time()); + } if (m.shading == SHADING_PBR) { handle old_shader = last_shader; @@ -3327,7 +3335,6 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, shader_texture( "tex_skyenv", m.sky_env ); } shader_texture( "tex_brdf_lut", brdf_lut() ); - shader_uint( "frame_count", (unsigned)window_frame() ); shader_bind(old_shader); } } diff --git a/engine/v4k.c b/engine/v4k.c index 4bb1622..bb35a45 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -20481,6 +20481,14 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, if ((loc = glGetUniformLocation(shader, "u_matcaps")) >= 0) { glUniform1i(loc, m.flags & MODEL_MATCAPS ? GL_TRUE:GL_FALSE); } + + if ((loc = glGetUniformLocation(shader, "frame_count")) >= 0) { + glUniform1i(loc, (unsigned)window_frame()); + } + + if ((loc = glGetUniformLocation(shader, "frame_time")) >= 0) { + glUniform1f(loc, (float)window_time()); + } if (m.shading == SHADING_PBR) { handle old_shader = last_shader; @@ -20500,7 +20508,6 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, shader_texture( "tex_skyenv", m.sky_env ); } shader_texture( "tex_brdf_lut", brdf_lut() ); - shader_uint( "frame_count", (unsigned)window_frame() ); shader_bind(old_shader); } }