- pass shade values to sky renderer

This commit is contained in:
Christoph Oelckers 2022-04-19 14:44:10 +02:00
parent 6354c1889d
commit 380864d6fb
4 changed files with 21 additions and 14 deletions

View file

@ -455,7 +455,7 @@ void FSkyVertexBuffer::RenderRow(FRenderState& state, EDrawType prim, int row, T
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which) void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color)
{ {
auto& primStart = which ? mPrimStartBuild : mPrimStartDoom; auto& primStart = which ? mPrimStartBuild : mPrimStartDoom;
if (tex && tex->isValid()) if (tex && tex->isValid())
@ -471,6 +471,13 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mo
if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != nullptr) if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != nullptr)
{ {
auto& col = R_GetSkyCapColor(tex); auto& col = R_GetSkyCapColor(tex);
col.first.r = col.first.r * color.r / 255;
col.first.g = col.first.g * color.g / 255;
col.first.b = col.first.b * color.b / 255;
col.second.r = col.second.r * color.r / 255;
col.second.g = col.second.g * color.g / 255;
col.second.b = col.second.b * color.b / 255;
state.SetObjectColor(col.first); state.SetObjectColor(col.first);
state.EnableTexture(false); state.EnableTexture(false);
RenderRow(state, DT_TriangleFan, 0, primStart); RenderRow(state, DT_TriangleFan, 0, primStart);
@ -497,13 +504,13 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mo
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale, float yscale) void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale, float yscale, PalEntry color)
{ {
if (tex) if (tex)
{ {
SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale); SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale);
} }
RenderDome(state, tex, mode, false); RenderDome(state, tex, mode, false, color);
} }
@ -513,10 +520,11 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void FSkyVertexBuffer::RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2) void FSkyVertexBuffer::RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color)
{ {
int faces; int faces;
state.SetObjectColor(color);
state.EnableModelMatrix(true); state.EnableModelMatrix(true);
state.mModelMatrix.loadIdentity(); state.mModelMatrix.loadIdentity();
state.mModelMatrix.scale(1, 1 / stretch, 1); // Undo the map's vertical scaling as skyboxes are true cubes. state.mModelMatrix.scale(1, 1 / stretch, 1); // Undo the map's vertical scaling as skyboxes are true cubes.

View file

@ -90,8 +90,8 @@ public:
} }
void RenderRow(FRenderState& state, EDrawType prim, int row, TArray<unsigned int>& mPrimStart, bool apply = true); void RenderRow(FRenderState& state, EDrawType prim, int row, TArray<unsigned int>& mPrimStart, bool apply = true);
void RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which); void RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color = 0xffffffff);
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 RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0, PalEntry color = 0xffffffff);
void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2); void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color = 0xffffffff);
}; };

View file

@ -88,7 +88,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane)
pe.a = 230; pe.a = 230;
sky->fadecolor = pe; sky->fadecolor = pe;
sky->shade = 0;// clamp(plane == plane_ceiling ? sector->ceilingshade : sector->floorshade, 0, numshades - 1); sky->shade = clamp<int>(plane == plane_ceiling ? sector->ceilingshade : sector->floorshade, 0, numshades - 1);
sky->texture = skytex; sky->texture = skytex;
} }
@ -119,12 +119,10 @@ void HWWall::SkyPlane(HWDrawInfo *di, sectortype *sector, int plane, bool allowr
} }
else else
{ {
ptype = PORTALTYPE_SKY;
HWSkyInfo skyinfo; HWSkyInfo skyinfo;
initSkyInfo(di, &skyinfo, sector, plane); initSkyInfo(di, &skyinfo, sector, plane);
ptype = PORTALTYPE_SKY;
sky = &skyinfo; sky = &skyinfo;
PutPortal(di, ptype, plane); PutPortal(di, PORTALTYPE_SKY, plane);
} }
} }

View file

@ -45,6 +45,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
state.AlphaFunc(Alpha_GEqual, 0.f); state.AlphaFunc(Alpha_GEqual, 0.f);
state.SetRenderStyle(STYLE_Translucent); state.SetRenderStyle(STYLE_Translucent);
bool oldClamp = state.SetDepthClamp(true); bool oldClamp = state.SetDepthClamp(true);
auto color = shadeToLight(origin->shade);
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
@ -53,7 +54,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
auto skybox = origin->texture ? dynamic_cast<FSkyBox*>(origin->texture->GetTexture()) : nullptr; auto skybox = origin->texture ? dynamic_cast<FSkyBox*>(origin->texture->GetTexture()) : nullptr;
if (skybox) if (skybox)
{ {
vertexBuffer->RenderBox(state, skybox, origin->x_offset, false, /*di->Level->info->pixelstretch*/1, { 0, 0, 1 }, { 0, 0, 1 }); vertexBuffer->RenderBox(state, skybox, origin->x_offset, false, /*di->Level->info->pixelstretch*/1, { 0, 0, 1 }, { 0, 0, 1 }, color);
} }
else if (!origin->cloudy) else if (!origin->cloudy)
{ {
@ -77,12 +78,12 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
textureMatrix.loadIdentity(); textureMatrix.loadIdentity();
state.EnableTextureMatrix(true); state.EnableTextureMatrix(true);
textureMatrix.scale(1.f, repeat_fac, 1.f); textureMatrix.scale(1.f, repeat_fac, 1.f);
vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER, true); vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER, true, 0, 0, color);
state.EnableTextureMatrix(false); state.EnableTextureMatrix(false);
} }
else else
{ {
vertexBuffer->RenderDome(state, origin->texture, -origin->x_offset, origin->y_offset, false, FSkyVertexBuffer::SKYMODE_MAINLAYER, true); vertexBuffer->RenderDome(state, origin->texture, -origin->x_offset, origin->y_offset, false, FSkyVertexBuffer::SKYMODE_MAINLAYER, true, 0, 0, color);
} }
state.SetTextureMode(TM_NORMAL); state.SetTextureMode(TM_NORMAL);
if (origin->fadecolor & 0xffffff) if (origin->fadecolor & 0xffffff)