diff --git a/ref_vk/vk_brush.c b/ref_vk/vk_brush.c index b52934dc..7c987912 100644 --- a/ref_vk/vk_brush.c +++ b/ref_vk/vk_brush.c @@ -456,8 +456,6 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) { vk_render_geometry_t *model_geometry = bmodel->render_model.geometries + num_geometries; const float sample_size = gEngine.Mod_SampleSizeForFace( surf ); int index_count = 0; - vec3_t pos[3]; - vec2_t uv[3]; vec3_t tangent; if (!renderableSurface(surf, -1)) @@ -496,6 +494,9 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) { model_geometry->material = kXVkMaterialConveyor; } + VectorCopy(surf->texinfo->vecs[0], tangent); + VectorNormalize(tangent); + for( int k = 0; k < surf->numedges; k++ ) { const int iedge = mod->surfedges[surf->firstedge + k]; @@ -514,18 +515,6 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) { vertex.gl_tc[0] = s; vertex.gl_tc[1] = t; - // TODO replace this with constructing tangent from surf->texinfo->vecs - if (k < 3) { - VectorCopy(vertex.pos, pos[k]); - Vector2Copy(vertex.gl_tc, uv[k]); - if (k == 2) { - computeTangent(tangent, pos[0], pos[1], pos[2], uv[0], uv[1], uv[2]); - VectorCopy(tangent, bvert[-1].tangent); - VectorCopy(tangent, bvert[-2].tangent); - } - } - VectorCopy(tangent, vertex.tangent); - // lightmap texture coordinates s = DotProduct( in_vertex->position, info->lmvecs[0] ) + info->lmvecs[0][3]; s -= info->lightmapmins[0]; @@ -543,6 +532,8 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) { VectorNegate( surf->plane->normal, vertex.normal ); else VectorCopy( surf->plane->normal, vertex.normal ); + VectorCopy(tangent, vertex.tangent); + vertex.lm_tc[0] = s; vertex.lm_tc[1] = t;