Saturn: Improve texture orientation

This commit is contained in:
UnknownShadow200 2024-07-05 20:36:03 +10:00
parent b821c41ceb
commit 5b0a269d2c
2 changed files with 21 additions and 9 deletions

View File

@ -252,7 +252,7 @@ void Gfx_DeleteIb(GfxResourceID* ib) { }
*#########################################################################################################################*/
// Preprocess vertex buffers into optimised layout for Saturn
struct SATVertexColoured { int x, y, z; PackedCol Col; };
struct SATVertexTextured { int x, y, z; PackedCol Col; float u, v; };
struct SATVertexTextured { int x, y, z; PackedCol Col; int flip, pad; };
static VertexFormat buf_fmt;
static int buf_count;
@ -278,6 +278,14 @@ static void PreprocessTexturedVertices(void) {
int b = PackedCol_B(src->Col);
dst->Col = ((b >> 5) << 7) | ((g >> 4) << 3) | (r >> 5);
}
dst = gfx_vertices;
src = gfx_vertices;
for (int i = 0; i < buf_count; i += 4, src += 4, dst += 4)
{
int flipped = src[0].V > src[2].V;
dst->flip = flipped ? VDP1_CMDT_CHAR_FLIP_V : VDP1_CMDT_CHAR_FLIP_NONE;
}
}
static void PreprocessColouredVertices(void) {
@ -508,6 +516,7 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
vdp1_cmdt_distorted_sprite_set(cmd);
vdp1_cmdt_char_size_set(cmd, tex_width, tex_height);
vdp1_cmdt_char_base_set(cmd, (vdp1_vram_t)tex_vram_cur);
vdp1_cmdt_char_flip_set(cmd, v->flip);
vdp1_cmdt_draw_mode_set(cmd, v->Col == 1023 ? color_draw_mode : shaded_draw_mode);
vdp1_cmdt_gouraud_base_set(cmd, (vdp1_vram_t)&gourad_base[v->Col]);
vdp1_cmdt_vtx_set(cmd, points);
@ -569,6 +578,7 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) {
vdp1_cmdt_distorted_sprite_set(cmd);
vdp1_cmdt_char_size_set(cmd, tex_width, tex_height);
vdp1_cmdt_char_base_set(cmd, (vdp1_vram_t)tex_vram_cur);
vdp1_cmdt_char_flip_set(cmd, v->flip);
vdp1_cmdt_draw_mode_set(cmd, v->Col == 1023 ? color_draw_mode : shaded_draw_mode);
vdp1_cmdt_gouraud_base_set(cmd, (vdp1_vram_t)&gourad_base[v->Col]);
vdp1_cmdt_vtx_set(cmd, points);

View File

@ -40,13 +40,14 @@ static void IsometricDrawer_Flat(BlockID block, float size) {
TextureLoc loc = Block_Tex(block, FACE_ZMAX);
TextureRec rec = Atlas1D_TexRec(loc, 1, &texIndex);
struct VertexTextured v;
struct VertexTextured* v;
float minX, maxX, minY, maxY;
PackedCol color;
float scale;
*iso_state++ = texIndex;
v.Col = PACKEDCOL_WHITE;
Block_Tint(v.Col, block);
color = PACKEDCOL_WHITE;
Block_Tint(color, block);
/* Rescale by 0.70 in Classic mode to match vanilla size */
/* Rescale by 0.88 in Enhanced mode to be slightly nicer */
@ -58,11 +59,12 @@ static void IsometricDrawer_Flat(BlockID block, float size) {
minX = iso_posX - size; maxX = iso_posX + size;
minY = iso_posY - size; maxY = iso_posY + size;
v.z = 0.0f;
v.x = minX; v.y = minY; v.U = rec.u1; v.V = rec.v1; *iso_vertices++ = v;
v.y = maxY; v.V = rec.v2; *iso_vertices++ = v;
v.x = maxX; v.U = rec.u2; *iso_vertices++ = v;
v.y = minY; v.V = rec.v1; *iso_vertices++ = v;
v = iso_vertices;
v->x = minX; v->y = minY; v->z = 0; v->Col = color; v->U = rec.u1; v->V = rec.v1; v++;
v->x = maxX; v->y = minY; v->z = 0; v->Col = color; v->U = rec.u1; v->V = rec.v1; v++;
v->x = maxX; v->y = maxY; v->z = 0; v->Col = color; v->U = rec.u2; v->V = rec.v2; v++;
v->x = minX; v->y = maxY; v->z = 0; v->Col = color; v->U = rec.u1; v->V = rec.v2; v++;
iso_vertices = v;
}
static void IsometricDrawer_Angled(BlockID block, float size) {