Change visstyle_t back to how it was in ZDoom and stop using it internally in the swrenderer

This commit is contained in:
Magnus Norddahl 2017-01-16 16:23:02 +01:00
parent 1c3440e391
commit 6c76c8534b
13 changed files with 231 additions and 220 deletions

View file

@ -791,8 +791,7 @@ int APowerInvisibility::AlterWeaponSprite (visstyle_t *vis)
if ((vis->Alpha < 0.25f && special1 > 0) || (vis->Alpha == 0)) if ((vis->Alpha < 0.25f && special1 > 0) || (vis->Alpha == 0))
{ {
vis->Alpha = clamp((1.f - float(Strength/100)), 0.f, 1.f); vis->Alpha = clamp((1.f - float(Strength/100)), 0.f, 1.f);
vis->BaseColormap = &SpecialColormaps[INVERSECOLORMAP]; vis->colormap = SpecialColormaps[INVERSECOLORMAP].Colormap;
vis->ColormapNum = 0;
} }
return -1; // This item is valid so another one shouldn't reset the translucency return -1; // This item is valid so another one shouldn't reset the translucency
} }

View file

@ -213,36 +213,36 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
FDynamicColormap *basecolormap = viewsector->ColorMap; FDynamicColormap *basecolormap = viewsector->ColorMap;
FDynamicColormap *colormap_to_use = basecolormap; FDynamicColormap *colormap_to_use = basecolormap;
visstyle_t visstyle; int ColormapNum = 0;
visstyle.ColormapNum = 0; FSWColormap *BaseColormap = basecolormap;
visstyle.BaseColormap = basecolormap; float Alpha = 0;
visstyle.Alpha = 0; FRenderStyle RenderStyle;
visstyle.RenderStyle = STYLE_Normal; RenderStyle = STYLE_Normal;
bool foggy = false; bool foggy = false;
int actualextralight = foggy ? 0 : extralight << 4; int actualextralight = foggy ? 0 : extralight << 4;
int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight); int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight);
double minz = double((2048 * 4) / double(1 << 20)); double minz = double((2048 * 4) / double(1 << 20));
visstyle.ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / minz, spriteshade); ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / minz, spriteshade);
if (sprite->GetID() < PSP_TARGETCENTER) if (sprite->GetID() < PSP_TARGETCENTER)
{ {
visstyle.Alpha = float(owner->Alpha); Alpha = float(owner->Alpha);
visstyle.RenderStyle = owner->RenderStyle; RenderStyle = owner->RenderStyle;
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
// too. That means if the source is inverted, we need to do the reverse of what // too. That means if the source is inverted, we need to do the reverse of what
// the invert overlay flag says to do. // the invert overlay flag says to do.
INTBOOL invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay); INTBOOL invertcolormap = (RenderStyle.Flags & STYLEF_InvertOverlay);
if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) if (RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
FDynamicColormap *mybasecolormap = basecolormap; FDynamicColormap *mybasecolormap = basecolormap;
if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) if (RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -258,8 +258,8 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
/* /*
if (swrenderer::realfixedcolormap != nullptr && (!swrenderer::r_swtruecolor || (r_shadercolormaps && screen->Accel2D))) if (swrenderer::realfixedcolormap != nullptr && (!swrenderer::r_swtruecolor || (r_shadercolormaps && screen->Accel2D)))
{ // fixed color { // fixed color
visstyle.BaseColormap = swrenderer::realfixedcolormap; BaseColormap = swrenderer::realfixedcolormap;
visstyle.ColormapNum = 0; ColormapNum = 0;
} }
else else
{ {
@ -269,49 +269,46 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
} }
if (swrenderer::fixedlightlev >= 0) if (swrenderer::fixedlightlev >= 0)
{ {
visstyle.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap;
visstyle.ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT; ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT;
} }
else if (!foggy && sprite->GetState()->GetFullbright()) else if (!foggy && sprite->GetState()->GetFullbright())
{ // full bright { // full bright
visstyle.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap
visstyle.ColormapNum = 0; ColormapNum = 0;
} }
else else
{ // local light { // local light
visstyle.BaseColormap = mybasecolormap; BaseColormap = mybasecolormap;
visstyle.ColormapNum = GETPALOOKUP(0, spriteshade); ColormapNum = GETPALOOKUP(0, spriteshade);
} }
} }
*/ */
if (camera->Inventory != nullptr) if (camera->Inventory != nullptr)
{ {
BYTE oldcolormapnum = visstyle.ColormapNum; visstyle_t visstyle;
FSWColormap *oldcolormap = visstyle.BaseColormap; visstyle.Alpha = Alpha;
visstyle.RenderStyle = RenderStyle;
visstyle.colormap = nullptr; // Same as the GL render is doing.
camera->Inventory->AlterWeaponSprite(&visstyle); camera->Inventory->AlterWeaponSprite(&visstyle);
if (visstyle.BaseColormap != oldcolormap || visstyle.ColormapNum != oldcolormapnum)
RenderStyle = visstyle.RenderStyle;
Alpha = visstyle.Alpha;
// Only bother checking for the one type it changes it to until this has been ZScript'ed..
if (visstyle.colormap == SpecialColormaps[INVERSECOLORMAP].Colormap)
{ {
// The colormap has changed. Is it one we can easily identify? BaseColormap = &SpecialColormaps[INVERSECOLORMAP];
// If not, then don't bother trying to identify it for ColormapNum = 0;
// hardware accelerated drawing.
if (visstyle.BaseColormap < &SpecialColormaps[0] ||
visstyle.BaseColormap > &SpecialColormaps.Last())
{
noaccel = true;
}
// Has the basecolormap changed? If so, we can't hardware accelerate it,
// since we don't know what it is anymore.
else if (visstyle.BaseColormap != mybasecolormap)
{
noaccel = true;
}
} }
} }
// If we're drawing with a special colormap, but shaders for them are disabled, do // If we're drawing with a special colormap, but shaders for them are disabled, do
// not accelerate. // not accelerate.
if (!r_shadercolormaps && (visstyle.BaseColormap >= &SpecialColormaps[0] && if (!r_shadercolormaps && (BaseColormap >= &SpecialColormaps[0] &&
visstyle.BaseColormap <= &SpecialColormaps.Last())) BaseColormap <= &SpecialColormaps.Last()))
{ {
noaccel = true; noaccel = true;
} }
@ -340,7 +337,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
// fuzzy, don't draw it until after the switch to 2D mode. // fuzzy, don't draw it until after the switch to 2D mode.
if (!noaccel && swrenderer::RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) if (!noaccel && swrenderer::RenderTarget == screen && (DFrameBuffer *)screen->Accel2D)
{ {
FRenderStyle style = visstyle.RenderStyle; FRenderStyle style = RenderStyle;
style.CheckFuzz(); style.CheckFuzz();
if (style.BlendOp != STYLEOP_Fuzz) if (style.BlendOp != STYLEOP_Fuzz)
{ {
@ -352,7 +349,10 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
screenSprite.Height = tex->GetHeight() * yscale; screenSprite.Height = tex->GetHeight() * yscale;
screenSprite.Translation = TranslationToTable(translation); screenSprite.Translation = TranslationToTable(translation);
screenSprite.Flip = xiscale < 0; screenSprite.Flip = xiscale < 0;
screenSprite.visstyle = visstyle; screenSprite.Alpha = Alpha;
screenSprite.RenderStyle = RenderStyle;
screenSprite.BaseColormap = BaseColormap;
screenSprite.ColormapNum = ColormapNum;
screenSprite.Colormap = colormap_to_use; screenSprite.Colormap = colormap_to_use;
ScreenSprites.push_back(screenSprite); ScreenSprites.push_back(screenSprite);
return; return;
@ -362,11 +362,11 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
// To do: draw sprite same way as R_DrawVisSprite(vis) here // To do: draw sprite same way as R_DrawVisSprite(vis) here
// Draw the fuzzy weapon: // Draw the fuzzy weapon:
FRenderStyle style = visstyle.RenderStyle; FRenderStyle style = RenderStyle;
style.CheckFuzz(); style.CheckFuzz();
if (style.BlendOp == STYLEOP_Fuzz) if (style.BlendOp == STYLEOP_Fuzz)
{ {
visstyle.RenderStyle = LegacyRenderStyles[STYLE_Shadow]; RenderStyle = LegacyRenderStyles[STYLE_Shadow];
PolyScreenSprite screenSprite; PolyScreenSprite screenSprite;
screenSprite.Pic = tex; screenSprite.Pic = tex;
@ -376,7 +376,10 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
screenSprite.Height = tex->GetHeight() * yscale; screenSprite.Height = tex->GetHeight() * yscale;
screenSprite.Translation = TranslationToTable(translation); screenSprite.Translation = TranslationToTable(translation);
screenSprite.Flip = xiscale < 0; screenSprite.Flip = xiscale < 0;
screenSprite.visstyle = visstyle; screenSprite.Alpha = Alpha;
screenSprite.RenderStyle = RenderStyle;
screenSprite.BaseColormap = BaseColormap;
screenSprite.ColormapNum = ColormapNum;
screenSprite.Colormap = colormap_to_use; screenSprite.Colormap = colormap_to_use;
ScreenSprites.push_back(screenSprite); ScreenSprites.push_back(screenSprite);
} }
@ -388,16 +391,16 @@ void PolyScreenSprite::Render()
FColormapStyle colormapstyle; FColormapStyle colormapstyle;
PalEntry overlay = 0; PalEntry overlay = 0;
bool usecolormapstyle = false; bool usecolormapstyle = false;
if (visstyle.BaseColormap >= &SpecialColormaps[0] && if (BaseColormap >= &SpecialColormaps[0] &&
visstyle.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) BaseColormap < &SpecialColormaps[SpecialColormaps.Size()])
{ {
special = static_cast<FSpecialColormap*>(visstyle.BaseColormap); special = static_cast<FSpecialColormap*>(BaseColormap);
} }
else if (Colormap->Color == PalEntry(255, 255, 255) && else if (Colormap->Color == PalEntry(255, 255, 255) &&
Colormap->Desaturate == 0) Colormap->Desaturate == 0)
{ {
overlay = Colormap->Fade; overlay = Colormap->Fade;
overlay.a = BYTE(visstyle.ColormapNum * 255 / NUMCOLORMAPS); overlay.a = BYTE(ColormapNum * 255 / NUMCOLORMAPS);
} }
else else
{ {
@ -405,7 +408,7 @@ void PolyScreenSprite::Render()
colormapstyle.Color = Colormap->Color; colormapstyle.Color = Colormap->Color;
colormapstyle.Fade = Colormap->Fade; colormapstyle.Fade = Colormap->Fade;
colormapstyle.Desaturate = Colormap->Desaturate; colormapstyle.Desaturate = Colormap->Desaturate;
colormapstyle.FadeLevel = visstyle.ColormapNum / float(NUMCOLORMAPS); colormapstyle.FadeLevel = ColormapNum / float(NUMCOLORMAPS);
} }
screen->DrawTexture(Pic, screen->DrawTexture(Pic,
@ -421,8 +424,8 @@ void PolyScreenSprite::Render()
DTA_ClipTop, viewwindowy, DTA_ClipTop, viewwindowy,
DTA_ClipRight, viewwindowx + viewwidth, DTA_ClipRight, viewwindowx + viewwidth,
DTA_ClipBottom, viewwindowy + viewheight, DTA_ClipBottom, viewwindowy + viewheight,
DTA_AlphaF, visstyle.Alpha, DTA_AlphaF, Alpha,
DTA_RenderStyle, visstyle.RenderStyle, DTA_RenderStyle, RenderStyle,
DTA_FillColor, FillColor, DTA_FillColor, FillColor,
DTA_SpecialColormap, special, DTA_SpecialColormap, special,
DTA_ColorOverlay, overlay.d, DTA_ColorOverlay, overlay.d,

View file

@ -22,8 +22,11 @@
#pragma once #pragma once
#include "r_defs.h"
class PolyScreenSprite; class PolyScreenSprite;
class DPSprite; class DPSprite;
struct FSWColormap;
class RenderPolyPlayerSprites class RenderPolyPlayerSprites
{ {
@ -53,7 +56,10 @@ public:
double Height = 0.0; double Height = 0.0;
FRemapTable *Translation = nullptr; FRemapTable *Translation = nullptr;
bool Flip = false; bool Flip = false;
visstyle_t visstyle; float Alpha = 1;
FRenderStyle RenderStyle;
FSWColormap *BaseColormap = nullptr;
int ColormapNum = 0;
uint32_t FillColor = 0; uint32_t FillColor = 0;
FDynamicColormap *Colormap = nullptr; FDynamicColormap *Colormap = nullptr;
}; };

View file

@ -290,6 +290,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing)
return false; return false;
} }
#if 0
visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z) visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z)
{ {
visstyle_t visstyle; visstyle_t visstyle;
@ -298,16 +299,17 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z)
int actualextralight = foggy ? 0 : extralight << 4; int actualextralight = foggy ? 0 : extralight << 4;
int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight); int spriteshade = LIGHT2SHADE(thing->Sector->lightlevel + actualextralight);
visstyle.RenderStyle = thing->RenderStyle; FRenderStyle RenderStyle;
visstyle.Alpha = float(thing->Alpha); RenderStyle = thing->RenderStyle;
visstyle.ColormapNum = 0; float Alpha = float(thing->Alpha);
int ColormapNum = 0;
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
// too. That means if the source is inverted, we need to do the reverse of what // too. That means if the source is inverted, we need to do the reverse of what
// the invert overlay flag says to do. // the invert overlay flag says to do.
bool invertcolormap = (visstyle.RenderStyle.Flags & STYLEF_InvertOverlay) != 0; bool invertcolormap = (RenderStyle.Flags & STYLEF_InvertOverlay) != 0;
if (visstyle.RenderStyle.Flags & STYLEF_InvertSource) if (RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
@ -315,12 +317,12 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z)
FDynamicColormap *mybasecolormap = thing->Sector->ColorMap; FDynamicColormap *mybasecolormap = thing->Sector->ColorMap;
// Sprites that are added to the scene must fade to black. // Sprites that are added to the scene must fade to black.
if (visstyle.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) if (RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0)
{ {
mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate);
} }
if (visstyle.RenderStyle.Flags & STYLEF_FadeToBlack) if (RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -336,8 +338,8 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z)
// get light level // get light level
if (swrenderer::fixedcolormap != nullptr) if (swrenderer::fixedcolormap != nullptr)
{ // fixed map { // fixed map
visstyle.BaseColormap = swrenderer::fixedcolormap; BaseColormap = swrenderer::fixedcolormap;
visstyle.ColormapNum = 0; ColormapNum = 0;
} }
else else
{ {
@ -347,24 +349,25 @@ visstyle_t RenderPolySprite::GetSpriteVisStyle(AActor *thing, double z)
} }
if (swrenderer::fixedlightlev >= 0) if (swrenderer::fixedlightlev >= 0)
{ {
visstyle.BaseColormap = mybasecolormap; BaseColormap = mybasecolormap;
visstyle.ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT; ColormapNum = swrenderer::fixedlightlev >> COLORMAPSHIFT;
} }
else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) else if (!foggy && ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)))
{ // full bright { // full bright
visstyle.BaseColormap = mybasecolormap; BaseColormap = mybasecolormap;
visstyle.ColormapNum = 0; ColormapNum = 0;
} }
else else
{ // diminished light { // diminished light
double minz = double((2048 * 4) / double(1 << 20)); double minz = double((2048 * 4) / double(1 << 20));
visstyle.ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / MAX(z, minz), spriteshade); ColormapNum = GETPALOOKUP(swrenderer::r_SpriteVisibility / MAX(z, minz), spriteshade);
visstyle.BaseColormap = mybasecolormap; BaseColormap = mybasecolormap;
} }
} }
return visstyle; return visstyle;
} }
#endif
FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX) FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
{ {

View file

@ -36,5 +36,5 @@ public:
static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX); static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
private: private:
visstyle_t GetSpriteVisStyle(AActor *thing, double z); //visstyle_t GetSpriteVisStyle(AActor *thing, double z);
}; };

