- Clean up PolyTriangleDrawer API so that it can better support both softpoly and the swrenderer
- Slightly improve how softpoly processes portals - Pass the vertex transform matrix via a command rather than being part of the drawer args - Improve zbuffer drawers in the software renderer - Misc model rendering fixes
This commit is contained in:
parent
cb3650ed9e
commit
2d51fa5b43
54 changed files with 1210 additions and 843 deletions
|
|
@ -35,12 +35,12 @@ PolySkyDome::PolySkyDome()
|
|||
CreateDome();
|
||||
}
|
||||
|
||||
void PolySkyDome::Render(PolyRenderThread *thread, const TriMatrix &worldToClip)
|
||||
void PolySkyDome::Render(PolyRenderThread *thread, const Mat4f &worldToView, const Mat4f &worldToClip)
|
||||
{
|
||||
#ifdef USE_GL_DOME_MATH
|
||||
TriMatrix modelMatrix = GLSkyMath();
|
||||
Mat4f modelMatrix = GLSkyMath();
|
||||
#else
|
||||
TriMatrix modelMatrix = TriMatrix::identity();
|
||||
Mat4f modelMatrix = Mat4f::Identity();
|
||||
|
||||
PolySkySetup frameSetup;
|
||||
frameSetup.Update();
|
||||
|
|
@ -76,14 +76,14 @@ void PolySkyDome::Render(PolyRenderThread *thread, const TriMatrix &worldToClip)
|
|||
#endif
|
||||
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
TriMatrix objectToWorld = TriMatrix::translate((float)viewpoint.Pos.X, (float)viewpoint.Pos.Y, (float)viewpoint.Pos.Z) * modelMatrix;
|
||||
objectToClip = worldToClip * objectToWorld;
|
||||
Mat4f objectToWorld = Mat4f::Translate((float)viewpoint.Pos.X, (float)viewpoint.Pos.Y, (float)viewpoint.Pos.Z) * modelMatrix;
|
||||
|
||||
int rc = mRows + 1;
|
||||
|
||||
PolyTriangleDrawer::SetTransform(thread->DrawQueue, thread->FrameMemory->NewObject<Mat4f>(worldToClip * objectToWorld));
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.SetLight(&NormalLight, 255, PolyRenderer::Instance()->Light.WallGlobVis(false), true);
|
||||
args.SetTransform(&objectToClip);
|
||||
args.SetStencilTestValue(255);
|
||||
args.SetWriteStencil(true, 1);
|
||||
args.SetClipPlane(0, PolyClipPlane(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
|
@ -107,10 +107,9 @@ void PolySkyDome::Render(PolyRenderThread *thread, const TriMatrix &worldToClip)
|
|||
|
||||
void PolySkyDome::RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int row, uint32_t capcolor, uint8_t capcolorindex)
|
||||
{
|
||||
args.SetFaceCullCCW(false);
|
||||
args.SetColor(capcolor, capcolorindex);
|
||||
args.SetStyle(TriBlendMode::Skycap);
|
||||
args.DrawArray(thread, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip);
|
||||
args.DrawArray(thread->DrawQueue, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip);
|
||||
}
|
||||
|
||||
void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
||||
|
|
@ -118,10 +117,9 @@ void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args
|
|||
uint32_t solid = skytex->GetSkyCapColor(bottomCap);
|
||||
uint8_t palsolid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)];
|
||||
|
||||
args.SetFaceCullCCW(bottomCap);
|
||||
args.SetColor(solid, palsolid);
|
||||
args.SetStyle(TriBlendMode::FillOpaque);
|
||||
args.DrawArray(thread, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleFan);
|
||||
}
|
||||
|
||||
void PolySkyDome::CreateDome()
|
||||
|
|
@ -141,7 +139,7 @@ void PolySkyDome::CreateSkyHemisphere(bool zflip)
|
|||
|
||||
for (c = 0; c < mColumns; c++)
|
||||
{
|
||||
SkyVertex(1, c, zflip);
|
||||
SkyVertex(1, zflip ? c : (mColumns - 1 - c), zflip);
|
||||
}
|
||||
|
||||
// The total number of triangles per hemisphere can be calculated
|
||||
|
|
@ -151,8 +149,8 @@ void PolySkyDome::CreateSkyHemisphere(bool zflip)
|
|||
mPrimStart.Push(mVertices.Size());
|
||||
for (c = 0; c <= mColumns; c++)
|
||||
{
|
||||
SkyVertex(r + zflip, c, zflip);
|
||||
SkyVertex(r + 1 - zflip, c, zflip);
|
||||
SkyVertex(r + zflip, c, zflip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -204,7 +202,7 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip)
|
|||
mInitialUV.Push({ vert.u, vert.v });
|
||||
}
|
||||
|
||||
TriMatrix PolySkyDome::GLSkyMath()
|
||||
Mat4f PolySkyDome::GLSkyMath()
|
||||
{
|
||||
PolySkySetup frameSetup;
|
||||
frameSetup.Update();
|
||||
|
|
@ -222,43 +220,43 @@ TriMatrix PolySkyDome::GLSkyMath()
|
|||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||
const float skyoffsetfactor = 57;
|
||||
|
||||
TriMatrix modelMatrix = TriMatrix::identity();
|
||||
Mat4f modelMatrix = Mat4f::Identity();
|
||||
if (tex)
|
||||
{
|
||||
texw = tex->GetWidth();
|
||||
texh = tex->GetHeight();
|
||||
|
||||
modelMatrix = TriMatrix::rotate(-180.0f + x_offset, 0.f, 0.f, 1.f);
|
||||
modelMatrix = Mat4f::Rotate(-180.0f + x_offset, 0.f, 0.f, 1.f);
|
||||
|
||||
float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f;
|
||||
float yscale = 1.f;
|
||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||
{
|
||||
modelMatrix = modelMatrix * TriMatrix::translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * TriMatrix::scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
else if (texh < 128)
|
||||
{
|
||||
// smaller sky textures must be tiled. We restrict it to 128 sky pixels, though
|
||||
modelMatrix = modelMatrix * TriMatrix::translate(0.f, 0.f, -1250.f);
|
||||
modelMatrix = modelMatrix * TriMatrix::scale(1.f, 1.f, 128 / 230.f);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, -1250.f);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 128 / 230.f);
|
||||
yscale = (float)(128 / texh); // intentionally left as integer.
|
||||
}
|
||||
else if (texh < 200)
|
||||
{
|
||||
modelMatrix = modelMatrix * TriMatrix::translate(0.f, 0.f, -1250.f);
|
||||
modelMatrix = modelMatrix * TriMatrix::scale(1.f, 1.f, texh / 230.f);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, -1250.f);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, texh / 230.f);
|
||||
}
|
||||
else if (texh <= 240)
|
||||
{
|
||||
modelMatrix = modelMatrix * TriMatrix::translate(0.f, 0.f, (200 - texh + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * TriMatrix::scale(1.f, 1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (200 - texh + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f);
|
||||
}
|
||||
else
|
||||
{
|
||||
modelMatrix = modelMatrix * TriMatrix::translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * TriMatrix::scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue