Browse Source

Use texture windows to allow repeating textures on select faces.

This reduces polycounts and file sizes significantly, at the expense of more texture warping and less refined lighting.
master
Nico de Poel 3 years ago
parent
commit
5bd322d33b
  1. BIN
      n64e1m1.ps1bsp
  2. BIN
      n64e2m2.ps1bsp
  3. BIN
      n64start.ps1bsp
  4. 1
      ps1bsp.h
  5. 14
      world.c

BIN
n64e1m1.ps1bsp

BIN
n64e2m2.ps1bsp

BIN
n64start.ps1bsp

1
ps1bsp.h

@ -58,6 +58,7 @@ typedef struct
{
unsigned short tpage; // Texture page in PS1 VRAM (precalculated when generating the texture atlas)
unsigned short nextframe; // If non-zero, the texture is animated and this points to the next texture in the sequence
unsigned int twin; // Texture window for repeating textures
} ps1bsp_texture_t;
// This matches the SVECTOR data type; we can use the extra padding to store some more data.

14
world.c

@ -193,6 +193,12 @@ static void world_drawface_textured(const world_t *world, const ps1bsp_face_t *f
}
}
}
// Texture window commands needs to be placed *after* the draw commands, because the commands are executed in reverse order
DR_TWIN *twin = (DR_TWIN*)mem_prim(sizeof(DR_TWIN));
setlen(twin, 1);
twin->code[0] = texture->twin;
addPrim(ot, twin);
}
static void (*world_drawface)(const world_t*, const ps1bsp_face_t*, u_long *ot) = &world_drawface_fast;
@ -205,7 +211,7 @@ static void world_drawFaces(const world_t *world, const ps1bsp_face_t *firstFace
for (const ps1bsp_face_t *face = firstFace; face != NULL; face = face->nextFace)
{
// Early primitive buffer check
if (!mem_checkprim(sizeof(POLY_GT4), face->totalPrimitives))
if (!mem_checkprim(sizeof(POLY_GT4) + sizeof(DR_TWIN), face->totalPrimitives))
break;
world_drawface(world, face, curOT);
@ -482,5 +488,11 @@ void world_draw(const world_t *world)
else
world_drawface = &world_drawface_lit;
// Make sure we set the texture window back to default after drawing the world
DR_TWIN *twin = (DR_TWIN*)mem_prim(sizeof(DR_TWIN));
setlen(twin, 1);
twin->code[0] = 0xe2000000;
addPrim(curOT, twin);
world_drawFaces(world, firstFace);
}
Loading…
Cancel
Save