View file

@ -1484,14 +1484,11 @@ struct FMiniBSP
// //
typedef BYTE lighttable_t; // This could be wider for >8 bit display. typedef BYTE lighttable_t; // This could be wider for >8 bit display.
struct FSWColormap;
// This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite // This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite
struct visstyle_t struct visstyle_t
{ {
int ColormapNum; // Which colormap is rendered lighttable_t *colormap;
FSWColormap *BaseColormap; // Base colormap used together with ColormapNum
lighttable_t *colormap; // [SP] Restored from GZDoom - will this work?
float Alpha; float Alpha;
FRenderStyle RenderStyle; FRenderStyle RenderStyle;
}; };

View file

@ -197,29 +197,29 @@ namespace swrenderer
vis->renderflags = (short)(particle->alpha * 255.0f + 0.5f); vis->renderflags = (short)(particle->alpha * 255.0f + 0.5f);
vis->FakeFlatStat = fakeside; vis->FakeFlatStat = fakeside;
vis->floorclip = 0; vis->floorclip = 0;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
vis->foggy = foggy; vis->foggy = foggy;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
vis->Style.BaseColormap = map; vis->BaseColormap = map;
vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; vis->ColormapNum = fixedlightlev >> COLORMAPSHIFT;
} }
else if (fixedcolormap) else if (fixedcolormap)
{ {
vis->Style.BaseColormap = fixedcolormap; vis->BaseColormap = fixedcolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else if (particle->bright) else if (particle->bright)
{ {
vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : map; vis->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : map;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ {
// Particles are slightly more visible than regular sprites. // Particles are slightly more visible than regular sprites.
vis->Style.ColormapNum = GETPALOOKUP(tiz * r_SpriteVisibility * 0.5, shade); vis->ColormapNum = GETPALOOKUP(tiz * r_SpriteVisibility * 0.5, shade);
vis->Style.BaseColormap = map; vis->BaseColormap = map;
} }
VisibleSpriteList::Instance()->Push(vis); VisibleSpriteList::Instance()->Push(vis);
@ -232,7 +232,7 @@ namespace swrenderer
auto vis = this; auto vis = this;
int spacing; int spacing;
BYTE color = vis->Style.BaseColormap->Maps[vis->startfrac]; BYTE color = vis->BaseColormap->Maps[vis->startfrac];
int yl = vis->y1; int yl = vis->y1;
int ycount = vis->y2 - yl + 1; int ycount = vis->y2 - yl + 1;
int x1 = vis->x1; int x1 = vis->x1;
@ -243,7 +243,7 @@ namespace swrenderer
DrawMaskedSegsBehindParticle(); DrawMaskedSegsBehindParticle();
uint32_t fg = LightBgra::shade_pal_index_simple(color, LightBgra::calc_light_multiplier(LIGHTSCALE(0, vis->Style.ColormapNum << FRACBITS))); uint32_t fg = LightBgra::shade_pal_index_simple(color, LightBgra::calc_light_multiplier(LIGHTSCALE(0, vis->ColormapNum << FRACBITS)));
// vis->renderflags holds translucency level (0-255) // vis->renderflags holds translucency level (0-255)
fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff; fixed_t fglevel = ((vis->renderflags + 1) << 8) & ~0x3ff;

View file

@ -305,7 +305,7 @@ namespace swrenderer
vis->yscale = float(pspriteyscale / tex->Scale.Y); vis->yscale = float(pspriteyscale / tex->Scale.Y);
vis->Translation = 0; // [RH] Use default colors vis->Translation = 0; // [RH] Use default colors
vis->pic = tex; vis->pic = tex;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
// If flip is used, provided that it's not already flipped (that would just invert itself) // If flip is used, provided that it's not already flipped (that would just invert itself)
// (It's an XOR...) // (It's an XOR...)
@ -335,42 +335,42 @@ namespace swrenderer
if (pspr->Flags & PSPF_FORCESTYLE) if (pspr->Flags & PSPF_FORCESTYLE)
{ {
vis->Style.RenderStyle = LegacyRenderStyles[rs]; vis->RenderStyle = LegacyRenderStyles[rs];
} }
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy]) else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
{ {
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Fuzzy]; vis->RenderStyle = LegacyRenderStyles[STYLE_Fuzzy];
} }
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy]) else if (owner->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
{ {
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_OptFuzzy]; vis->RenderStyle = LegacyRenderStyles[STYLE_OptFuzzy];
vis->Style.RenderStyle.CheckFuzz(); vis->RenderStyle.CheckFuzz();
} }
else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Subtract]) else if (owner->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
{ {
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Subtract]; vis->RenderStyle = LegacyRenderStyles[STYLE_Subtract];
} }
else else
{ {
vis->Style.RenderStyle = LegacyRenderStyles[rs]; vis->RenderStyle = LegacyRenderStyles[rs];
} }
} }
else else
{ {
vis->Style.RenderStyle = owner->RenderStyle; vis->RenderStyle = owner->RenderStyle;
} }
// Set the alpha based on if using the overlay's own or not. Also adjust // Set the alpha based on if using the overlay's own or not. Also adjust
// and override the alpha if not forced. // and override the alpha if not forced.
if (pspr->Flags & PSPF_ALPHA) if (pspr->Flags & PSPF_ALPHA)
{ {
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy]) if (vis->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy])
{ {
alpha = owner->Alpha; alpha = owner->Alpha;
} }
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy]) else if (vis->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])
{ {
FRenderStyle style = vis->Style.RenderStyle; FRenderStyle style = vis->RenderStyle;
style.CheckFuzz(); style.CheckFuzz();
switch (style.BlendOp) switch (style.BlendOp)
{ {
@ -384,15 +384,15 @@ namespace swrenderer
} }
} }
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Subtract]) else if (vis->RenderStyle == LegacyRenderStyles[STYLE_Subtract])
{ {
alpha = owner->Alpha; alpha = owner->Alpha;
} }
else if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] || else if (vis->RenderStyle == LegacyRenderStyles[STYLE_Add] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Translucent] || vis->RenderStyle == LegacyRenderStyles[STYLE_Translucent] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil] || vis->RenderStyle == LegacyRenderStyles[STYLE_TranslucentStencil] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_AddStencil] || vis->RenderStyle == LegacyRenderStyles[STYLE_AddStencil] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_AddShaded]) vis->RenderStyle == LegacyRenderStyles[STYLE_AddShaded])
{ {
alpha = owner->Alpha * pspr->alpha; alpha = owner->Alpha * pspr->alpha;
} }
@ -405,10 +405,10 @@ namespace swrenderer
// Should normal renderstyle come out on top at the end and we desire alpha, // Should normal renderstyle come out on top at the end and we desire alpha,
// switch it to translucent. Normal never applies any sort of alpha. // switch it to translucent. Normal never applies any sort of alpha.
if ((pspr->Flags & PSPF_ALPHA) && if ((pspr->Flags & PSPF_ALPHA) &&
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Normal] && vis->RenderStyle == LegacyRenderStyles[STYLE_Normal] &&
vis->Style.Alpha < 1.0) vis->Alpha < 1.0)
{ {
vis->Style.RenderStyle = LegacyRenderStyles[STYLE_Translucent]; vis->RenderStyle = LegacyRenderStyles[STYLE_Translucent];
alpha = owner->Alpha * pspr->alpha; alpha = owner->Alpha * pspr->alpha;
} }
@ -417,22 +417,22 @@ namespace swrenderer
if (pspr->Flags & PSPF_FORCEALPHA) if (pspr->Flags & PSPF_FORCEALPHA)
{ {
//Due to lack of != operators... //Due to lack of != operators...
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] || if (vis->RenderStyle == LegacyRenderStyles[STYLE_Fuzzy] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_SoulTrans] || vis->RenderStyle == LegacyRenderStyles[STYLE_SoulTrans] ||
vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Stencil]) vis->RenderStyle == LegacyRenderStyles[STYLE_Stencil])
{ {
} }
else else
{ {
alpha = pspr->alpha; alpha = pspr->alpha;
vis->Style.RenderStyle.Flags |= STYLEF_ForceAlpha; vis->RenderStyle.Flags |= STYLEF_ForceAlpha;
} }
} }
vis->Style.Alpha = clamp<float>(float(alpha), 0.f, 1.f); vis->Alpha = clamp<float>(float(alpha), 0.f, 1.f);
// Due to how some of the effects are handled, going to 0 or less causes some // Due to how some of the effects are handled, going to 0 or less causes some
// weirdness to display. There's no point rendering it anyway if it's 0. // weirdness to display. There's no point rendering it anyway if it's 0.
if (vis->Style.Alpha <= 0.) if (vis->Alpha <= 0.)
return; return;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -440,16 +440,16 @@ namespace swrenderer
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
// too. That means if the source is inverted, we need to do the reverse of what // too. That means if the source is inverted, we need to do the reverse of what
// the invert overlay flag says to do. // the invert overlay flag says to do.
INTBOOL invertcolormap = (vis->Style.RenderStyle.Flags & STYLEF_InvertOverlay); INTBOOL invertcolormap = (vis->RenderStyle.Flags & STYLEF_InvertOverlay);
if (vis->Style.RenderStyle.Flags & STYLEF_InvertSource) if (vis->RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
FDynamicColormap *mybasecolormap = basecolormap; FDynamicColormap *mybasecolormap = basecolormap;
if (vis->Style.RenderStyle.Flags & STYLEF_FadeToBlack) if (vis->RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -464,8 +464,8 @@ namespace swrenderer
if (realfixedcolormap != nullptr && (!r_swtruecolor || (r_shadercolormaps && screen->Accel2D))) if (realfixedcolormap != nullptr && (!r_swtruecolor || (r_shadercolormaps && screen->Accel2D)))
{ // fixed color { // fixed color
vis->Style.BaseColormap = realfixedcolormap; vis->BaseColormap = realfixedcolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ {
@ -475,47 +475,43 @@ namespace swrenderer
} }
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; vis->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap;
vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; vis->ColormapNum = fixedlightlev >> COLORMAPSHIFT;
} }
else if (!vis->foggy && pspr->GetState()->GetFullbright()) else if (!vis->foggy && pspr->GetState()->GetFullbright())
{ // full bright { // full bright
vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap vis->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; // [RH] use basecolormap
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ // local light { // local light
vis->Style.BaseColormap = mybasecolormap; vis->BaseColormap = mybasecolormap;
vis->Style.ColormapNum = GETPALOOKUP(0, spriteshade); vis->ColormapNum = GETPALOOKUP(0, spriteshade);
} }
} }
if (camera->Inventory != nullptr) if (camera->Inventory != nullptr)
{ {
BYTE oldcolormapnum = vis->Style.ColormapNum; visstyle_t visstyle;
FSWColormap *oldcolormap = vis->Style.BaseColormap; visstyle.Alpha = vis->Alpha;
camera->Inventory->AlterWeaponSprite(&vis->Style); visstyle.RenderStyle = vis->RenderStyle;
if (vis->Style.BaseColormap != oldcolormap || vis->Style.ColormapNum != oldcolormapnum) visstyle.colormap = nullptr; // Same as the GL render is doing.
camera->Inventory->AlterWeaponSprite(&visstyle);
vis->RenderStyle = visstyle.RenderStyle;
vis->Alpha = visstyle.Alpha;
// Only bother checking for the one type it changes it to until this has been ZScript'ed..
if (visstyle.colormap == SpecialColormaps[INVERSECOLORMAP].Colormap)
{ {
// The colormap has changed. Is it one we can easily identify? vis->BaseColormap = &SpecialColormaps[INVERSECOLORMAP];
// If not, then don't bother trying to identify it for vis->ColormapNum = 0;
// hardware accelerated drawing.
if (vis->Style.BaseColormap < &SpecialColormaps[0] ||
vis->Style.BaseColormap > &SpecialColormaps.Last())
{
noaccel = true;
}
// Has the basecolormap changed? If so, we can't hardware accelerate it,
// since we don't know what it is anymore.
else if (vis->Style.BaseColormap != mybasecolormap)
{
noaccel = true;
}
} }
} }
// If we're drawing with a special colormap, but shaders for them are disabled, do // If we're drawing with a special colormap, but shaders for them are disabled, do
// not accelerate. // not accelerate.
if (!r_shadercolormaps && (vis->Style.BaseColormap >= &SpecialColormaps[0] && if (!r_shadercolormaps && (vis->BaseColormap >= &SpecialColormaps[0] &&
vis->Style.BaseColormap <= &SpecialColormaps.Last())) vis->BaseColormap <= &SpecialColormaps.Last()))
{ {
noaccel = true; noaccel = true;
} }
@ -543,15 +539,15 @@ namespace swrenderer
{ {
colormap_to_use = basecolormap; colormap_to_use = basecolormap;
vis->Style.BaseColormap = basecolormap; vis->BaseColormap = basecolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
// Check for hardware-assisted 2D. If it's available, and this sprite is not // Check for hardware-assisted 2D. If it's available, and this sprite is not
// fuzzy, don't draw it until after the switch to 2D mode. // fuzzy, don't draw it until after the switch to 2D mode.
if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D)
{ {
FRenderStyle style = vis->Style.RenderStyle; FRenderStyle style = vis->RenderStyle;
style.CheckFuzz(); style.CheckFuzz();
if (style.BlendOp != STYLEOP_Fuzz) if (style.BlendOp != STYLEOP_Fuzz)
{ {
@ -585,16 +581,16 @@ namespace swrenderer
FColormapStyle colormapstyle; FColormapStyle colormapstyle;
bool usecolormapstyle = false; bool usecolormapstyle = false;
if (vis->Style.BaseColormap >= &SpecialColormaps[0] && if (vis->BaseColormap >= &SpecialColormaps[0] &&
vis->Style.BaseColormap < &SpecialColormaps[SpecialColormaps.Size()]) vis->BaseColormap < &SpecialColormaps[SpecialColormaps.Size()])
{ {
special = static_cast<FSpecialColormap*>(vis->Style.BaseColormap); special = static_cast<FSpecialColormap*>(vis->BaseColormap);
} }
else if (colormap->Color == PalEntry(255, 255, 255) && else if (colormap->Color == PalEntry(255, 255, 255) &&
colormap->Desaturate == 0) colormap->Desaturate == 0)
{ {
overlay = colormap->Fade; overlay = colormap->Fade;
overlay.a = BYTE(vis->Style.ColormapNum * 255 / NUMCOLORMAPS); overlay.a = BYTE(vis->ColormapNum * 255 / NUMCOLORMAPS);
} }
else else
{ {
@ -602,7 +598,7 @@ namespace swrenderer
colormapstyle.Color = colormap->Color; colormapstyle.Color = colormap->Color;
colormapstyle.Fade = colormap->Fade; colormapstyle.Fade = colormap->Fade;
colormapstyle.Desaturate = colormap->Desaturate; colormapstyle.Desaturate = colormap->Desaturate;
colormapstyle.FadeLevel = vis->Style.ColormapNum / float(NUMCOLORMAPS); colormapstyle.FadeLevel = vis->ColormapNum / float(NUMCOLORMAPS);
} }
screen->DrawTexture(vis->pic, screen->DrawTexture(vis->pic,
viewwindowx + vispsprites[i].x1, viewwindowx + vispsprites[i].x1,
@ -617,8 +613,8 @@ namespace swrenderer
DTA_ClipTop, viewwindowy, DTA_ClipTop, viewwindowy,
DTA_ClipRight, viewwindowx + viewwidth, DTA_ClipRight, viewwindowx + viewwidth,
DTA_ClipBottom, viewwindowy + viewheight, DTA_ClipBottom, viewwindowy + viewheight,
DTA_AlphaF, vis->Style.Alpha, DTA_AlphaF, vis->Alpha,
DTA_RenderStyle, vis->Style.RenderStyle, DTA_RenderStyle, vis->RenderStyle,
DTA_FillColor, vis->FillColor, DTA_FillColor, vis->FillColor,
DTA_SpecialColormap, special, DTA_SpecialColormap, special,
DTA_ColorOverlay, overlay.d, DTA_ColorOverlay, overlay.d,

View file

@ -194,14 +194,14 @@ namespace swrenderer
vis->renderflags = renderflags; vis->renderflags = renderflags;
if (thing->flags5 & MF5_BRIGHT) if (thing->flags5 & MF5_BRIGHT)
vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->renderflags |= RF_FULLBRIGHT; // kg3D
vis->Style.RenderStyle = thing->RenderStyle; vis->RenderStyle = thing->RenderStyle;
vis->FillColor = thing->fillcolor; vis->FillColor = thing->fillcolor;
vis->Translation = thing->Translation; // [RH] thing translation table vis->Translation = thing->Translation; // [RH] thing translation table
vis->FakeFlatStat = fakeside; vis->FakeFlatStat = fakeside;
vis->Style.Alpha = float(thing->Alpha); vis->Alpha = float(thing->Alpha);
vis->fakefloor = fakefloor; vis->fakefloor = fakefloor;
vis->fakeceiling = fakeceiling; vis->fakeceiling = fakeceiling;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
//vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP; //vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP;
//vis->bSplitSprite = false; //vis->bSplitSprite = false;
@ -212,9 +212,9 @@ namespace swrenderer
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
// too. That means if the source is inverted, we need to do the reverse of what // too. That means if the source is inverted, we need to do the reverse of what
// the invert overlay flag says to do. // the invert overlay flag says to do.
INTBOOL invertcolormap = (vis->Style.RenderStyle.Flags & STYLEF_InvertOverlay); INTBOOL invertcolormap = (vis->RenderStyle.Flags & STYLEF_InvertOverlay);
if (vis->Style.RenderStyle.Flags & STYLEF_InvertSource) if (vis->RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
@ -226,12 +226,12 @@ namespace swrenderer
} }
// Sprites that are added to the scene must fade to black. // Sprites that are added to the scene must fade to black.
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) if (vis->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0)
{ {
mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate);
} }
if (vis->Style.RenderStyle.Flags & STYLEF_FadeToBlack) if (vis->RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -247,8 +247,8 @@ namespace swrenderer
// get light level // get light level
if (fixedcolormap != nullptr) if (fixedcolormap != nullptr)
{ // fixed map { // fixed map
vis->Style.BaseColormap = fixedcolormap; vis->BaseColormap = fixedcolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ {
@ -258,18 +258,18 @@ namespace swrenderer
} }
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
vis->Style.BaseColormap = mybasecolormap; vis->BaseColormap = mybasecolormap;
vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; vis->ColormapNum = fixedlightlev >> COLORMAPSHIFT;
} }
else if (!vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) else if (!vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)))
{ // full bright { // full bright
vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; vis->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ // diminished light { // diminished light
vis->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade); vis->ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade);
vis->Style.BaseColormap = mybasecolormap; vis->BaseColormap = mybasecolormap;
} }
} }
@ -295,17 +295,17 @@ namespace swrenderer
} }
fixed_t centeryfrac = FLOAT2FIXED(CenterY); fixed_t centeryfrac = FLOAT2FIXED(CenterY);
R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); R_SetColorMapLight(vis->BaseColormap, 0, vis->ColormapNum << FRACBITS);
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->Style.BaseColormap); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->BaseColormap);
bool visible = R_SetPatchStyle(vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor, basecolormap); bool visible = R_SetPatchStyle(vis->RenderStyle, vis->Alpha, vis->Translation, vis->FillColor, basecolormap);
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded]) if (vis->RenderStyle == LegacyRenderStyles[STYLE_Shaded])
{ // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but
// it is the brightest one. We need to get back to the proper light level for // it is the brightest one. We need to get back to the proper light level for
// this sprite. // this sprite.
R_SetColorMapLight(drawerargs::dc_fcolormap, 0, vis->Style.ColormapNum << FRACBITS); R_SetColorMapLight(drawerargs::dc_fcolormap, 0, vis->ColormapNum << FRACBITS);
} }
if (visible) if (visible)

View file

@ -52,8 +52,8 @@ namespace swrenderer
int r1, r2; int r1, r2;
short topclip, botclip; short topclip, botclip;
short *clip1, *clip2; short *clip1, *clip2;
FSWColormap *colormap = spr->Style.BaseColormap; FSWColormap *colormap = spr->BaseColormap;
int colormapnum = spr->Style.ColormapNum; int colormapnum = spr->ColormapNum;
F3DFloor *rover; F3DFloor *rover;
FDynamicColormap *mybasecolormap; FDynamicColormap *mybasecolormap;
@ -120,20 +120,20 @@ namespace swrenderer
// found new values, recalculate // found new values, recalculate
if (sec) if (sec)
{ {
INTBOOL invertcolormap = (spr->Style.RenderStyle.Flags & STYLEF_InvertOverlay); INTBOOL invertcolormap = (spr->RenderStyle.Flags & STYLEF_InvertOverlay);
if (spr->Style.RenderStyle.Flags & STYLEF_InvertSource) if (spr->RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
// Sprites that are added to the scene must fade to black. // Sprites that are added to the scene must fade to black.
if (spr->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) if (spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0)
{ {
mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate);
} }
if (spr->Style.RenderStyle.Flags & STYLEF_FadeToBlack) if (spr->RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -153,19 +153,19 @@ namespace swrenderer
} }
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
spr->Style.BaseColormap = mybasecolormap; spr->BaseColormap = mybasecolormap;
spr->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; spr->ColormapNum = fixedlightlev >> COLORMAPSHIFT;
} }
else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT)) else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT))
{ // full bright { // full bright
spr->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; spr->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap;
spr->Style.ColormapNum = 0; spr->ColormapNum = 0;
} }
else else
{ // diminished light { // diminished light
int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(spr->foggy)); int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(spr->foggy));
spr->Style.BaseColormap = mybasecolormap; spr->BaseColormap = mybasecolormap;
spr->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade); spr->ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade);
} }
} }
} }
@ -291,8 +291,8 @@ namespace swrenderer
if (topclip >= botclip) if (topclip >= botclip)
{ {
spr->Style.BaseColormap = colormap; spr->BaseColormap = colormap;
spr->Style.ColormapNum = colormapnum; spr->ColormapNum = colormapnum;
return; return;
} }
@ -418,8 +418,8 @@ namespace swrenderer
} }
if (i == x2) if (i == x2)
{ {
spr->Style.BaseColormap = colormap; spr->BaseColormap = colormap;
spr->Style.ColormapNum = colormapnum; spr->ColormapNum = colormapnum;
return; return;
} }
} }
@ -437,7 +437,7 @@ namespace swrenderer
int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale); int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale);
spr->Render(cliptop, clipbot, minvoxely, maxvoxely); spr->Render(cliptop, clipbot, minvoxely, maxvoxely);
} }
spr->Style.BaseColormap = colormap; spr->BaseColormap = colormap;
spr->Style.ColormapNum = colormapnum; spr->ColormapNum = colormapnum;
} }
} }

View file

@ -19,11 +19,15 @@
#define MINZ double((2048*4) / double(1 << 20)) #define MINZ double((2048*4) / double(1 << 20))
struct FSWColormap;
namespace swrenderer namespace swrenderer
{ {
class VisibleSprite class VisibleSprite
{ {
public: public:
virtual ~VisibleSprite() { }
void Render(); void Render();
bool IsCurrentPortalUniq(int portalUniq) const { return CurrentPortalUniq == portalUniq; } bool IsCurrentPortalUniq(int portalUniq) const { return CurrentPortalUniq == portalUniq; }
@ -59,7 +63,10 @@ namespace swrenderer
sector_t *sector; // sector this sprite is in sector_t *sector; // sector this sprite is in
// Light shared calculation? // Light shared calculation?
visstyle_t Style; int ColormapNum; // Which colormap is rendered
FSWColormap *BaseColormap; // Base colormap used together with ColormapNum
float Alpha;
FRenderStyle RenderStyle;
bool foggy; bool foggy;
short renderflags; short renderflags;

View file

@ -142,14 +142,14 @@ namespace swrenderer
vis->renderflags = renderflags; vis->renderflags = renderflags;
if (thing->flags5 & MF5_BRIGHT) if (thing->flags5 & MF5_BRIGHT)
vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->renderflags |= RF_FULLBRIGHT; // kg3D
vis->Style.RenderStyle = thing->RenderStyle; vis->RenderStyle = thing->RenderStyle;
vis->FillColor = thing->fillcolor; vis->FillColor = thing->fillcolor;
vis->Translation = thing->Translation; // [RH] thing translation table vis->Translation = thing->Translation; // [RH] thing translation table
vis->FakeFlatStat = fakeside; vis->FakeFlatStat = fakeside;
vis->Style.Alpha = float(thing->Alpha); vis->Alpha = float(thing->Alpha);
vis->fakefloor = fakefloor; vis->fakefloor = fakefloor;
vis->fakeceiling = fakeceiling; vis->fakeceiling = fakeceiling;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
//vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP; //vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP;
//vis->bSplitSprite = false; //vis->bSplitSprite = false;
@ -159,9 +159,9 @@ namespace swrenderer
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
// too. That means if the source is inverted, we need to do the reverse of what // too. That means if the source is inverted, we need to do the reverse of what
// the invert overlay flag says to do. // the invert overlay flag says to do.
INTBOOL invertcolormap = (vis->Style.RenderStyle.Flags & STYLEF_InvertOverlay); INTBOOL invertcolormap = (vis->RenderStyle.Flags & STYLEF_InvertOverlay);
if (vis->Style.RenderStyle.Flags & STYLEF_InvertSource) if (vis->RenderStyle.Flags & STYLEF_InvertSource)
{ {
invertcolormap = !invertcolormap; invertcolormap = !invertcolormap;
} }
@ -173,12 +173,12 @@ namespace swrenderer
} }
// Sprites that are added to the scene must fade to black. // Sprites that are added to the scene must fade to black.
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0) if (vis->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0)
{ {
mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, 0, mybasecolormap->Desaturate);
} }
if (vis->Style.RenderStyle.Flags & STYLEF_FadeToBlack) if (vis->RenderStyle.Flags & STYLEF_FadeToBlack)
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
@ -194,8 +194,8 @@ namespace swrenderer
// get light level // get light level
if (fixedcolormap != nullptr) if (fixedcolormap != nullptr)
{ // fixed map { // fixed map
vis->Style.BaseColormap = fixedcolormap; vis->BaseColormap = fixedcolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ {
@ -206,18 +206,18 @@ namespace swrenderer
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
vis->Style.BaseColormap = mybasecolormap; vis->BaseColormap = mybasecolormap;
vis->Style.ColormapNum = fixedlightlev >> COLORMAPSHIFT; vis->ColormapNum = fixedlightlev >> COLORMAPSHIFT;
} }
else if (!vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) else if (!vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)))
{ // full bright { // full bright
vis->Style.BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap; vis->BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : mybasecolormap;
vis->Style.ColormapNum = 0; vis->ColormapNum = 0;
} }
else else
{ // diminished light { // diminished light
vis->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade); vis->ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade);
vis->Style.BaseColormap = mybasecolormap; vis->BaseColormap = mybasecolormap;
} }
} }
@ -229,11 +229,11 @@ namespace swrenderer
{ {
auto sprite = this; auto sprite = this;
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(sprite->Style.BaseColormap); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(sprite->BaseColormap);
R_SetColorMapLight(sprite->Style.BaseColormap, 0, sprite->Style.ColormapNum << FRACBITS); R_SetColorMapLight(sprite->BaseColormap, 0, sprite->ColormapNum << FRACBITS);
bool visible = R_SetPatchStyle(sprite->Style.RenderStyle, sprite->Style.Alpha, sprite->Translation, sprite->FillColor, basecolormap); bool visible = R_SetPatchStyle(sprite->RenderStyle, sprite->Alpha, sprite->Translation, sprite->FillColor, basecolormap);
if (!visible) if (!visible)
return; return;
@ -620,8 +620,8 @@ namespace swrenderer
int flags = 0; int flags = 0;
// Do setup for blending. // Do setup for blending.
R_SetColorMapLight(spr->Style.BaseColormap, 0, spr->Style.ColormapNum << FRACBITS); R_SetColorMapLight(spr->BaseColormap, 0, spr->ColormapNum << FRACBITS);
bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); bool visible = R_SetPatchStyle(spr->RenderStyle, spr->Alpha, spr->Translation, spr->FillColor);
if (!visible) if (!visible)
{ {
@ -646,7 +646,7 @@ namespace swrenderer
// Render the voxel, either directly to the screen or offscreen. // Render the voxel, either directly to the screen or offscreen.
R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle, R_DrawVoxel(spr->pa.vpos, spr->pa.vang, spr->gpos, spr->Angle,
spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->Style.BaseColormap, spr->Style.ColormapNum, cliptop, clipbot, spr->xscale, FLOAT2FIXED(spr->yscale), spr->voxel, spr->BaseColormap, spr->ColormapNum, cliptop, clipbot,
minslabz, maxslabz, flags); minslabz, maxslabz, flags);
// Blend the voxel, if that's what we need to do. // Blend the voxel, if that's what we need to do.

View file

@ -120,17 +120,17 @@ namespace swrenderer
vis->deltay = float(pos.Y - ViewPos.Y); vis->deltay = float(pos.Y - ViewPos.Y);
vis->renderflags = renderflags; vis->renderflags = renderflags;
if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D if (thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D
vis->Style.RenderStyle = thing->RenderStyle; vis->RenderStyle = thing->RenderStyle;
vis->FillColor = thing->fillcolor; vis->FillColor = thing->fillcolor;
vis->Translation = thing->Translation; vis->Translation = thing->Translation;
vis->FakeFlatStat = WaterFakeSide::Center; vis->FakeFlatStat = WaterFakeSide::Center;
vis->Style.Alpha = float(thing->Alpha); vis->Alpha = float(thing->Alpha);
vis->fakefloor = NULL; vis->fakefloor = NULL;
vis->fakeceiling = NULL; vis->fakeceiling = NULL;
//vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP; //vis->bInMirror = renderportal->MirrorFlags & RF_XFLIP;
vis->pic = pic; vis->pic = pic;
vis->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade); vis->ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(tz, MINZ), spriteshade);
vis->Style.BaseColormap = basecolormap; vis->BaseColormap = basecolormap;
vis->wallc = wallc; vis->wallc = wallc;
vis->foggy = foggy; vis->foggy = foggy;
@ -165,11 +165,11 @@ namespace swrenderer
} }
// Prepare lighting // Prepare lighting
bool calclighting = false; bool calclighting = false;
FSWColormap *usecolormap = spr->Style.BaseColormap; FSWColormap *usecolormap = spr->BaseColormap;
bool rereadcolormap = true; bool rereadcolormap = true;
// Decals that are added to the scene must fade to black. // Decals that are added to the scene must fade to black.
if (spr->Style.RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0) if (spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
{ {
usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate); usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate);
rereadcolormap = false; rereadcolormap = false;
@ -206,14 +206,14 @@ namespace swrenderer
int x = x1; int x = x1;
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(spr->Style.BaseColormap); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(spr->BaseColormap);
bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor, basecolormap); bool visible = R_SetPatchStyle(spr->RenderStyle, spr->Alpha, spr->Translation, spr->FillColor, basecolormap);
// R_SetPatchStyle can modify basecolormap. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)
{ {
usecolormap = spr->Style.BaseColormap; usecolormap = spr->BaseColormap;
} }
if (!visible) if (!visible)