diff --git a/src/common/rendering/hwrenderer/data/hw_lightmaptile.h b/src/common/rendering/hwrenderer/data/hw_lightmaptile.h index 57ab8b133..faf188092 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightmaptile.h +++ b/src/common/rendering/hwrenderer/data/hw_lightmaptile.h @@ -54,9 +54,6 @@ struct LightmapTile // True if the tile needs to be rendered into the lightmap texture before it can be used bool NeedsUpdate = true; - // Lightmap UV coordinates used by HWWall - FVector2 WallUV[4]; - FVector2 ToUV(const FVector3& vert) const { FVector3 localPos = vert - Transform.TranslateWorldToLocal; diff --git a/src/rendering/hwrenderer/doom_levelsubmesh.cpp b/src/rendering/hwrenderer/doom_levelsubmesh.cpp index aba980d4a..b1eec7fcf 100644 --- a/src/rendering/hwrenderer/doom_levelsubmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelsubmesh.cpp @@ -664,51 +664,6 @@ void DoomLevelSubmesh::PackLightmapAtlas(FLevelLocals& doomMap, int lightmapStar } } - // Calculate HWWall lightmap UV coordinates for the immediate hwrenderer - for (LightmapTile* tile : sortedTiles) - { - uint32_t type = tile->Binding.Type; - if (type != ST_LOWERSIDE && type != ST_MIDDLESIDE && type != ST_UPPERSIDE) - continue; - - side_t* frontside = &doomMap.sides[tile->Binding.TypeIndex]; - side_t* backside = frontside->linedef->sidedef[0] == frontside ? frontside->linedef->sidedef[1] : frontside->linedef->sidedef[0]; - sector_t* frontsector = frontside->sector; - sector_t* backsector = backside ? backside->sector : frontsector; - - FVector2 v1 = FVector2(frontside->V1()->fPos()); - FVector2 v2 = FVector2(frontside->V2()->fPos()); - secplane_t* top; - secplane_t* bottom; - - if (tile->Binding.ControlSector != 0xffffffff) - { - sector_t* controlsector = &doomMap.sectors[tile->Binding.ControlSector]; - top = &controlsector->GetSecPlane(sector_t::ceiling); - bottom = &controlsector->GetSecPlane(sector_t::floor); - } - else if (type == ST_MIDDLESIDE) - { - top = &frontsector->GetSecPlane(sector_t::ceiling); - bottom = &frontsector->GetSecPlane(sector_t::floor); - } - else if (type == ST_LOWERSIDE) - { - top = &backsector->GetSecPlane(sector_t::floor); - bottom = &frontsector->GetSecPlane(sector_t::floor); - } - else // if (type == ST_UPPERSIDE) - { - top = &frontsector->GetSecPlane(sector_t::ceiling); - bottom = &backsector->GetSecPlane(sector_t::ceiling); - } - - tile->WallUV[0] = tile->ToUV(FVector3(v1, bottom->ZatPoint(v1)), (float)LMTextureSize); - tile->WallUV[1] = tile->ToUV(FVector3(v1, top->ZatPoint(v1)), (float)LMTextureSize); - tile->WallUV[2] = tile->ToUV(FVector3(v2, top->ZatPoint(v2)), (float)LMTextureSize); - tile->WallUV[3] = tile->ToUV(FVector3(v2, bottom->ZatPoint(v2)), (float)LMTextureSize); - } - #if 0 // Debug atlas tile locations: float colors[30] = { diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index 0766e3ed2..541061837 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -767,10 +767,6 @@ void HWWall::SplitWall(HWWallDispatcher *di, FRenderState& state, sector_t * fro (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.tcs[LOLFT].v-copyWall1.tcs[UPLFT].v)/(zbottom[0]-copyWall1.ztop[0]); tcs[UPRGT].v=copyWall1.tcs[LORGT].v=copyWall1.tcs[UPRGT].v+ (maplightbottomright-copyWall1.ztop[1])*(copyWall1.tcs[LORGT].v-copyWall1.tcs[UPRGT].v)/(zbottom[1]-copyWall1.ztop[1]); - lightuv[UPLFT].v=copyWall1.lightuv[LOLFT].v=copyWall1.lightuv[UPLFT].v+ - (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lightuv[LOLFT].v-copyWall1.lightuv[UPLFT].v)/(zbottom[0]-copyWall1.ztop[0]); - lightuv[UPRGT].v=copyWall1.lightuv[LORGT].v=copyWall1.lightuv[UPRGT].v+ - (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lightuv[LORGT].v-copyWall1.lightuv[UPRGT].v)/(zbottom[1]-copyWall1.ztop[1]); copyWall1.Put3DWall(di, state, &lightlist[i], translucent); } if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) @@ -909,25 +905,6 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto texlength = 0; } - texcoord srclightuv[4]; - if (surface && surface->LightmapTileIndex >= 0) - { - LightmapTile* tile = &surface->Submesh->LightmapTiles[surface->LightmapTileIndex]; - srclightuv[0] = { tile->WallUV[0].X, tile->WallUV[0].Y }; - srclightuv[1] = { tile->WallUV[1].X, tile->WallUV[1].Y }; - srclightuv[2] = { tile->WallUV[2].X, tile->WallUV[2].Y }; - srclightuv[3] = { tile->WallUV[3].X, tile->WallUV[3].Y }; - lindex = (float)tile->AtlasLocation.ArrayIndex; - } - else - { - srclightuv[0] = { 0.0f, 0.0f }; - srclightuv[1] = { 0.0f, 0.0f }; - srclightuv[2] = { 0.0f, 0.0f }; - srclightuv[3] = { 0.0f, 0.0f }; - lindex = -1.0f; - } - // // // set up coordinates for the left side of the polygon @@ -944,9 +921,6 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop); tcs[LOLFT].v = tci->FloatToTexV(-zbottom[0] + texturetop); } - - lightuv[UPLFT].v = srclightuv[UPLFT].v; - lightuv[LOLFT].v = srclightuv[LOLFT].v; } else { @@ -967,9 +941,6 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto { tcs[LOLFT].v = tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop); } - - lightuv[UPLFT].v = srclightuv[UPLFT].v + inter_x * (srclightuv[UPRGT].v - srclightuv[UPLFT].v); - lightuv[LOLFT].v = srclightuv[LOLFT].v + inter_x * (srclightuv[LORGT].v - srclightuv[LOLFT].v); } // @@ -988,9 +959,6 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop + skew); tcs[LORGT].v = tci->FloatToTexV(-zbottom[1] + texturetop + skew); } - - lightuv[UPRGT].v = srclightuv[UPRGT].v; - lightuv[LORGT].v = srclightuv[LORGT].v; } else { @@ -1010,19 +978,11 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto { tcs[LORGT].v = tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop + skew); } - - lightuv[UPRGT].v = srclightuv[UPRGT].v + inter_x * (srclightuv[UPRGT].v - srclightuv[UPLFT].v); - lightuv[LORGT].v = srclightuv[LORGT].v + inter_x * (srclightuv[LORGT].v - srclightuv[LOLFT].v); } tcs[UPLFT].u = tcs[LOLFT].u = l_ul + texlength * glseg.fracleft; tcs[UPRGT].u = tcs[LORGT].u = l_ul + texlength * glseg.fracright; - lightuv[UPLFT].u = srclightuv[UPLFT].u + (srclightuv[UPRGT].u - srclightuv[UPLFT].u) * glseg.fracleft; - lightuv[LOLFT].u = srclightuv[LOLFT].u + (srclightuv[LORGT].u - srclightuv[LOLFT].u) * glseg.fracleft; - lightuv[UPRGT].u = srclightuv[UPLFT].u + (srclightuv[UPRGT].u - srclightuv[UPLFT].u) * glseg.fracright; - lightuv[LORGT].u = srclightuv[LOLFT].u + (srclightuv[LORGT].u - srclightuv[LOLFT].u) * glseg.fracright; - if (texture != NULL) { bool normalize = false; @@ -1671,35 +1631,6 @@ void HWWall::BuildFFBlock(HWWallDispatcher *di, FRenderState& state, seg_t * seg tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright); type = RENDERWALL_FFBLOCK; CheckTexturePosition(&tci); - - texcoord srclightuv[4]; - if (surface && surface->LightmapTileIndex >= 0) - { - LightmapTile* tile = &surface->Submesh->LightmapTiles[surface->LightmapTileIndex]; - srclightuv[0] = { tile->WallUV[0].X, tile->WallUV[0].Y }; - srclightuv[1] = { tile->WallUV[1].X, tile->WallUV[1].Y }; - srclightuv[2] = { tile->WallUV[2].X, tile->WallUV[2].Y }; - srclightuv[3] = { tile->WallUV[3].X, tile->WallUV[3].Y }; - lindex = (float)tile->AtlasLocation.ArrayIndex; - } - else - { - srclightuv[0] = { 0.0f, 0.0f }; - srclightuv[1] = { 0.0f, 0.0f }; - srclightuv[2] = { 0.0f, 0.0f }; - srclightuv[3] = { 0.0f, 0.0f }; - lindex = -1.0f; - } - - lightuv[UPLFT].u = srclightuv[UPLFT].u + (srclightuv[UPRGT].u - srclightuv[UPLFT].u) * glseg.fracleft; - lightuv[LOLFT].u = srclightuv[LOLFT].u + (srclightuv[LORGT].u - srclightuv[LOLFT].u) * glseg.fracleft; - lightuv[UPRGT].u = srclightuv[UPLFT].u + (srclightuv[UPRGT].u - srclightuv[UPLFT].u) * glseg.fracright; - lightuv[LORGT].u = srclightuv[LOLFT].u + (srclightuv[LORGT].u - srclightuv[LOLFT].u) * glseg.fracright; - - lightuv[UPLFT].v = srclightuv[UPLFT].v; - lightuv[UPRGT].v = srclightuv[UPRGT].v; - lightuv[LOLFT].v = srclightuv[LOLFT].v; - lightuv[LORGT].v = srclightuv[LORGT].v; } ztop[0] = ff_topleft; diff --git a/src/rendering/hwrenderer/scene/hw_walls_vertex.cpp b/src/rendering/hwrenderer/scene/hw_walls_vertex.cpp index a92cd7087..adb4d52f7 100644 --- a/src/rendering/hwrenderer/scene/hw_walls_vertex.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls_vertex.cpp @@ -26,6 +26,7 @@ #include "hw_renderstate.h" #include "hwrenderer/scene/hw_drawinfo.h" #include "hwrenderer/scene/hw_drawstructs.h" +#include "doom_levelsubmesh.h" EXTERN_CVAR(Bool, gl_seamless) @@ -193,6 +194,28 @@ void HWWall::SplitRightEdge(FFlatVertex *&ptr) int HWWall::CreateVertices(FFlatVertex *&ptr, bool split) { + if (surface && surface->LightmapTileIndex >= 0) + { + LightmapTile* tile = &surface->Submesh->LightmapTiles[surface->LightmapTileIndex]; + FVector2 lolft = tile->ToUV(FVector3(glseg.x1, glseg.y1, zbottom[0]), surface->Submesh->LMTextureSize); + FVector2 uplft = tile->ToUV(FVector3(glseg.x1, glseg.y1, ztop[0]), surface->Submesh->LMTextureSize); + FVector2 uprgt = tile->ToUV(FVector3(glseg.x2, glseg.y2, ztop[1]), surface->Submesh->LMTextureSize); + FVector2 lorgt = tile->ToUV(FVector3(glseg.x2, glseg.y2, zbottom[1]), surface->Submesh->LMTextureSize); + lightuv[LOLFT] = { lolft.X, lolft.Y }; + lightuv[UPLFT] = { uplft.X, uplft.Y }; + lightuv[UPRGT] = { uprgt.X, uprgt.Y }; + lightuv[LORGT] = { lorgt.X, lorgt.Y }; + lindex = (float)tile->AtlasLocation.ArrayIndex; + } + else + { + lightuv[LOLFT] = { 0.0f, 0.0f }; + lightuv[UPLFT] = { 0.0f, 0.0f }; + lightuv[UPRGT] = { 0.0f, 0.0f }; + lightuv[LORGT] = { 0.0f, 0.0f }; + lindex = -1.0f; + } + auto oo = ptr; ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v, lightuv[LOLFT].u, lightuv[LOLFT].v, lindex); ptr++;