MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / Update

Method Update

BakingLab/MeshBaker.cpp:1326–1679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1324}
1325
1326MeshBakerStatus MeshBaker::Update(const Camera& camera, uint32 screenWidth, uint32 screenHeight,
1327 ID3D11DeviceContext* deviceContext, const Model* currentModel)
1328{
1329 Assert_(initialized);
1330
1331 const bool32 showGroundTruth = AppSettings::ShowGroundTruth;
1332
1333 if(currentModel != input.SceneModel)
1334 {
1335 KillBakeThreads();
1336 KillRenderThreads();
1337
1338 sceneBVH = BVHData();
1339 input.SceneModel = currentModel;
1340 BuildBVH(*input.SceneModel, sceneBVH, input.Device, rtcDevice);
1341
1342 InterlockedIncrement64(&renderTag);
1343 InterlockedIncrement64(&bakeTag);
1344 currTile = 0;
1345 currBakeBatch = 0;
1346
1347 // Make sure that we re-extract the lightmap data
1348 currLightMapSize = 0;
1349 }
1350
1351 if(showGroundTruth == false)
1352 {
1353 // Handle light map size change, which requires re-extraction of sample points
1354 const uint32 lightMapSize = AppSettings::LightMapResolution;
1355 const BakeModes bakeMode = AppSettings::BakeMode;
1356 const SolveModes solveMode = AppSettings::SolveMode;
1357 if(lightMapSize != currLightMapSize || bakeMode != currBakeMode || solveMode != currSolveMode)
1358 {
1359 KillBakeThreads();
1360 KillRenderThreads();
1361
1362 ExtractBakePoints(input, bakePoints, gutterTexels);
1363 bakePointBuffer.Initialize(input.Device, sizeof(BakePoint), uint32(bakePoints.size()),
1364 false, false, false, bakePoints.data());
1365
1366 const uint64 basisCount = AppSettings::BasisCount(bakeMode);
1367 const uint64 numTexels = lightMapSize * lightMapSize;
1368 for(uint64 i = 0; i < AppSettings::MaxBasisCount; ++i)
1369 bakeResults[i].Shutdown();
1370
1371 for(uint64 i = 0; i < basisCount; ++i)
1372 bakeResults[i].Init(numTexels);
1373
1374 const uint64 numGroupsX = (lightMapSize + (BakeGroupSizeX - 1)) / BakeGroupSizeX;
1375 const uint64 numGroupsY = (lightMapSize + (BakeGroupSizeY - 1)) / BakeGroupSizeY;
1376 if(AppSettings::SupportsProgressiveIntegration(bakeMode, solveMode))
1377 currNumBakeBatches = numGroupsX * numGroupsY * AppSettings::NumBakeSamples * AppSettings::NumBakeSamples;
1378 else
1379 currNumBakeBatches = numGroupsX * numGroupsY * BakeGroupSize;
1380
1381 currLightMapSize = lightMapSize;
1382 currBakeMode = bakeMode;
1383 currSolveMode = solveMode;

Callers 1

ExtractBakePointsFunction · 0.45

Calls 15

BVHDataClass · 0.85
BuildBVHFunction · 0.85
ExtractBakePointsFunction · 0.85
BasisCountFunction · 0.85
SGCountFunction · 0.85
InitializeSGSolverFunction · 0.85
InitialGuessFunction · 0.85
DXCallFunction · 0.85
HasSunDirChangedFunction · 0.85
SaturateFunction · 0.85

Tested by

no test coverage detected