mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
WIP fake raytracer output
This commit is contained in:
parent
88e6d459ef
commit
c63fc707a4
4 changed files with 32 additions and 4 deletions
|
@ -34,9 +34,12 @@ void VkLightmap::Raytrace(hwrenderer::LevelMesh* level)
|
|||
|
||||
UpdateAccelStructDescriptors(); // To do: we only need to do this if the accel struct changes.
|
||||
|
||||
CreateAtlasImages();
|
||||
|
||||
BeginCommands();
|
||||
UploadUniforms();
|
||||
|
||||
|
||||
for (size_t pageIndex = 0; pageIndex < atlasImages.size(); pageIndex++)
|
||||
{
|
||||
RenderAtlasImage(pageIndex);
|
||||
|
|
|
@ -71,6 +71,7 @@ void VkRaytrace::Reset()
|
|||
deletelist->Add(std::move(transferBuffer));
|
||||
deletelist->Add(std::move(nodesBuffer));
|
||||
deletelist->Add(std::move(surfaceBuffer));
|
||||
deletelist->Add(std::move(surfaceIndexBuffer));
|
||||
deletelist->Add(std::move(portalBuffer));
|
||||
deletelist->Add(std::move(blScratchBuffer));
|
||||
deletelist->Add(std::move(blAccelStructBuffer));
|
||||
|
|
|
@ -482,8 +482,8 @@ void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TAr
|
|||
{
|
||||
Printf("Running VkLightmap.\n");
|
||||
|
||||
VkLightmap lightmap(this);
|
||||
lightmap.Raytrace(&mesh);
|
||||
//VkLightmap lightmap(this);
|
||||
//lightmap.Raytrace(&mesh);
|
||||
|
||||
Printf("Copying data.\n");
|
||||
|
||||
|
@ -491,6 +491,10 @@ void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TAr
|
|||
|
||||
auto clamp = [](float a, float min, float max) -> float { return a < min ? min : a > max ? max : a; };
|
||||
|
||||
|
||||
std::sort(mesh.surfaces.begin(), mesh.surfaces.end(), [](const std::unique_ptr<hwrenderer::Surface>& a, const std::unique_ptr<hwrenderer::Surface>& b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; });
|
||||
|
||||
|
||||
RectPacker packer(LMTextureSize, LMTextureSize);
|
||||
|
||||
for (auto& surface : mesh.surfaces)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "g_levellocals.h"
|
||||
|
||||
#include "common/rendering/vulkan/accelstructs/vk_lightmap.h"
|
||||
#include <vulkan/accelstructs/halffloat.h>
|
||||
|
||||
CCMD(dumplevelmesh)
|
||||
{
|
||||
|
@ -511,11 +512,11 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
|
|||
|
||||
hwSurface->boundsMax = surface.bounds.max;
|
||||
hwSurface->boundsMin = surface.bounds.min;
|
||||
|
||||
|
||||
// hwSurface->LightList = // TODO
|
||||
hwSurface->projLocalToU = surface.projLocalToU;
|
||||
hwSurface->projLocalToV = surface.projLocalToV;
|
||||
hwSurface->smoothingGroupIndex = -1;
|
||||
hwSurface->smoothingGroupIndex = 0;
|
||||
hwSurface->texHeight = surface.texHeight;
|
||||
hwSurface->texWidth = surface.texWidth;
|
||||
|
||||
|
@ -524,6 +525,13 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
|
|||
|
||||
hwSurface->texPixels.resize(surface.texWidth * surface.texHeight);
|
||||
|
||||
for (auto& pixel : hwSurface->texPixels)
|
||||
{
|
||||
pixel.X = floatToHalf(0.0);
|
||||
pixel.X = floatToHalf(1.0);
|
||||
pixel.X = floatToHalf(0.0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < surface.numVerts; ++i)
|
||||
{
|
||||
hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]);
|
||||
|
@ -539,6 +547,18 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
|
|||
info.Sky = surface.bSky;
|
||||
|
||||
surfaceInfo.Push(info);
|
||||
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
hwrenderer::SmoothingGroup smoothing;
|
||||
|
||||
for (auto& surface : surfaces)
|
||||
{
|
||||
smoothing.surfaces.push_back(surface.get());
|
||||
}
|
||||
smoothingGroups.Push(std::move(smoothing));
|
||||
}
|
||||
|
||||
std::sort(sortedSurfaces.begin(), sortedSurfaces.end(), [](Surface* a, Surface* b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; });
|
||||
|
|
Loading…
Reference in a new issue