mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-02-16 17:35:39 +00:00
Support multiple microTextures, fixes crazy texturing in sega ski champ. I'm assuming microtextures are always located on the other memory bank to the base texture. This logic seems to work for all our games anyway.
This commit is contained in:
parent
e21ea93319
commit
c3581c9fe8
|
@ -39,6 +39,7 @@ struct Mesh
|
|||
// texture
|
||||
int format, x, y, width, height = 0;
|
||||
bool microTexture = false;
|
||||
int microTextureID = 0;
|
||||
bool mirrorU = false;
|
||||
bool mirrorV = false;
|
||||
|
||||
|
|
|
@ -147,8 +147,11 @@ void CNew3D::RenderScene(int priority, bool alpha)
|
|||
}
|
||||
|
||||
if (mesh.microTexture) {
|
||||
|
||||
int mX, mY;
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
auto tex2 = m_texSheet.BindTexture(m_textureRAM, 0, false, false, 0, 1024, 128, 128);
|
||||
m_texSheet.GetMicrotexPos(y / 1024, mesh.microTextureID, mX, mY);
|
||||
auto tex2 = m_texSheet.BindTexture(m_textureRAM, 0, false, false, mX, mY, 128, 128);
|
||||
if (tex2) {
|
||||
tex2->BindTexture();
|
||||
}
|
||||
|
@ -980,6 +983,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
|
|||
currentMesh->mirrorU = ph.TexUMirror();
|
||||
currentMesh->mirrorV = ph.TexVMirror();
|
||||
currentMesh->microTexture = ph.MicroTexture();
|
||||
currentMesh->microTextureID = ph.MicroTextureID();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,11 @@ bool PolyHeader::MicroTexture()
|
|||
return (header[2] & 0x10) > 0;
|
||||
}
|
||||
|
||||
int PolyHeader::MicroTextureID()
|
||||
{
|
||||
return (header[2] >> 5) & 3;
|
||||
}
|
||||
|
||||
//
|
||||
// header 3
|
||||
|
||||
|
@ -366,7 +371,8 @@ UINT64 PolyHeader::Hash()
|
|||
hash |= (UINT64)DoubleSided() << 33; // bits 33 double sided
|
||||
hash |= (UINT64)AlphaTest() << 34; // bits 34 contour processing
|
||||
hash |= (UINT64)PolyAlpha() << 35; // bits 35 poly alpha processing
|
||||
hash |= (UINT64)TextureAlpha() << 36; // bits 35 poly alpha processing
|
||||
hash |= (UINT64)TextureAlpha() << 36; // bits 35 texture alpha processing
|
||||
hash |= (UINT64)MicroTexture() << 37; // bits 36 microtexture enable
|
||||
|
||||
//to do add the rest of the states
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ xxxxxx-- -------- -------- -------- Specular
|
|||
-------- -------- -------- x------- Enable specular
|
||||
-------- -------- -------- -x------ 0 = Triangle, 1 = Quad
|
||||
-------- -------- -------- --x----- Poly is points
|
||||
-------- -------- -------- ---x---- Smoothing ?
|
||||
-------- -------- -------- ---x---- Anti-aliasing
|
||||
-------- -------- -------- ----x--- Vertex 3 shared from previous polygon
|
||||
-------- -------- -------- -----x-- Vertex 2 shared from previous polygon
|
||||
-------- -------- -------- ------x- Vertex 1 shared from previous polygon
|
||||
|
@ -108,6 +108,7 @@ public:
|
|||
bool TexUMirror();
|
||||
bool TexVMirror();
|
||||
bool MicroTexture();
|
||||
int MicroTextureID();
|
||||
|
||||
// header 3
|
||||
int TexWidth();
|
||||
|
|
|
@ -120,4 +120,19 @@ int TextureSheet::GetTexFormat(int originalFormat, bool contour)
|
|||
}
|
||||
}
|
||||
|
||||
void TextureSheet::GetMicrotexPos(int basePage, int id, int& x, int& y)
|
||||
{
|
||||
int xCoords[8] = { 0, 128, 0, 128, 0, 128, 0, 128 };
|
||||
int yCoords[8] = { 0, 0, 128, 128, 0, 0, 128, 128 };
|
||||
|
||||
// i'm assuming .. the micro texture map is always on the other memory bank to the base texture
|
||||
// this logic works for all our current games
|
||||
// the microtextures are always on the top left of each texture sheet
|
||||
|
||||
basePage = (basePage + 1) & 1; // wrap around base page
|
||||
|
||||
x = xCoords[id];
|
||||
y = xCoords[id] + (basePage * 1024);
|
||||
}
|
||||
|
||||
} // New3D
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
void Invalidate (int x, int y, int width, int height); // release parts of the memory
|
||||
void Release (); // release all texture objects and memory
|
||||
int GetTexFormat (int originalFormat, bool contour);
|
||||
void GetMicrotexPos (int basePage, int id, int& x, int& y);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue