mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 13:31:37 +00:00
Remove smoothing groups from vk_lightmap and fix some warnings
This commit is contained in:
parent
2d37bfe527
commit
cfea7404cf
4 changed files with 33 additions and 32 deletions
|
@ -209,7 +209,6 @@ public:
|
|||
|
||||
virtual int AddSurfaceLights(const LevelMeshSurface* surface, LevelMeshLight* list, int listMaxSize) { return 0; }
|
||||
|
||||
TArray<LevelMeshSmoothingGroup> SmoothingGroups;
|
||||
TArray<LevelMeshPortal> Portals;
|
||||
|
||||
// Lightmap atlas
|
||||
|
@ -297,8 +296,11 @@ public:
|
|||
return hitSurface; // I hit something
|
||||
}
|
||||
|
||||
protected:
|
||||
void BuildSmoothingGroups()
|
||||
{
|
||||
TArray<LevelMeshSmoothingGroup> SmoothingGroups;
|
||||
|
||||
for (int i = 0, count = GetSurfaceCount(); i < count; i++)
|
||||
{
|
||||
auto surface = GetSurface(i);
|
||||
|
@ -340,5 +342,27 @@ public:
|
|||
SmoothingGroups[smoothingGroupIndex].surfaces.push_back(surface);
|
||||
surface->smoothingGroupIndex = smoothingGroupIndex;
|
||||
}
|
||||
|
||||
for (int i = 0, count = GetSurfaceCount(); i < count; i++)
|
||||
{
|
||||
auto targetSurface = GetSurface(i);
|
||||
for (LevelMeshSurface* surface : SmoothingGroups[targetSurface->smoothingGroupIndex].surfaces)
|
||||
{
|
||||
FVector2 minUV = ToUV(surface->bounds.min, targetSurface);
|
||||
FVector2 maxUV = ToUV(surface->bounds.max, targetSurface);
|
||||
if (surface != targetSurface && (maxUV.X < 0.0f || maxUV.Y < 0.0f || minUV.X > 1.0f || minUV.Y > 1.0f))
|
||||
continue; // Bounding box not visible
|
||||
|
||||
targetSurface->tileSurfaces.Push(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FVector2 ToUV(const FVector3& vert, const LevelMeshSurface* targetSurface)
|
||||
{
|
||||
FVector3 localPos = vert - targetSurface->translateWorldToLocal;
|
||||
float u = (1.0f + (localPos | targetSurface->projLocalToU)) / (targetSurface->texWidth + 2);
|
||||
float v = (1.0f + (localPos | targetSurface->projLocalToV)) / (targetSurface->texHeight + 2);
|
||||
return FVector2(u, v);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -187,19 +187,6 @@ void VkLightmap::Render()
|
|||
|
||||
bool buffersFull = false;
|
||||
|
||||
if (targetSurface->tileSurfaces.Size() == 0) // To do: move this to where we set up the smoothing groups as we don't need the groups after this step
|
||||
{
|
||||
for (LevelMeshSurface* surface : mesh->SmoothingGroups[targetSurface->smoothingGroupIndex].surfaces)
|
||||
{
|
||||
FVector2 minUV = ToUV(surface->bounds.min, targetSurface);
|
||||
FVector2 maxUV = ToUV(surface->bounds.max, targetSurface);
|
||||
if (surface != targetSurface && (maxUV.X < 0.0f || maxUV.Y < 0.0f || minUV.X > 1.0f || minUV.Y > 1.0f))
|
||||
continue; // Bounding box not visible
|
||||
|
||||
targetSurface->tileSurfaces.Push(surface);
|
||||
}
|
||||
}
|
||||
|
||||
// Paint all surfaces visible in the tile
|
||||
for (LevelMeshSurface* surface : targetSurface->tileSurfaces)
|
||||
{
|
||||
|
@ -529,14 +516,6 @@ void VkLightmap::CopyResult()
|
|||
fb->GetCommands()->PopGroup(cmdbuffer);
|
||||
}
|
||||
|
||||
FVector2 VkLightmap::ToUV(const FVector3& vert, const LevelMeshSurface* targetSurface)
|
||||
{
|
||||
FVector3 localPos = vert - targetSurface->translateWorldToLocal;
|
||||
float u = (1.0f + (localPos | targetSurface->projLocalToU)) / (targetSurface->texWidth + 2);
|
||||
float v = (1.0f + (localPos | targetSurface->projLocalToV)) / (targetSurface->texHeight + 2);
|
||||
return FVector2(u, v);
|
||||
}
|
||||
|
||||
void VkLightmap::CreateShaders()
|
||||
{
|
||||
std::string prefix = "#version 460\r\n";
|
||||
|
|
|
@ -149,8 +149,6 @@ private:
|
|||
void CreateDrawIndexedBuffer();
|
||||
void CreateBakeImage();
|
||||
|
||||
static FVector2 ToUV(const FVector3& vert, const LevelMeshSurface* targetSurface);
|
||||
|
||||
static FString LoadPrivateShaderLump(const char* lumpname);
|
||||
|
||||
VulkanRenderDevice* fb = nullptr;
|
||||
|
|
|
@ -864,20 +864,20 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
|
||||
auto gameTexture = TexMan.GetGameTexture(texture);
|
||||
|
||||
float mid1Top = gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale;
|
||||
float mid2Top = gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale;
|
||||
float mid1Top = (float)(gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
float mid2Top = (float)(gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
float mid1Bottom = 0;
|
||||
float mid2Bottom = 0;
|
||||
|
||||
float yTextureOffset = side->textures[side_t::mid].yOffset / gameTexture->GetScaleY();
|
||||
float yTextureOffset = (float)(side->textures[side_t::mid].yOffset / gameTexture->GetScaleY());
|
||||
|
||||
if (side->linedef->flags & ML_DONTPEGBOTTOM)
|
||||
{
|
||||
yTextureOffset += side->sector->planes[sector_t::floor].TexZ;
|
||||
yTextureOffset += (float)side->sector->planes[sector_t::floor].TexZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
yTextureOffset += side->sector->planes[sector_t::ceiling].TexZ - gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale;
|
||||
yTextureOffset += (float)(side->sector->planes[sector_t::ceiling].TexZ - gameTexture->GetDisplayHeight() / side->textures[side_t::mid].yScale);
|
||||
}
|
||||
|
||||
verts[0].Z = min(max(yTextureOffset + mid1Bottom, v1Bottom), v1Top);
|
||||
|
@ -891,7 +891,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevelLocals &doomMap, side_t *side)
|
|||
surf.bSky = false;
|
||||
surf.plane = ToPlane(verts[0], verts[1], verts[2], verts[3]);
|
||||
|
||||
auto offset = FVector3(surf.plane.XYZ()) * 0.05; // for better accuracy when raytracing mid-textures from each side
|
||||
FVector3 offset = surf.plane.XYZ() * 0.05f; // for better accuracy when raytracing mid-textures from each side
|
||||
|
||||
if (side->linedef->sidedef[0] != side)
|
||||
{
|
||||
|
@ -1651,8 +1651,8 @@ void DoomLevelMesh::CreateSurfaceTextureUVs(FLevelLocals& doomMap)
|
|||
auto a = line->v2->fPos() - line->v1->fPos();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
uvs[i].X = tci.FloatToTexU(uvs[i].X * a.Length() + side->textures[side_t::mid].xOffset);
|
||||
uvs[i].Y = tci.FloatToTexV(uvs[i].Y * sideHeight + side->textures[side_t::mid].yOffset);
|
||||
uvs[i].X = tci.FloatToTexU((float)(uvs[i].X * a.Length() + side->textures[side_t::mid].xOffset));
|
||||
uvs[i].Y = tci.FloatToTexV((float)(uvs[i].Y * sideHeight + side->textures[side_t::mid].yOffset));
|
||||
//uvs[i].Y = tci.FloatToTexU(0);
|
||||
//uvs[i].X = uvs[i].X * repeatsU + anchorU / w;
|
||||
//uvs[i].Y = uvs[i].Y * repeatsV + anchorZ / h;
|
||||
|
|
Loading…
Reference in a new issue