From 3557b0c25545139b4a5adf0ba44cdac63bf77302 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 27 Nov 2023 11:50:19 +0000 Subject: [PATCH] fix vertex blend data --- scene.h | 7 +++---- shaders/scene_vertex_blend.h | 4 ++-- world_gen.c | 5 ++--- world_routes.c | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/scene.h b/scene.h index f448bbc..8aaafe9 100644 --- a/scene.h +++ b/scene.h @@ -73,8 +73,7 @@ void scene_supply_buffer( scene_context *ctx, void *buffer ) ctx->arrindices = (u32*)(((u8*)buffer) + vertex_length); } -static void scene_vert_pack_norm( scene_vert *vert, v3f norm ) -{ +static void scene_vert_pack_norm( scene_vert *vert, v3f norm, f32 blend ){ v3f n; v3_muls( norm, 127.0f, n ); v3_minv( n, (v3f){ 127.0f, 127.0f, 127.0f }, n ); @@ -82,7 +81,7 @@ static void scene_vert_pack_norm( scene_vert *vert, v3f norm ) vert->norm[0] = n[0]; vert->norm[1] = n[1]; vert->norm[2] = n[2]; - vert->norm[3] = 0; /* free byte :D */ + vert->norm[3] = blend * 127.0f; } /* @@ -129,7 +128,7 @@ static void scene_add_mdl_submesh( scene_context *ctx, mdl_context *mdl, v3f normal; m3x3_mulv( normal_matrix, src->norm, normal ); - scene_vert_pack_norm( pvert, normal ); + scene_vert_pack_norm( pvert, normal, src->colour[0]*(1.0f/255.0f) ); v2_copy( src->uv, pvert->uv ); } diff --git a/shaders/scene_vertex_blend.h b/shaders/scene_vertex_blend.h index 2cc345b..c5206d1 100644 --- a/shaders/scene_vertex_blend.h +++ b/shaders/scene_vertex_blend.h @@ -477,7 +477,7 @@ static struct vg_shader _shader_scene_vertex_blend = { " vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n" "\n" " // Colour blending\n" -" float fblendclip = step(0.380,aNorm.w + (rgarbage.r-0.5)*-1.740)*0.320;\n" +" float fblendclip = step(0.380,aNorm.w + (rgarbage.r-0.5)*-1.740)*0.380;\n" " vec2 uvgradients = aUv + vec2( fblendclip, 0.0 );\n" "\n" " vfrag = texture( uTexGradients, uvgradients ).rgb;\n" @@ -489,7 +489,7 @@ static struct vg_shader _shader_scene_vertex_blend = { " }\n" "\n" " vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );\n" -" oColour = vec4(vfrag, 1.0);\n" +" oColour = vec4(vec3(aNorm.w), 1.0);\n" "}\n" ""}, }; diff --git a/world_gen.c b/world_gen.c index 4e01de3..df5b342 100644 --- a/world_gen.c +++ b/world_gen.c @@ -85,13 +85,12 @@ static void world_gen_add_blob( world_instance *world, scene_vert *ref = &world->scene_geo.arrvertices[ hit->tri[0] ]; - for( u32 i=0; ico, pvert->co ); - scene_vert_pack_norm( pvert, transform[1] ); + scene_vert_pack_norm( pvert, transform[1], 0.0f ); v2_copy( ref->uv, pvert->uv ); } diff --git a/world_routes.c b/world_routes.c index 0bfdcac..fbd335e 100644 --- a/world_routes.c +++ b/world_routes.c @@ -315,8 +315,8 @@ void world_routes_place_curve( world_instance *world, ent_route *route, v3_muladds( ha.pos, up, 0.06f+gap, va.co ); v3_muladds( hb.pos, up, 0.06f+gap, vb.co ); - scene_vert_pack_norm( &va, up ); - scene_vert_pack_norm( &vb, up ); + scene_vert_pack_norm( &va, up, 0.0f ); + scene_vert_pack_norm( &vb, up, 0.0f ); float t1 = (travel_length / total_length) * patch_count; va.uv[0] = t1; -- 2.25.1