WIP fake raytracer output

This commit is contained in:
RaveYard 2023-08-31 20:06:13 +02:00 committed by Christoph Oelckers
parent 88e6d459ef
commit c63fc707a4
4 changed files with 32 additions and 4 deletions

View file

@ -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);

View file

@ -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));

View file

@ -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)

View file

@ -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; });