From b7344c7298fb84399303eebe9f67785c9de57577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Tue, 7 Nov 2023 10:54:37 +0100 Subject: [PATCH] small billboarding changes --- demos/05-scene.c | 2 +- engine/art/shaders/vs_323444143_16_332_model.glsl | 11 +++++++---- engine/joint/v4k.h | 2 +- engine/split/v4k_render.c | 2 +- engine/v4k.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/demos/05-scene.c b/demos/05-scene.c index 8bcd5a4..fd00e77 100644 --- a/demos/05-scene.c +++ b/demos/05-scene.c @@ -7,7 +7,7 @@ int main() { // options bool do_twosided = 1; bool do_wireframe = 0; - bool do_billboard_x = 0, do_billboard_y = 0, do_billboard_z = 0; + bool do_billboard_x = 1, do_billboard_y = 1, do_billboard_z = 1; // window (80% sized, MSAA x4 flag) window_create(80, WINDOW_MSAA4); diff --git a/engine/art/shaders/vs_323444143_16_332_model.glsl b/engine/art/shaders/vs_323444143_16_332_model.glsl index 4575f1b..4e1044f 100644 --- a/engine/art/shaders/vs_323444143_16_332_model.glsl +++ b/engine/art/shaders/vs_323444143_16_332_model.glsl @@ -126,14 +126,17 @@ void main() { vec3 cameraPosition = -transpose(mat3(view)) * view[3].xyz; vec3 lookDir = normalize(cameraPosition - v_position_ws); - vec3 up = vec3(view[0][1], view[1][1], view[2][1]); + vec3 up = vec3(modelView[0][1], modelView[1][1], modelView[2][1]); vec3 right = normalize(cross(up, lookDir)); up = cross(lookDir, right); vec3 scale; - scale.x = length(vec3(att_instanced_matrix[0])); - scale.y = length(vec3(att_instanced_matrix[1])); - scale.z = length(vec3(att_instanced_matrix[2])); + scale.x = length(vec3(l_model[0])); + scale.y = length(vec3(l_model[1])); + scale.z = length(vec3(l_model[2])); + // scale.x *= sign(l_model[0][0]); + // scale.y *= sign(l_model[1][1]); + // scale.z *= sign(l_model[2][2]); mat4 billboardRotation = mat4( vec4(right * scale.x, 0.0), diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 8730108..3ac1df7 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -354485,7 +354485,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent","fragColor", va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); // } - // ASSERT(shaderprog > 0); + ASSERT(shaderprog > 0); iqm_t *q = CALLOC(1, sizeof(iqm_t)); m.program = shaderprog; diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 2f86bc3..79949ef 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -4398,7 +4398,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent","fragColor", va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); // } - // ASSERT(shaderprog > 0); + ASSERT(shaderprog > 0); iqm_t *q = CALLOC(1, sizeof(iqm_t)); m.program = shaderprog; diff --git a/engine/v4k.c b/engine/v4k.c index b33c16f..c3c3740 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -20562,7 +20562,7 @@ model_t model_from_mem(const void *mem, int len, int flags) { "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent","fragColor", va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); // } - // ASSERT(shaderprog > 0); + ASSERT(shaderprog > 0); iqm_t *q = CALLOC(1, sizeof(iqm_t)); m.program = shaderprog;