Browse Source

Small tweaks to make a few textures on n64start a bit nicer

master
Nico de Poel 3 years ago
parent
commit
3e0706c9f9
  1. 10
      main.cpp
  2. 4
      texture.cpp

10
main.cpp

@ -158,6 +158,12 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex
vertexSum = vertexSum + vertexPoint;
}
// If the texture doesn't tile, we don't need to correct the UVs as much
float sRange = maxS - minS;
float tRange = maxT - minT;
if (sRange < 1) sRange = 1;
if (tRange < 1) tRange = 1;
// Go over the edges again to fudge some UVs for the vertices (this second pass is only necessary because we don't have texture tiling yet)
for (int edgeListIdx = 0; edgeListIdx < face->ledge_num; ++edgeListIdx)
{
@ -177,8 +183,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex
// Calculate texture UVs
float s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width;
float t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height;
s = (s - minS) / (maxS - minS);
t = (t - minT) / (maxT - minT);
if (minS < 0 || maxS > 1) s = (s - minS) / sRange;
if (minT < 0 || maxT > 1) t = (t - minT) / tRange;
// Rescale the UVs to the dimensions of the mipmap we've selected for our texture atlas
faceVertex.u = (unsigned char)(s * (ps1tex.w - 1));

4
texture.cpp

@ -46,6 +46,10 @@ bool process_textures(const world_t* world, std::vector<ps1bsp_texture_t>& outTe
// Shrink the larger textures, but keep smaller ones at their original size
int ps1mip = miptex->width > 64 || miptex->height > 64 ? 1 : 0;
// Make an exception for the difficulty selection teleporters
if (!strncmp(miptex->name, "skill", 5) || !strcmp(miptex->name, "quake"))
ps1mip = 0;
if (strcmp(miptex->name, "clip") && strcmp(miptex->name, "trigger"))
rectangles.emplace_back(rectpack2D::rect_xywh(0, 0, miptex->width >> ps1mip, miptex->height >> ps1mip));
else

Loading…
Cancel
Save