Page 1 of 1

How to do texture tiling?

Posted: September 14th, 2024, 1:34 pm
by masmorra
There is a way to achieve texture tiling? I have a 256 texture and I want o make 32x32 repeat on the polygon, but I only got the other part of the texture:

my uv is:

Code: Select all

DVECTOR uvs[4] = {
	{ 0, 127 },
	{ 127, 127 },
	{ 127, 0 },
	{ 0, 0 },
};

Code: Select all

RECT texRect = {0, 0, 32>>3, 32>>3};
DR_TWIN* ptwin = (DR_TWIN*)db_nextpri;
setTexWindow(ptwin, &texRect);
addPrim(_orderingTable, ptwin);
ptwin++;
db_nextpri = (uint8_t*)ptwin;
GeometryType *pol4 = (GeometryType *)db_nextpri;
// Load the first 3 vertices of a quad to the GTE
gte_ldv3(
    &values[0],
    &values[1],
    &values[2]);
// Rotation, Translation and Perspective Triple
gte_rtpt();
...
...
...
pol4->tpage = getTPage(texture->mode, 0, texture->prect->x, texture->prect->y);

if (texture->mode & 0x8)
{
    // Set CLUT
    setClut(pol4, texture->crect->x, texture->crect->y);
}
// setUV3 1, 0, 2
pol4->u0 = uvs[0].vx;
pol4->v0 = uvs[0].vy;

pol4->u1 = uvs[1].vx;
pol4->v1 = uvs[1].vy;

pol4->u2 = uvs[2].vx;
pol4->v2 = uvs[2].vy;
The result is this:
texture-tiling.png

Re: How to do texture tiling?

Posted: September 16th, 2024, 3:54 pm
by Administrator
If I'm not mistaken, the PSX can only natively support a texture size of 128 x 128. Larger textures need additional methods.

Re: How to do texture tiling?

Posted: September 17th, 2024, 5:48 am
by nocash
The limit is 256x256 (or perhaps something like 255x255 in practice), not 128x128.
Either way, 32x32 doesn't exceed those limits.
The GPU has MASK and OFFSET features for sizes like repeating 32x32 textures.
If your 32>>3 is meant to set the MASK, try replacing it by 31/8, or (255-31)/8.

Re: How to do texture tiling?

Posted: September 18th, 2024, 8:27 am
by masmorra
nocash wrote: September 17th, 2024, 5:48 am The limit is 256x256 (or perhaps something like 255x255 in practice), not 128x128.
Either way, 32x32 doesn't exceed those limits.
The GPU has MASK and OFFSET features for sizes like repeating 32x32 textures.
If your 32>>3 is meant to set the MASK, try replacing it by 31/8, or (255-31)/8.
The tiling worked! I don't know why, but it works with RECT texRect = {0, 0, (texture->prect->w>>2), (texture->prect->h>>3)};
But the real problem I think was the ordering table position, when I set to the same position, it worked:

addPrim(_orderingTable + p, ptwin);
addPrim(_orderingTable + p, pol4);

Thanks for the help guys!

Re: How to do texture tiling?

Posted: September 21st, 2024, 1:51 am
by Administrator
nocash wrote: September 17th, 2024, 5:48 am The limit is 256x256 (or perhaps something like 255x255 in practice), not 128x128.
Thanks for the correction and clarification :)