- 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
|
|
@ -36,30 +36,30 @@
|
|||
|
||||
EXTERN_CVAR(Int, r_3dfloors)
|
||||
|
||||
void RenderPolyPlane::RenderPlanes(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
void RenderPolyPlane::RenderPlanes(PolyRenderThread *thread, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
{
|
||||
if (fakeflat.FrontSector->CenterFloor() == fakeflat.FrontSector->CenterCeiling())
|
||||
return;
|
||||
|
||||
RenderPolyPlane plane;
|
||||
plane.Render(thread, worldToClip, clipPlane, fakeflat, stencilValue, true, skyCeilingHeight, sectorPortals);
|
||||
plane.Render(thread, worldToClip, clipPlane, fakeflat, stencilValue, false, skyFloorHeight, sectorPortals);
|
||||
plane.Render(thread, clipPlane, fakeflat, stencilValue, true, skyCeilingHeight, sectorPortals);
|
||||
plane.Render(thread, clipPlane, fakeflat, stencilValue, false, skyFloorHeight, sectorPortals);
|
||||
}
|
||||
|
||||
void RenderPolyPlane::Render(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
void RenderPolyPlane::Render(PolyRenderThread *thread, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
{
|
||||
FSectorPortal *portal = fakeflat.FrontSector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor);
|
||||
if (!portal || (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into
|
||||
{
|
||||
RenderNormal(thread, worldToClip, clipPlane, fakeflat, stencilValue, ceiling, skyHeight);
|
||||
RenderNormal(thread, clipPlane, fakeflat, stencilValue, ceiling, skyHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPortal(thread, worldToClip, clipPlane, fakeflat, stencilValue, ceiling, skyHeight, portal, sectorPortals);
|
||||
RenderPortal(thread, clipPlane, fakeflat, stencilValue, ceiling, skyHeight, portal, sectorPortals);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight)
|
||||
void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight)
|
||||
{
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
|
||||
|
|
@ -76,35 +76,30 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const TriMatrix &wo
|
|||
PolyDrawArgs args;
|
||||
SetLightLevel(thread, args, fakeflat, ceiling);
|
||||
SetDynLights(thread, args, fakeflat.Subsector, ceiling);
|
||||
args.SetTransform(&worldToClip);
|
||||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetClipPlane(0, clipPlane);
|
||||
args.SetTexture(tex, DefaultRenderStyle());
|
||||
args.SetStyle(TriBlendMode::TextureOpaque);
|
||||
args.DrawArray(thread, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
}
|
||||
else
|
||||
{
|
||||
TriVertex *vertices = CreateSkyPlaneVertices(thread, fakeflat.Subsector, skyHeight);
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.SetTransform(&worldToClip);
|
||||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetClipPlane(0, clipPlane);
|
||||
args.SetWriteStencil(true, 255);
|
||||
args.SetWriteColor(false);
|
||||
args.SetWriteDepth(false);
|
||||
args.DrawArray(thread, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
|
||||
RenderSkyWalls(thread, args, fakeflat.Subsector, nullptr, ceiling, skyHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPolyPlane::RenderPortal(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight, FSectorPortal *portal, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
void RenderPolyPlane::RenderPortal(PolyRenderThread *thread, const PolyClipPlane &clipPlane, const PolyTransferHeights &fakeflat, uint32_t stencilValue, bool ceiling, double skyHeight, FSectorPortal *portal, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||
{
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
|
||||
|
|
@ -160,19 +155,16 @@ void RenderPolyPlane::RenderPortal(PolyRenderThread *thread, const TriMatrix &wo
|
|||
TriVertex *vertices = CreateSkyPlaneVertices(thread, fakeflat.Subsector, skyHeight);
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.SetTransform(&worldToClip);
|
||||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetClipPlane(0, clipPlane);
|
||||
args.SetWriteStencil(true, polyportal->StencilValue);
|
||||
args.SetWriteColor(false);
|
||||
args.SetWriteDepth(false);
|
||||
args.DrawArray(thread, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
|
||||
RenderSkyWalls(thread, args, fakeflat.Subsector, polyportal, ceiling, skyHeight);
|
||||
|
||||
polyportal->Shape.push_back({ vertices, (int)fakeflat.Subsector->numlines, true });
|
||||
polyportal->Shape.push_back({ vertices, (int)fakeflat.Subsector->numlines });
|
||||
}
|
||||
|
||||
void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &args, subsector_t *sub, PolyDrawSectorPortal *polyportal, bool ceiling, double skyHeight)
|
||||
|
|
@ -246,11 +238,11 @@ void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &arg
|
|||
wallvert[3] = GetSkyVertex(line->v1, skyHeight);
|
||||
}
|
||||
|
||||
args.DrawArray(thread, wallvert, 4, PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, wallvert, 4, PolyDrawMode::TriangleFan);
|
||||
|
||||
if (polyportal)
|
||||
{
|
||||
polyportal->Shape.push_back({ wallvert, 4, args.FaceCullCCW() });
|
||||
polyportal->Shape.push_back({ wallvert, 4 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -421,7 +413,7 @@ PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FTexture
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, uint32_t subsectorDepth, std::vector<PolyTranslucentObject *> &translucentObjects)
|
||||
void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, uint32_t subsectorDepth, std::vector<PolyTranslucentObject *> &translucentObjects)
|
||||
{
|
||||
if (!r_3dfloors || sub->sector->CenterFloor() == sub->sector->CenterCeiling())
|
||||
return;
|
||||
|
|
@ -465,7 +457,7 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, const TriMatrix
|
|||
}
|
||||
|
||||
if (!plane.Masked)
|
||||
plane.Render(thread, worldToClip, clipPlane);
|
||||
plane.Render(thread, clipPlane);
|
||||
else
|
||||
translucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucent3DFloorPlane>(plane, subsectorDepth));
|
||||
}
|
||||
|
|
@ -505,14 +497,14 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, const TriMatrix
|
|||
}
|
||||
|
||||
if (!plane.Masked)
|
||||
plane.Render(thread, worldToClip, clipPlane);
|
||||
plane.Render(thread, clipPlane);
|
||||
else
|
||||
translucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucent3DFloorPlane>(plane, subsectorDepth));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Render3DFloorPlane::Render(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane)
|
||||
void Render3DFloorPlane::Render(PolyRenderThread *thread, const PolyClipPlane &clipPlane)
|
||||
{
|
||||
FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture;
|
||||
FTexture *tex = TexMan(picnum);
|
||||
|
|
@ -555,7 +547,6 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread, const TriMatrix &world
|
|||
|
||||
PolyDrawArgs args;
|
||||
args.SetLight(GetColorTable(sub->sector->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), false);
|
||||
args.SetTransform(&worldToClip);
|
||||
if (!Masked)
|
||||
{
|
||||
args.SetStyle(TriBlendMode::TextureOpaque);
|
||||
|
|
@ -567,12 +558,10 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread, const TriMatrix &world
|
|||
args.SetStyle(TriBlendMode::TextureAdd, srcalpha, destalpha);
|
||||
args.SetDepthTest(true);
|
||||
args.SetWriteDepth(true);
|
||||
args.SetWriteStencil(false);
|
||||
}
|
||||
args.SetFaceCullCCW(true);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetTexture(tex, DefaultRenderStyle());
|
||||
args.SetClipPlane(0, clipPlane);
|
||||
args.DrawArray(thread, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
||||
args.DrawArray(thread->DrawQueue, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue