diff --git a/src/am_map.cpp b/src/am_map.cpp index 690c078fa..7c1e8f5f4 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2057,10 +2057,10 @@ void DAutomap::drawSubsectors() if (roverz < cmpz) { maptex = *(rover->top.texture); - flatcolor = *(rover->top.flatcolor); floorplane = rover->top.plane; sector_t *model = rover->top.model; int selector = (rover->flags & FF_INVERTPLANES) ? sector_t::floor : sector_t::ceiling; + flatcolor = model->SpecialColors[selector]; rotation = -model->GetAngle(selector); scalex = model->GetXScale(selector); scaley = model->GetYScale(selector); diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index e64ee25aa..3597290c4 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -1106,6 +1106,7 @@ void MapLoader::LoadSectors (MapData *map, FMissingTextureTracker &missingtex) ss->prevsec = -1; // stair retriggering until build completes memset(ss->SpecialColors, -1, sizeof(ss->SpecialColors)); memset(ss->AdditiveColors, 0, sizeof(ss->AdditiveColors)); + ss->ColorScaleFactor[0] = ss->ColorScaleFactor[1] = ss->ColorScaleFactor[2] = 1.f; ss->SetAlpha(sector_t::floor, 1.); ss->SetAlpha(sector_t::ceiling, 1.); diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index 49d9c41a1..fc0ae92d1 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -1503,6 +1503,7 @@ public: sec->SetYScale(sector_t::ceiling, 1.); sec->SetAlpha(sector_t::floor, 1.); sec->SetAlpha(sector_t::ceiling, 1.); + sec->ColorScaleFactor[0] = sec->ColorScaleFactor[1] = sec->ColorScaleFactor[2] = 1.f; sec->thinglist = nullptr; sec->touching_thinglist = nullptr; // phares 3/14/98 sec->sectorportal_thinglist = nullptr; diff --git a/src/playsim/p_3dfloors.cpp b/src/playsim/p_3dfloors.cpp index 31fcb2f91..4f8a5d961 100644 --- a/src/playsim/p_3dfloors.cpp +++ b/src/playsim/p_3dfloors.cpp @@ -126,14 +126,12 @@ void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flags, int { ffloor->bottom.plane = &sec2->floorplane; ffloor->bottom.texture = &sec2->planes[sector_t::floor].Texture; - ffloor->bottom.flatcolor = &sec2->SpecialColors[sector_t::floor]; ffloor->bottom.isceiling = sector_t::floor; } else { ffloor->bottom.plane = &sec2->ceilingplane; ffloor->bottom.texture = &sec2->planes[sector_t::ceiling].Texture; - ffloor->bottom.flatcolor = &sec2->SpecialColors[sector_t::ceiling]; ffloor->bottom.isceiling = sector_t::ceiling; } @@ -141,7 +139,6 @@ void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flags, int { ffloor->top.plane = &sec2->ceilingplane; ffloor->top.texture = &sec2->planes[sector_t::ceiling].Texture; - ffloor->top.flatcolor = &sec2->SpecialColors[sector_t::ceiling]; ffloor->toplightlevel = &sec2->lightlevel; ffloor->top.isceiling = sector_t::ceiling; } @@ -149,7 +146,6 @@ void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flags, int { ffloor->top.plane = &sec->floorplane; ffloor->top.texture = &sec2->planes[sector_t::floor].Texture; - ffloor->top.flatcolor = &sec2->SpecialColors[sector_t::floor]; ffloor->toplightlevel = &sec->lightlevel; ffloor->top.isceiling = sector_t::floor; ffloor->top.model = sec; diff --git a/src/playsim/p_3dfloors.h b/src/playsim/p_3dfloors.h index fc82b7550..f0b1e87fd 100644 --- a/src/playsim/p_3dfloors.h +++ b/src/playsim/p_3dfloors.h @@ -68,7 +68,6 @@ struct F3DFloor secplane_t * plane; const FTextureID * texture; sector_t * model; - PalEntry * flatcolor; int isceiling; int vindex; bool copied; diff --git a/src/rendering/hwrenderer/scene/hw_drawstructs.h b/src/rendering/hwrenderer/scene/hw_drawstructs.h index 04c14c0a4..beac22d3f 100644 --- a/src/rendering/hwrenderer/scene/hw_drawstructs.h +++ b/src/rendering/hwrenderer/scene/hw_drawstructs.h @@ -301,6 +301,10 @@ public: FColormap Colormap; // light and fog PalEntry FlatColor; PalEntry AddColor; + PalEntry BlendColor; + float DesaturationFactor, ColorFactor; + int BlendMode; + bool Invert; ERenderStyle renderstyle; float alpha; diff --git a/src/rendering/hwrenderer/scene/hw_flats.cpp b/src/rendering/hwrenderer/scene/hw_flats.cpp index fc1416afc..3a65c5964 100644 --- a/src/rendering/hwrenderer/scene/hw_flats.cpp +++ b/src/rendering/hwrenderer/scene/hw_flats.cpp @@ -308,6 +308,12 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) di->SetFog(state, lightlevel, rel, di->isFullbrightScene(), &Colormap, false); state.SetObjectColor(FlatColor | 0xff000000); state.SetAddColor(AddColor | 0xff000000); + state.SetBlendColor(BlendColor); + state.SetObjectBlendMode(BlendMode); + state.SetColorizeFactor(ColorFactor); + state.SetObjectDesaturateFactor(DesaturationFactor); + state.SetObjectInvert(Invert); + if (hacktype & SSRF_PLANEHACK) { @@ -334,7 +340,6 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) flatvertices += 4; flatprimitives++; } - state.SetObjectColor(0xffffffff); } else { @@ -356,8 +361,8 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) state.EnableTextureMatrix(false); } state.SetRenderStyle(DefaultRenderStyle()); - state.SetObjectColor(0xffffffff); } + state.SetObjectColor(0xffffffff); state.SetAddColor(0); state.SetBlendColor(0); state.SetObjectDesaturateFactor(0); @@ -454,12 +459,22 @@ void HWFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) Colormap.LightColor = light->extra_colormap.FadeColor; FlatColor = 0xffffffff; AddColor = 0; + BlendColor = 0; + BlendMode = 0; + ColorFactor = 1.f; + DesaturationFactor = 0.f; + Invert = false; } else { Colormap.CopyFrom3DLight(light); - FlatColor = *plane.flatcolor; - // AddColor = sector->SpecialColors[sector_t::add]; + FlatColor = plane.model->SpecialColors[plane.isceiling]; + AddColor = plane.model->AdditiveColors[plane.isceiling]; + BlendColor = plane.model->BlendColors[plane.isceiling]; + BlendMode = plane.model->BlendModes[plane.isceiling]; + ColorFactor = plane.model->ColorScaleFactor[plane.isceiling]; + DesaturationFactor = plane.model->MaterialDesaturationFactor[plane.isceiling]; + Invert = plane.model->InvertMode(plane.isceiling); } @@ -515,6 +530,12 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sector_t * frontsector, int which) Colormap = frontsector->Colormap; FlatColor = frontsector->SpecialColors[sector_t::floor]; AddColor = frontsector->AdditiveColors[sector_t::floor]; + BlendColor = frontsector->BlendColors[sector_t::floor]; + BlendMode = frontsector->BlendModes[sector_t::floor]; + DesaturationFactor = frontsector->MaterialDesaturationFactor[sector_t::floor]; + ColorFactor = frontsector->ColorScaleFactor[sector_t::floor]; + Invert = frontsector->InvertMode(sector_t::floor); + port = frontsector->ValidatePortal(sector_t::floor); if ((stack = (port != NULL))) { @@ -571,6 +592,11 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sector_t * frontsector, int which) Colormap = frontsector->Colormap; FlatColor = frontsector->SpecialColors[sector_t::ceiling]; AddColor = frontsector->AdditiveColors[sector_t::ceiling]; + BlendColor = frontsector->BlendColors[sector_t::ceiling]; + BlendMode = frontsector->BlendModes[sector_t::ceiling]; + DesaturationFactor = frontsector->MaterialDesaturationFactor[sector_t::ceiling]; + ColorFactor = frontsector->ColorScaleFactor[sector_t::ceiling]; + Invert = frontsector->InvertMode(sector_t::ceiling); port = frontsector->ValidatePortal(sector_t::ceiling); if ((stack = (port != NULL))) { diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index ed75e3c34..fa12f28bc 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -175,6 +175,10 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags) state.SetObjectColor(color1); state.SetObjectColor2((color1 != color2) ? color2 : PalEntry(0)); state.SetAddColor(side->GetAdditiveColor(tierndx, frontsector)); + state.SetBlendColor(side->GetBlendColor(tierndx, frontsector)); + state.SetObjectBlendMode(side->GetBlendMode(tierndx, frontsector)); + state.SetObjectDesaturateFactor(side->GetDesaturationFactor(tierndx, frontsector)); + state.SetObjectInvert(side->GetInvertMode(tierndx, frontsector)); if (color1 != color2) {