diff --git a/src/rendering/hwrenderer/scene/hw_visibleset.cpp b/src/rendering/hwrenderer/scene/hw_visibleset.cpp index 10ce5b464..70b0976c3 100644 --- a/src/rendering/hwrenderer/scene/hw_visibleset.cpp +++ b/src/rendering/hwrenderer/scene/hw_visibleset.cpp @@ -54,7 +54,7 @@ void HWVisibleSet::FindPVS(HWDrawInfo* di, int sliceIndex, int sliceCount) VSMatrix m = di->VPUniforms.mProjectionMatrix; m.multMatrix(di->VPUniforms.mViewMatrix); - ClipFrustum.Set(m); + ClipFrustum.Set(m, Viewpoint.Pos); CurrentMapSections = &di->CurrentMapSections; no_renderflags = TArrayView(di->no_renderflags.data(), di->no_renderflags.size()); @@ -660,15 +660,18 @@ void HWVisibleSetThreads::WorkerMain(int sliceIndex) ///////////////////////////////////////////////////////////////////////////// -void CameraFrustum::Set(const VSMatrix& worldToProjection) +void CameraFrustum::Set(const VSMatrix& worldToProjection, const DVector3& viewpoint) { - Planes[0] = LeftFrustum(worldToProjection); - Planes[1] = TopFrustum(worldToProjection); - Planes[2] = RightFrustum(worldToProjection); - Planes[3] = BottomFrustum(worldToProjection); - Planes[4] = NearFrustum(worldToProjection); + Planes[0] = NearFrustum(worldToProjection); + Planes[1] = LeftFrustum(worldToProjection); + Planes[2] = TopFrustum(worldToProjection); + Planes[3] = RightFrustum(worldToProjection); + Planes[4] = BottomFrustum(worldToProjection); Planes[5] = FarFrustum(worldToProjection); + // Move back near plane to be slightly behind the camera position + Planes[0].W = -(Planes[0].XYZ() | viewpoint.ToXZY() - 1.0); + for (int i = 0; i < 6; i++) { AbsPlaneNormals[i] = Planes[i].XYZ(); diff --git a/src/rendering/hwrenderer/scene/hw_visibleset.h b/src/rendering/hwrenderer/scene/hw_visibleset.h index d2d92c79a..06fc510d7 100644 --- a/src/rendering/hwrenderer/scene/hw_visibleset.h +++ b/src/rendering/hwrenderer/scene/hw_visibleset.h @@ -15,7 +15,7 @@ struct HWDrawInfo; struct CameraFrustum { - void Set(const VSMatrix& worldToProjection); + void Set(const VSMatrix& worldToProjection, const DVector3& viewpoint); bool IsSphereVisible(const DVector3& point, double radius) const {