mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- initial sky fixes.
This commit is contained in:
parent
e884a418f8
commit
096ce5e025
7 changed files with 109 additions and 74 deletions
|
@ -63,13 +63,6 @@
|
|||
#include "v_video.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
|
||||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||
enum
|
||||
{
|
||||
skyoffsetfactor = 57
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Shamelessly lifted from Doomsday (written by Jaakko Keränen)
|
||||
|
@ -369,7 +362,7 @@ void FSkyVertexBuffer::SetupMatrices(FGameTexture *tex, float x_offset, float y_
|
|||
else
|
||||
{
|
||||
modelMatrix.translate(0.f, (-40 + texskyoffset) * skyoffsetfactor, 0.f);
|
||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||
modelMatrix.scale(1.f, 0.8f * 1.17f, 1.f);
|
||||
}
|
||||
textureMatrix.loadIdentity();
|
||||
textureMatrix.scale(mirror ? -xscale : xscale, yscale, 1.f);
|
||||
|
@ -393,21 +386,19 @@ void FSkyVertexBuffer::RenderRow(FRenderState& state, EDrawType prim, int row, b
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled)
|
||||
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode)
|
||||
{
|
||||
if (tex)
|
||||
{
|
||||
state.SetMaterial(tex, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.EnableModelMatrix(true);
|
||||
state.EnableTextureMatrix(true);
|
||||
|
||||
SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled);
|
||||
}
|
||||
|
||||
int rc = mRows + 1;
|
||||
|
||||
// The caps only get drawn for the main layer but not for the overlay.
|
||||
if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != NULL)
|
||||
if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != nullptr)
|
||||
{
|
||||
auto& col = R_GetSkyCapColor(tex);
|
||||
state.SetObjectColor(col.first);
|
||||
|
@ -430,6 +421,22 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float
|
|||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale, float yscale)
|
||||
{
|
||||
if (tex)
|
||||
{
|
||||
SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale);
|
||||
}
|
||||
RenderDome(state, tex, mode);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
|
|
@ -11,6 +11,12 @@ class IVertexBuffer;
|
|||
struct HWSkyPortal;
|
||||
struct HWDrawInfo;
|
||||
|
||||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||
enum
|
||||
{
|
||||
skyoffsetfactor = 57
|
||||
};
|
||||
|
||||
struct FSkyVertex
|
||||
{
|
||||
float x, y, z, u, v;
|
||||
|
@ -84,7 +90,8 @@ public:
|
|||
}
|
||||
|
||||
void RenderRow(FRenderState& state, EDrawType prim, int row, bool apply = true);
|
||||
void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled);
|
||||
void RenderDome(FRenderState& state, FGameTexture* tex, int mode);
|
||||
void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0);
|
||||
void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2);
|
||||
|
||||
};
|
||||
|
|
|
@ -120,9 +120,23 @@ void BunchDrawer::DeleteBunch(int index)
|
|||
|
||||
bool BunchDrawer::CheckClip(walltype* wal)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (wal - wall == 843 || wal - wall == 847)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
auto pt2 = &wall[wal->point2];
|
||||
sectortype* backsector = §or[wal->nextsector];
|
||||
sectortype* frontsector = §or[wall[wal->nextwall].nextsector];
|
||||
|
||||
// if one plane is sky on both sides, the line must not clip.
|
||||
if (frontsector->ceilingstat & backsector->ceilingstat & CSTAT_SECTOR_SKY) return false;
|
||||
if (frontsector->floorstat & backsector->floorstat & CSTAT_SECTOR_SKY) return false;
|
||||
|
||||
float bs_floorheight1;
|
||||
float bs_floorheight2;
|
||||
float bs_ceilingheight1;
|
||||
|
@ -145,22 +159,18 @@ bool BunchDrawer::CheckClip(walltype* wal)
|
|||
if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2)
|
||||
{
|
||||
// backsector's ceiling is below frontsector's floor.
|
||||
if (frontsector->ceilingstat & backsector->ceilingstat & CSTAT_SECTOR_SKY) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2)
|
||||
{
|
||||
// backsector's floor is above frontsector's ceiling
|
||||
if (frontsector->floorstat & backsector->floorstat & CSTAT_SECTOR_SKY) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bs_ceilingheight1 <= bs_floorheight1 && bs_ceilingheight2 <= bs_floorheight2)
|
||||
{
|
||||
// backsector is closed
|
||||
if (frontsector->ceilingstat & backsector->ceilingstat & CSTAT_SECTOR_SKY) return false;
|
||||
if (frontsector->floorstat & backsector->floorstat & CSTAT_SECTOR_SKY) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,12 +177,6 @@ public:
|
|||
spritetype* teleport; // SW's teleport-views
|
||||
};
|
||||
|
||||
|
||||
|
||||
// these are not the same as ytop and ybottom!!!
|
||||
float zceil[2];
|
||||
float zfloor[2];
|
||||
|
||||
unsigned int vertindex;
|
||||
unsigned int vertcount;
|
||||
|
||||
|
@ -202,9 +196,9 @@ public:
|
|||
|
||||
void SkyPlane(HWDrawInfo *di, sectortype *sector, int plane, bool allowmirror);
|
||||
void SkyLine(HWDrawInfo *di, sectortype *sec, walltype *line);
|
||||
void SkyNormal(HWDrawInfo* di, sectortype* fs, FVector2& v1, FVector2& v2);
|
||||
void SkyTop(HWDrawInfo* di, walltype* seg, sectortype* fs, sectortype* bs, FVector2& v1, FVector2& v2);
|
||||
void SkyBottom(HWDrawInfo* di, walltype* seg, sectortype* fs, sectortype* bs, FVector2& v1, FVector2& v2);
|
||||
void SkyNormal(HWDrawInfo* di, sectortype* fs, FVector2& v1, FVector2& v2, float fch1, float fch2, float ffh1, float ffh2);
|
||||
void SkyTop(HWDrawInfo* di, walltype* seg, sectortype* fs, sectortype* bs, FVector2& v1, FVector2& v2, float fch1, float fch2);
|
||||
void SkyBottom(HWDrawInfo* di, walltype* seg, sectortype* fs, sectortype* bs, FVector2& v1, FVector2& v2, float ffh1, float ffh2);
|
||||
|
||||
bool DoHorizon(HWDrawInfo *di, walltype * seg,sectortype * fs, DVector2& v1, DVector2& v2);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane,
|
|||
|
||||
// dapyscale is not relvant for a sky dome.
|
||||
sky->y_scale = FixedToFloat(daptileyscale);
|
||||
sky->y_offset = FixedToFloat(dapyoffs) + ypanning * (float)ti * (1.f / 256.f);
|
||||
sky->y_offset = dapyoffs*2 + (ypanning * ti / 64.f);
|
||||
sky->x_offset = xpanning / (1 << (realskybits - dapskybits));
|
||||
sky->fadecolor = FadeColor;
|
||||
sky->shade = 0;// clamp(plane == plane_ceiling ? sector->ceilingshade : sector->floorshade, 0, numshades - 1);
|
||||
|
@ -113,17 +113,23 @@ void HWWall::SkyPlane(HWDrawInfo *di, sectortype *sector, int plane, bool allowr
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void HWWall::SkyNormal(HWDrawInfo* di, sectortype* fs, FVector2& v1, FVector2& v2)
|
||||
void HWWall::SkyNormal(HWDrawInfo* di, sectortype* fs, FVector2& v1, FVector2& v2, float fch1, float fch2, float ffh1, float ffh2)
|
||||
{
|
||||
ztop[0] = ztop[1] = 32768.0f;
|
||||
zbottom[0] = zceil[0];
|
||||
zbottom[1] = zceil[1];
|
||||
SkyPlane(di, fs, plane_ceiling, true);
|
||||
if (fs->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
ztop[0] = ztop[1] = 32768.0f;
|
||||
zbottom[0] = fch1;
|
||||
zbottom[1] = fch2;
|
||||
SkyPlane(di, fs, plane_ceiling, true);
|
||||
}
|
||||
|
||||
ztop[0] = zfloor[0];
|
||||
ztop[1] = zfloor[1];
|
||||
zbottom[0] = zbottom[1] = -32768.0f;
|
||||
SkyPlane(di, fs, plane_floor, true);
|
||||
if (fs->floorstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
ztop[0] = ffh1;
|
||||
ztop[1] = ffh2;
|
||||
zbottom[0] = zbottom[1] = -32768.0f;
|
||||
SkyPlane(di, fs, plane_floor, true);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -132,7 +138,7 @@ void HWWall::SkyNormal(HWDrawInfo* di, sectortype* fs, FVector2& v1, FVector2& v
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void HWWall::SkyTop(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype * bs, FVector2& v1, FVector2& v2)
|
||||
void HWWall::SkyTop(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype * bs, FVector2& v1, FVector2& v2, float fch1, float fch2)
|
||||
{
|
||||
if (fs->portalflags == PORTAL_SECTOR_CEILING || fs->portalflags == PORTAL_SECTOR_CEILING_REFLECT)
|
||||
{
|
||||
|
@ -155,30 +161,26 @@ void HWWall::SkyTop(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype *
|
|||
return;
|
||||
}
|
||||
}
|
||||
// stacked sectors
|
||||
ztop[0] = ztop[1] = 32768.0f;
|
||||
PlanesAtPoint(fs, v1.X*16.f, v1.Y*-16.f, &zbottom[0], nullptr);
|
||||
PlanesAtPoint(fs, v2.X * 16.f, v2.Y * -16.f, &zbottom[1], nullptr);
|
||||
}
|
||||
else if (fs->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
float c1, c2, f1, f2;
|
||||
PlanesAtPoint(bs, v1.X * 16.f, v1.Y * -16.f, &c1, &f1);
|
||||
PlanesAtPoint(bs, v2.X * 16.f, v2.Y * -16.f, &c2, &f2);
|
||||
|
||||
if (bs->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
float c1, c2, f1, f2;
|
||||
PlanesAtPoint(bs, v1.X * 16.f, v1.Y * -16.f, &c1, &f1);
|
||||
PlanesAtPoint(bs, v2.X * 16.f, v2.Y * -16.f, &c2, &f2);
|
||||
|
||||
// if the back sector is closed the sky must be drawn!
|
||||
if (c1 > f1 || c2 > f2) return;
|
||||
}
|
||||
|
||||
ztop[0]=ztop[1]=32768.0f;
|
||||
|
||||
zbottom[0] = c1;
|
||||
zbottom[1] = c2;
|
||||
flags|=HWF_SKYHACK; // mid textures on such lines need special treatment!
|
||||
flags |= HWF_SKYHACK; // mid textures on such lines need special treatment!
|
||||
}
|
||||
else return;
|
||||
|
||||
ztop[0] = ztop[1] = 32768.0f;
|
||||
zbottom[0] = fch1;
|
||||
zbottom[1] = fch2;
|
||||
SkyPlane(di, fs, plane_ceiling, true);
|
||||
}
|
||||
|
||||
|
@ -189,7 +191,7 @@ void HWWall::SkyTop(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype *
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void HWWall::SkyBottom(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype * bs, FVector2& v1, FVector2& v2)
|
||||
void HWWall::SkyBottom(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype * bs, FVector2& v1, FVector2& v2, float ffh1, float ffh2)
|
||||
{
|
||||
if (fs->portalflags == PORTAL_SECTOR_FLOOR || fs->portalflags == PORTAL_SECTOR_FLOOR_REFLECT)
|
||||
{
|
||||
|
@ -213,29 +215,25 @@ void HWWall::SkyBottom(HWDrawInfo *di, walltype * seg,sectortype * fs,sectortype
|
|||
}
|
||||
}
|
||||
// stacked sectors
|
||||
zbottom[0] = zbottom[1] = -32768.0f;
|
||||
PlanesAtPoint(fs, v1.X * 16.f, v1.Y * -16.f, nullptr, &ztop[0]);
|
||||
PlanesAtPoint(fs, v2.X * 16.f, v2.Y * -16.f, nullptr, &ztop[0]);
|
||||
}
|
||||
else if (fs->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
else if (fs->floorstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
float c1, c2, f1, f2;
|
||||
PlanesAtPoint(bs, v1.X * 16.f, v1.Y * -16.f, &c1, &f1);
|
||||
PlanesAtPoint(bs, v2.X * 16.f, v2.Y * -16.f, &c2, &f2);
|
||||
|
||||
if (bs->ceilingstat & CSTAT_SECTOR_SKY)
|
||||
if (bs->floorstat & CSTAT_SECTOR_SKY)
|
||||
{
|
||||
// if the back sector is closed the sky must be drawn!
|
||||
if (c1 > f1 || c2 > f2) return;
|
||||
}
|
||||
|
||||
zbottom[0] = zbottom[1] = -32768.0f;
|
||||
|
||||
zbottom[0] = f1;
|
||||
zbottom[1] = f2;
|
||||
flags |= HWF_SKYHACK; // mid textures on such lines need special treatment!
|
||||
}
|
||||
else return;
|
||||
|
||||
zbottom[0] = zbottom[1] = -32768.0f;
|
||||
ztop[0] = ffh1;
|
||||
ztop[1] = ffh2;
|
||||
SkyPlane(di, fs, plane_floor, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "hw_renderstate.h"
|
||||
#include "skyboxtexture.h"
|
||||
|
||||
CVAR(Float, skyoffsettest, 0, 0)
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -51,6 +52,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
||||
|
||||
state.SetVertexBuffer(vertexBuffer);
|
||||
state.SetTextureMode(TM_OPAQUE);
|
||||
auto skybox = origin->texture ? dynamic_cast<FSkyBox*>(origin->texture->GetTexture()) : nullptr;
|
||||
if (skybox)
|
||||
{
|
||||
|
@ -58,10 +60,23 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
}
|
||||
else
|
||||
{
|
||||
state.SetTextureMode(TM_OPAQUE);
|
||||
vertexBuffer->RenderDome(state, origin->texture, origin->x_offset, origin->y_offset, false, FSkyVertexBuffer::SKYMODE_MAINLAYER, false);
|
||||
state.SetTextureMode(TM_NORMAL);
|
||||
auto tex = origin->texture;
|
||||
float texw = tex->GetDisplayWidth();
|
||||
float texh = tex->GetDisplayHeight();
|
||||
auto& modelMatrix = state.mModelMatrix;
|
||||
auto& textureMatrix = state.mTextureMatrix;
|
||||
auto texskyoffset = tex->GetSkyOffset() + origin->y_offset + skyoffsettest;
|
||||
|
||||
modelMatrix.loadIdentity();
|
||||
modelMatrix.rotate(-180.0f + origin->x_offset, 0.f, 1.f, 0.f);
|
||||
modelMatrix.translate(0.f, (-40 + texskyoffset) * skyoffsetfactor, 0.f);
|
||||
//modelMatrix.scale(1.f, 0.8f * 1.17f, 1.f);
|
||||
textureMatrix.loadIdentity();
|
||||
textureMatrix.scale(-1.f, 0.5, 1.f);
|
||||
textureMatrix.translate(1.f, 0/*origin->y_offset / texh*/, 1.f);
|
||||
vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER);
|
||||
}
|
||||
state.SetTextureMode(TM_NORMAL);
|
||||
if (origin->fadecolor & 0xffffff)
|
||||
{
|
||||
PalEntry FadeColor = origin->fadecolor;
|
||||
|
|
|
@ -880,9 +880,9 @@ void HWWall::DoMidTexture(HWDrawInfo* di, walltype* wal,
|
|||
//
|
||||
//
|
||||
//==========================================================================
|
||||
void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sectortype* backsector)
|
||||
void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sectortype* backsector)
|
||||
{
|
||||
auto backwall = wal->nextwall >= 0 && wal->nextwall < numwalls? &wall[wal->nextwall] : nullptr;
|
||||
auto backwall = wal->nextwall >= 0 && wal->nextwall < numwalls ? &wall[wal->nextwall] : nullptr;
|
||||
auto p2wall = &wall[wal->point2];
|
||||
|
||||
float fch1;
|
||||
|
@ -896,8 +896,9 @@ void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sec
|
|||
PlanesAtPoint(frontsector, wal->x, wal->y, &fch1, &ffh1);
|
||||
PlanesAtPoint(frontsector, p2wall->x, p2wall->y, &fch2, &ffh2);
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (wal - wall == 7591)
|
||||
if (wal - wall == 843)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
|
@ -950,10 +951,10 @@ void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sec
|
|||
else if (seg->portalflags == PORTAL_WALL_TO_SPRITE) ptype = PORTALTYPE_LINETOSPRITE;
|
||||
if (ptype != -1)
|
||||
{
|
||||
ztop[0] = zceil[0];
|
||||
ztop[1] = zceil[1];
|
||||
zbottom[0] = zfloor[0];
|
||||
zbottom[1] = zfloor[1];
|
||||
ztop[0] = fch1;
|
||||
ztop[1] = fch2;
|
||||
zbottom[0] = ffh1;
|
||||
zbottom[1] = ffh2;
|
||||
PutPortal(di, ptype, -1);
|
||||
return;
|
||||
}
|
||||
|
@ -963,7 +964,7 @@ void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sec
|
|||
if (!backsector || !backwall)
|
||||
{
|
||||
// sector's sky
|
||||
SkyNormal(di, frontsector, v1, v2);
|
||||
SkyNormal(di, frontsector, v1, v2, fch1, fch2, ffh1, ffh2);
|
||||
|
||||
// normal texture
|
||||
|
||||
|
@ -987,8 +988,11 @@ void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sec
|
|||
|
||||
float zalign = 0.f;
|
||||
|
||||
SkyTop(di, wal, frontsector, backsector, v1, v2);
|
||||
SkyBottom(di, wal, frontsector, backsector, v1, v2);
|
||||
if (fch1 > ffh1 || fch2 > ffh2)
|
||||
{
|
||||
SkyTop(di, wal, frontsector, backsector, v1, v2, fch1, fch2);
|
||||
SkyBottom(di, wal, frontsector, backsector, v1, v2, ffh1, ffh2);
|
||||
}
|
||||
|
||||
// upper texture
|
||||
if (!(frontsector->ceilingstat & backsector->ceilingstat & CSTAT_SECTOR_SKY))
|
||||
|
|
Loading…
Reference in a new issue