diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 473f4b01da..f482fdeaca 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3338,8 +3338,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) { @@ -3409,6 +3414,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; + } } } }