void HWEEHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state) { auto &vp = di->Viewpoint; sector_t *sector = portal->mOrigin; if (sector->GetTexture(sector_t::floor) == skyflatnum || sector->GetTexture(sector_t::ceiling) == skyflatnum) { GLSkyInfo skyinfo; skyinfo.init(di, sector->sky, 0); HWSkyPortal sky(screen->mSkyData, mState, &skyinfo, true); sky.DrawContents(di, state); } if (sector->GetTexture(sector_t::ceiling) != skyflatnum) { GLHorizonInfo horz; horz.plane.GetFromSector(sector, sector_t::ceiling); horz.lightlevel = hw_ClampLight(sector->GetCeilingLight()); horz.colormap = sector->Colormap; horz.specialcolor = 0xffffffff; if (portal->mType == PORTS_PLANE) { horz.plane.Texheight = vp.Pos.Z + fabs(horz.plane.Texheight); } HWHorizonPortal ceil(mState, &horz, di->Viewpoint, true); ceil.DrawContents(di, state); } if (sector->GetTexture(sector_t::floor) != skyflatnum) { GLHorizonInfo horz; horz.plane.GetFromSector(sector, sector_t::floor); horz.lightlevel = hw_ClampLight(sector->GetFloorLight()); horz.colormap = sector->Colormap; horz.specialcolor = 0xffffffff; if (portal->mType == PORTS_PLANE) { horz.plane.Texheight = vp.Pos.Z - fabs(horz.plane.Texheight); } HWHorizonPortal floor(mState, &horz, di->Viewpoint, true); floor.DrawContents(di, state); } }
//========================================================================== // // set current light color // //========================================================================== void gl_SetColor(int sectorlightlevel, int rellight, bool fullbright, const FColormap &cm, float alpha, bool weapon) { if (fullbright) { gl_RenderState.SetColorAlpha(0xffffff, alpha, 0); gl_RenderState.SetSoftLightLevel(255); } else { int hwlightlevel = hw_CalcLightLevel(sectorlightlevel, rellight, weapon); PalEntry pe = hw_CalcLightColor(hwlightlevel, cm.LightColor, cm.BlendFactor); gl_RenderState.SetColorAlpha(pe, alpha, cm.Desaturation); gl_RenderState.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight)); } }
//========================================================================== // // set current light color // //========================================================================== void HWDrawInfo::SetColor(FRenderState &state, int sectorlightlevel, int rellight, bool fullbright, const FColormap &cm, float alpha, bool weapon) { if (fullbright) { state.SetColorAlpha(0xffffff, alpha, 0); if (isSoftwareLighting()) state.SetSoftLightLevel(255); else state.SetNoSoftLightLevel(); } else { int hwlightlevel = CalcLightLevel(sectorlightlevel, rellight, weapon, cm.BlendFactor); PalEntry pe = CalcLightColor(hwlightlevel, cm.LightColor, cm.BlendFactor); state.SetColorAlpha(pe, alpha, cm.Desaturation); if (isSoftwareLighting()) state.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor); else state.SetNoSoftLightLevel(); } }
void GLSprite::SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent) { GLSprite copySprite; double lightbottom; unsigned int i; bool put=false; TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist; for(i=0;i<lightlist.Size();i++) { // Particles don't go through here so we can safely assume that actor is not nullptr if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor); else lightbottom=frontsector->floorplane.ZatPoint(actor); if (lightbottom<z2) lightbottom=z2; if (lightbottom<z1) { copySprite=*this; copySprite.lightlevel = hw_ClampLight(*lightlist[i].p_lightlevel); copySprite.Colormap.CopyLight(lightlist[i].extra_colormap); if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) { copySprite.Colormap.Decolorize(); } if (!ThingColor.isWhite()) { copySprite.Colormap.LightColor.r = (copySprite.Colormap.LightColor.r*ThingColor.r) >> 8; copySprite.Colormap.LightColor.g = (copySprite.Colormap.LightColor.g*ThingColor.g) >> 8; copySprite.Colormap.LightColor.b = (copySprite.Colormap.LightColor.b*ThingColor.b) >> 8; } z1=copySprite.z2=lightbottom; vt=copySprite.vb=copySprite.vt+ (lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1); copySprite.PutSprite(di, translucent); put=true; }