From e4d99058ad93bef502a807fcd035349dda1f6ddf Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:09:31 +0200 Subject: [PATCH] CPU raytrace basic test --- src/maploader/maploader.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index f10094782..cc7f92e8d 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3343,8 +3343,13 @@ void MapLoader::InitLightmap(MapData* map) Level->LMTextureSize = 1024; // TODO cvar + // TODO read from ZDRayInfoThing + Level->SunColor = FVector3(1.f, 1.f, 1.f); + Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f); + Level->LMTextureCount = Level->levelMesh->SetupLightmapUvs(Level->LMTextureSize); + // Debug placeholder stuff { auto constructDebugTexture = [&](TArray& buffer, int layers, int width, int height) { @@ -3414,6 +3419,19 @@ void MapLoader::InitLightmap(MapData* map) ptr[1] = floatToHalf(0.0f); ptr[2] = floatToHalf(0.0f); } + + if (Level->levelMesh->TraceSky(surface.worldOrigin - surface.worldStepX - surface.worldStepY + surface.worldStepX * x + surface.worldStepY * y + FVector3(surface.plane.Normal()), Level->SunDirection, 32000.0f)) + { + ptr[0] = floatToHalf(Level->SunColor.X); + ptr[1] = floatToHalf(Level->SunColor.Y); + ptr[2] = floatToHalf(Level->SunColor.Z); + } + else + { + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + } } } }