MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / exportCachePreview

Method exportCachePreview

Source/Engine/ShadowsOfMordor/Builder.Debug.cpp:69–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67#if DEBUG_EXPORT_CACHE_PREVIEW
68
69void ShadowsOfMordor::Builder::exportCachePreview(SceneBuildCache* scene, GenerateHemispheresData& cacheData, LightmapBuildCache& lightmapEntry) const
70{
71 auto settings = &scene->GetSettings();
72 auto atlasSize = (int32)settings->AtlasSize;
73
74 int32 bytesPerPixel = 3;
75 int32 dataSize = atlasSize * atlasSize * bytesPerPixel;
76 byte* data = new byte[dataSize];
77
78 {
79 auto tmpPath = GetDebugDataPath() / String::Format(TEXT("Scene{1}_lightmapCache_{0}_Posiion.bmp"), _workerStagePosition0, scene->SceneIndex);
80 auto mipData = cacheData.PositionsData.GetData(0, 0);
81
82 for (int32 x = 0; x < cacheData.PositionsData.Width; x++)
83 {
84 for (int32 y = 0; y < cacheData.PositionsData.Height; y++)
85 {
86#if CACHE_POSITIONS_FORMAT == HEMISPHERES_FORMAT_R32G32B32A32
87 Float3 color(mipData->Get<Float4>(x, y));
88#elif CACHE_POSITIONS_FORMAT == HEMISPHERES_FORMAT_R16G16B16A16
89 Float3 color = mipData->Get<Half4>(x, y).ToFloat3();
90#endif
91 color /= 100.0f;
92
93 const int32 pos = ((cacheData.PositionsData.Height - y - 1) * cacheData.PositionsData.Width + x) * 3;
94 data[pos + 0] = (byte)(color.Z * 255);
95 data[pos + 1] = (byte)(color.Y * 255);
96 data[pos + 2] = (byte)(color.X * 255);
97 }
98 }
99
100 FileSystem::SaveBitmapToFile(data, atlasSize, atlasSize, bytesPerPixel * 8, 0, tmpPath);
101 }
102
103 {
104 auto tmpPath = GetDebugDataPath() / String::Format(TEXT("Scene{1}_lightmapCache_{0}_Normal.bmp"), _workerStagePosition0, scene->SceneIndex);
105 Platform::MemoryClear(data, dataSize);
106 auto mipData = cacheData.NormalsData.GetData(0, 0);
107
108 for (int32 x = 0; x < cacheData.NormalsData.Width; x++)
109 {
110 for (int32 y = 0; y < cacheData.NormalsData.Height; y++)
111 {
112#if CACHE_NORMALS_FORMAT == HEMISPHERES_FORMAT_R32G32B32A32
113 Float3 color(mipData->Get<Float4>(x, y));
114#elif CACHE_NORMALS_FORMAT == HEMISPHERES_FORMAT_R16G16B16A16
115 Float3 color = mipData->Get<Half4>(x, y).ToFloat3();
116#endif
117 color.Normalize();
118
119 const int32 pos = ((cacheData.NormalsData.Height - y - 1) * cacheData.NormalsData.Width + x) * 3;
120 data[pos + 0] = (byte)(color.Z * 255);
121 data[pos + 1] = (byte)(color.Y * 255);
122 data[pos + 2] = (byte)(color.X * 255);
123 }
124 }
125
126 FileSystem::SaveBitmapToFile(data, atlasSize, atlasSize, bytesPerPixel * 8, 0, tmpPath);

Callers

nothing calls this directly

Calls 7

GetDebugDataPathFunction · 0.85
MemoryClearFunction · 0.85
GetSettingsMethod · 0.80
FormatFunction · 0.50
GetDataMethod · 0.45
ToFloat3Method · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected