- fixed translucent voxel rendering.

This commit is contained in:
Christoph Oelckers 2021-11-28 18:05:19 +01:00
parent 793aaf242c
commit 35c2d6d14e
2 changed files with 27 additions and 3 deletions

View file

@ -3927,6 +3927,29 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate)
auto tex = TexMan.GetGameTexture(m->model->GetPaletteTexture());
GLInterface.SetTexture(tex, TRANSLATION(Translation_Remap + curbasepal, globalpal), CLAMP_NOFILTER_XY, true);
GLInterface.SetModel(m->model, 0, 0, 0);
// The shade rgb from the tint is ignored here.
pc[0] = (float)globalr * (1.f / 255.f);
pc[1] = (float)globalg * (1.f / 255.f);
pc[2] = (float)globalb * (1.f / 255.f);
bool trans = (tspr->cstat & CSTAT_SPRITE_TRANSLUCENT);
float alpha;
FRenderStyle RenderStyle;
if (trans)
{
RenderStyle = GetRenderStyle(0, !!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT));
alpha = GetAlphaFromBlend((tspr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0);
}
else
{
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
alpha = 1.f;
}
alpha *= 1.f - spriteext[tspr->owner].alpha;
GLInterface.SetRenderStyle(RenderStyle);
GLInterface.SetColor(pc[0], pc[1], pc[2], alpha);
GLInterface.Draw(DT_Triangles, 0, 0);
GLInterface.SetModel(nullptr, 0, 0, 0);
GLInterface.SetCull(Cull_None);

View file

@ -144,17 +144,19 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent)
}
else
{
state.EnableModelMatrix(true);
state.mModelMatrix = rotmat;
FHWModelRenderer mr(state, dynlightindex);
if (modelframe < 0)
{
state.mModelMatrix = rotmat;
auto model = voxel->model;
state.SetDepthFunc(DF_LEqual);
state.EnableTexture(true);
model->BuildVertexBuffer(&mr);
mr.BeginDrawModel(RenderStyle, nullptr, rotmat, portalState.isMirrored());
mr.SetupFrame(model, 0, 0, 0);
model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette));
mr.EndDrawModel(RenderStyle, nullptr);
state.SetDepthFunc(DF_Less);
state.SetVertexBuffer(screen->mVertexData);
@ -165,7 +167,6 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent)
}
state.SetObjectColor(0xffffffff);
state.SetVertexBuffer(screen->mVertexData);
state.EnableModelMatrix(false);
}
if (translucent)