From 2f49239a9fa7b897962c3ed033afb02a87a47245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Thu, 21 Mar 2024 07:47:28 +0100 Subject: [PATCH] improve shader binding for PBR --- engine/joint/v4k.h | 3 +++ engine/split/v4k_render.c | 3 +++ engine/v4k.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 163a215..8caf0d7 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -373021,6 +373021,8 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } if (m.shading == SHADING_PBR) { + handle old_shader = last_shader; + shader_bind(shader); shader_vec2( "resolution", vec2(window_width(),window_height())); bool has_tex_skysphere = m.sky_refl.id != texture_checker().id; @@ -373037,6 +373039,7 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } shader_texture( "tex_brdf_lut", brdf_lut() ); shader_uint( "frame_count", (unsigned)window_frame() ); + shader_bind(old_shader); } } static diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index c611361..e0f5f9a 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -2994,6 +2994,8 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } if (m.shading == SHADING_PBR) { + handle old_shader = last_shader; + shader_bind(shader); shader_vec2( "resolution", vec2(window_width(),window_height())); bool has_tex_skysphere = m.sky_refl.id != texture_checker().id; @@ -3010,6 +3012,7 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } shader_texture( "tex_brdf_lut", brdf_lut() ); shader_uint( "frame_count", (unsigned)window_frame() ); + shader_bind(old_shader); } } static diff --git a/engine/v4k.c b/engine/v4k.c index b9adbc5..0157d1d 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -20168,6 +20168,8 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } if (m.shading == SHADING_PBR) { + handle old_shader = last_shader; + shader_bind(shader); shader_vec2( "resolution", vec2(window_width(),window_height())); bool has_tex_skysphere = m.sky_refl.id != texture_checker().id; @@ -20184,6 +20186,7 @@ void model_set_uniforms(model_t m, int shader, mat44 mv, mat44 proj, mat44 view, } shader_texture( "tex_brdf_lut", brdf_lut() ); shader_uint( "frame_count", (unsigned)window_frame() ); + shader_bind(old_shader); } } static