- transitioned sky and decal code away from FMaterial.
This commit is contained in:
parent
cca3f878f5
commit
4cbd20e822
10 changed files with 65 additions and 72 deletions
|
|
@ -47,8 +47,6 @@
|
|||
|
||||
void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
||||
{
|
||||
auto tex = gltexture;
|
||||
|
||||
// calculate dynamic light effect.
|
||||
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && gl_light_sprites)
|
||||
{
|
||||
|
|
@ -68,7 +66,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
|||
|
||||
state.SetTextureMode(decal->RenderStyle);
|
||||
state.SetRenderStyle(decal->RenderStyle);
|
||||
state.SetMaterial(tex, CLAMP_XY, decal->Translation, -1);
|
||||
state.SetMaterial(texture, false, CLAMP_XY, decal->Translation, -1);
|
||||
|
||||
|
||||
// If srcalpha is one it looks better with a higher alpha threshold
|
||||
|
|
@ -313,8 +311,6 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
|
|||
float vx = (glseg.x2 - glseg.x1) / linelength;
|
||||
float vy = (glseg.y2 - glseg.y1) / linelength;
|
||||
|
||||
FMaterial* tex = FMaterial::ValidateTexture(texture->GetTexture(), false);
|
||||
|
||||
DecalVertex dv[4];
|
||||
enum
|
||||
{
|
||||
|
|
@ -330,11 +326,12 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
|
|||
|
||||
dv[UL].z = dv[UR].z = zpos;
|
||||
dv[LL].z = dv[LR].z = dv[UL].z - decalheight;
|
||||
dv[UL].v = dv[UR].v = tex->GetVT();
|
||||
dv[UL].v = dv[UR].v = 0.f;
|
||||
|
||||
dv[UL].u = dv[LL].u = tex->GetU(lefttex / decal->ScaleX);
|
||||
dv[LR].u = dv[UR].u = tex->GetU(righttex / decal->ScaleX);
|
||||
dv[LL].v = dv[LR].v = tex->GetVB();
|
||||
float decalscale = float(decal->ScaleX * texture->GetDisplayWidth());
|
||||
dv[UL].u = dv[LL].u = lefttex / decalscale;
|
||||
dv[LR].u = dv[UR].u = righttex / decalscale;
|
||||
dv[LL].v = dv[LR].v = 1.f;
|
||||
|
||||
// now clip to the top plane
|
||||
float vzt = (ztop[UL] - ztop[LL]) / linelength;
|
||||
|
|
@ -377,17 +374,15 @@ void HWWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
|
|||
|
||||
if (flipx)
|
||||
{
|
||||
float ur = tex->GetUR();
|
||||
for (i = 0; i < 4; i++) dv[i].u = ur - dv[i].u;
|
||||
for (i = 0; i < 4; i++) dv[i].u = 1.f - dv[i].u;
|
||||
}
|
||||
if (flipy)
|
||||
{
|
||||
float vb = tex->GetVB();
|
||||
for (i = 0; i < 4; i++) dv[i].v = vb - dv[i].v;
|
||||
for (i = 0; i < 4; i++) dv[i].v = 1.f - dv[i].v;
|
||||
}
|
||||
|
||||
HWDecal *gldecal = di->AddDecal(type == RENDERWALL_MIRRORSURFACE);
|
||||
gldecal->gltexture = tex;
|
||||
gldecal->texture = texture;
|
||||
gldecal->decal = decal;
|
||||
|
||||
if (decal->RenderFlags & RF_FULLBRIGHT)
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ struct DecalVertex
|
|||
|
||||
struct HWDecal
|
||||
{
|
||||
FMaterial *gltexture;
|
||||
FGameTexture *texture;
|
||||
TArray<lightlist_t> *lightlist;
|
||||
DBaseDecal *decal;
|
||||
DecalVertex dv[4];
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct HWSkyInfo
|
|||
{
|
||||
float x_offset[2];
|
||||
float y_offset; // doubleskies don't have a y-offset
|
||||
FMaterial * texture[2];
|
||||
FGameTexture * texture[2];
|
||||
FTextureID skytexno1;
|
||||
bool mirrored;
|
||||
bool doublesky;
|
||||
|
|
@ -358,8 +358,8 @@ struct HWSkyPortal : public HWPortal
|
|||
friend struct HWEEHorizonPortal;
|
||||
|
||||
void RenderRow(HWDrawInfo *di, FRenderState &state, EDrawType prim, int row, bool apply = true);
|
||||
void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FMaterial * gltex, float x_offset, bool sky2);
|
||||
void RenderDome(HWDrawInfo *di, FRenderState &state, FMaterial * tex, float x_offset, float y_offset, bool mirror, int mode);
|
||||
void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * gltex, float x_offset, bool sky2);
|
||||
void RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * tex, float x_offset, float y_offset, bool mirror, int mode);
|
||||
|
||||
protected:
|
||||
virtual void DrawContents(HWDrawInfo *di, FRenderState &state);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
|||
FTextureID texno = s->GetTexture(pos);
|
||||
auto tex = TexMan.GetGameTexture(texno, true);
|
||||
if (!tex || !tex->isValid()) goto normalsky;
|
||||
texture[0] = FMaterial::ValidateTexture(tex->GetTexture(), false);
|
||||
texture[0] = tex;
|
||||
skytexno1 = texno;
|
||||
x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f);
|
||||
y_offset = s->GetTextureYOffset(pos);
|
||||
|
|
@ -76,7 +76,7 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
|||
{
|
||||
auto tex1 = TexMan.GetGameTexture(di->Level->skytexture1, true);
|
||||
if (tex1) tex1 = tex1->GetFrontSkyLayer();
|
||||
texture[1] = FMaterial::ValidateTexture(tex1->GetTexture(), false);
|
||||
texture[1] = tex1;
|
||||
x_offset[1] = di->Level->hw_sky1pos;
|
||||
doublesky = true;
|
||||
}
|
||||
|
|
@ -84,14 +84,14 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
|||
if ((di->Level->flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (di->Level->flags&LEVEL_DOUBLESKY)) &&
|
||||
di->Level->skytexture2 != di->Level->skytexture1) // If both skies are equal use the scroll offset of the first!
|
||||
{
|
||||
texture[0] = FMaterial::ValidateTexture(di->Level->skytexture2, false, true);
|
||||
texture[0] = TexMan.GetGameTexture(di->Level->skytexture2, true);
|
||||
skytexno1 = di->Level->skytexture2;
|
||||
sky2 = true;
|
||||
x_offset[0] = di->Level->hw_sky2pos;
|
||||
}
|
||||
else if (!doublesky)
|
||||
{
|
||||
texture[0] = FMaterial::ValidateTexture(di->Level->skytexture1, false, true);
|
||||
texture[0] = TexMan.GetGameTexture(di->Level->skytexture1, true);
|
||||
skytexno1 = di->Level->skytexture1;
|
||||
x_offset[0] = di->Level->hw_sky1pos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,17 +282,17 @@ void FSkyVertexBuffer::CreateDome()
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FSkyVertexBuffer::SetupMatrices(HWDrawInfo *di, FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix)
|
||||
void FSkyVertexBuffer::SetupMatrices(HWDrawInfo *di, FGameTexture *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix)
|
||||
{
|
||||
int texw = tex->TextureWidth();
|
||||
int texh = tex->TextureHeight();
|
||||
int texw = tex->GetDisplayWidth();
|
||||
int texh = tex->GetDisplayHeight();
|
||||
|
||||
modelMatrix.loadIdentity();
|
||||
modelMatrix.rotate(-180.0f + x_offset, 0.f, 1.f, 0.f);
|
||||
|
||||
float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f;
|
||||
float yscale = 1.f;
|
||||
auto texskyoffset = tex->Source()->GetSkyOffset() + skyoffset;
|
||||
auto texskyoffset = tex->GetSkyOffset() + skyoffset;
|
||||
if (texh <= 128 && (di->Level->flags & LEVEL_FORCETILEDSKY))
|
||||
{
|
||||
modelMatrix.translate(0.f, (-40 + texskyoffset)*skyoffsetfactor, 0.f);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "matrix.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
|
||||
class FMaterial;
|
||||
class FGameTexture;
|
||||
class FRenderState;
|
||||
class IVertexBuffer;
|
||||
struct HWSkyPortal;
|
||||
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
FSkyVertexBuffer();
|
||||
~FSkyVertexBuffer();
|
||||
void SetupMatrices(HWDrawInfo *di, FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelmatrix, VSMatrix &textureMatrix);
|
||||
void SetupMatrices(HWDrawInfo *di, FGameTexture *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelmatrix, VSMatrix &textureMatrix);
|
||||
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
||||
{
|
||||
return std::make_pair(mVertexBuffer, nullptr);
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ void HWSkyPortal::RenderRow(HWDrawInfo *di, FRenderState &state, EDrawType prim,
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FMaterial * tex, float x_offset, float y_offset, bool mirror, int mode)
|
||||
void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * tex, float x_offset, float y_offset, bool mirror, int mode)
|
||||
{
|
||||
if (tex)
|
||||
{
|
||||
state.SetMaterial(tex, CLAMP_NONE, 0, -1);
|
||||
state.SetMaterial(tex, false, CLAMP_NONE, 0, -1);
|
||||
state.EnableModelMatrix(true);
|
||||
state.EnableTextureMatrix(true);
|
||||
|
||||
|
|
@ -66,13 +66,12 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FMaterial * te
|
|||
// The caps only get drawn for the main layer but not for the overlay.
|
||||
if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != NULL)
|
||||
{
|
||||
auto base = tex->Source();
|
||||
PalEntry pe = base->GetSkyCapColor(false);
|
||||
PalEntry pe = tex->GetSkyCapColor(false);
|
||||
state.SetObjectColor(pe);
|
||||
state.EnableTexture(false);
|
||||
RenderRow(di, state, DT_TriangleFan, 0);
|
||||
|
||||
pe = base->GetSkyCapColor(true);
|
||||
pe = tex->GetSkyCapColor(true);
|
||||
state.SetObjectColor(pe);
|
||||
RenderRow(di, state, DT_TriangleFan, rc);
|
||||
state.EnableTexture(true);
|
||||
|
|
@ -95,9 +94,9 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FMaterial * te
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FMaterial * gltex, float x_offset, bool sky2)
|
||||
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * gltex, float x_offset, bool sky2)
|
||||
{
|
||||
FSkyBox * sb = static_cast<FSkyBox*>(gltex->Source());
|
||||
FSkyBox * sb = static_cast<FSkyBox*>(gltex->GetTexture());
|
||||
int faces;
|
||||
FMaterial * tex;
|
||||
|
||||
|
|
@ -182,7 +181,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
||||
|
||||
state.SetVertexBuffer(vertexBuffer);
|
||||
if (origin->texture[0] && origin->texture[0]->Source()->isSkybox())
|
||||
if (origin->texture[0] && origin->texture[0]->isSkybox())
|
||||
{
|
||||
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue