Move lightmap wait into WorldPainter to fix single-frame lightmap lag-behind
unfortunate
This commit is contained in:
parent
afefd89533
commit
dc134e168b
@ -364,38 +364,20 @@ void ClientApplication::render() {
|
|||||||
WorldClientPtr worldClient = m_universeClient->worldClient();
|
WorldClientPtr worldClient = m_universeClient->worldClient();
|
||||||
RendererPtr renderer = Application::renderer();
|
RendererPtr renderer = Application::renderer();
|
||||||
if (worldClient) {
|
if (worldClient) {
|
||||||
|
int64_t start = Time::monotonicMilliseconds();
|
||||||
if (renderer)
|
if (renderer)
|
||||||
renderer->setEffectParameter("lightMapEnabled", true);
|
renderer->setEffectParameter("lightMapEnabled", true);
|
||||||
worldClient->render(m_renderData, TilePainter::BorderTileSize);
|
worldClient->render(m_renderData, TilePainter::BorderTileSize);
|
||||||
// Might have to move lightmap adjustment code back into worldPainter->render
|
|
||||||
// eventually, can't be bothered to remove the passed lambda yet
|
|
||||||
m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); });
|
m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); });
|
||||||
m_mainInterface->renderInWorldElements();
|
m_mainInterface->renderInWorldElements();
|
||||||
if (renderer)
|
if (renderer)
|
||||||
renderer->setEffectParameter("lightMapEnabled", false);
|
renderer->setEffectParameter("lightMapEnabled", false);
|
||||||
|
LogMap::set("render_world", strf("{}ms", Time::monotonicMilliseconds() - start));
|
||||||
}
|
}
|
||||||
|
int64_t start = Time::monotonicMilliseconds();
|
||||||
m_mainInterface->render();
|
m_mainInterface->render();
|
||||||
m_cinematicOverlay->render();
|
m_cinematicOverlay->render();
|
||||||
|
LogMap::set("render_ui", strf("{}ms", Time::monotonicMilliseconds() - start));
|
||||||
if (worldClient && renderer) {
|
|
||||||
worldClient->waitForLighting();
|
|
||||||
|
|
||||||
if (m_renderData.isFullbright) {
|
|
||||||
renderer->setEffectTexture("lightMap", Image::filled(Vec2U(1, 1), { 255, 255, 255, 255 }, PixelFormat::RGB24));
|
|
||||||
renderer->setEffectTexture("tileLightMap", Image::filled(Vec2U(1, 1), { 0, 0, 0, 0 }, PixelFormat::RGBA32));
|
|
||||||
renderer->setEffectParameter("lightMapMultiplier", 1.0f);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_worldPainter->adjustLighting(m_renderData);
|
|
||||||
|
|
||||||
WorldCamera const& camera = m_worldPainter->camera();
|
|
||||||
renderer->setEffectParameter("lightMapMultiplier", assets->json("/rendering.config:lightMapMultiplier").toFloat());
|
|
||||||
renderer->setEffectParameter("lightMapScale", Vec2F::filled(TilePixels * camera.pixelRatio()));
|
|
||||||
renderer->setEffectParameter("lightMapOffset", camera.worldToScreen(Vec2F(m_renderData.lightMinPosition)));
|
|
||||||
renderer->setEffectTexture("lightMap", m_renderData.lightMap);
|
|
||||||
renderer->setEffectTexture("tileLightMap", m_renderData.tileLightMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_errorScreen->accepted())
|
if (!m_errorScreen->accepted())
|
||||||
|
@ -1447,8 +1447,10 @@ void WorldClient::lightingMain() {
|
|||||||
MutexLocker locker(m_lightingMutex);
|
MutexLocker locker(m_lightingMutex);
|
||||||
|
|
||||||
if (m_renderData) {
|
if (m_renderData) {
|
||||||
|
int64_t start = Time::monotonicMilliseconds();
|
||||||
m_lightingCalculator.calculate(m_renderData->lightMap);
|
m_lightingCalculator.calculate(m_renderData->lightMap);
|
||||||
m_renderData = nullptr;
|
m_renderData = nullptr;
|
||||||
|
LogMap::set("render_light_calc", strf("{}ms", Time::monotonicMilliseconds() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lightingCond.wait(m_lightingMutex);
|
m_lightingCond.wait(m_lightingMutex);
|
||||||
|
@ -64,6 +64,25 @@ void WorldPainter::render(WorldRenderData& renderData, function<void()> lightWai
|
|||||||
m_environmentPainter->renderSky(Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderSky(Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
m_environmentPainter->renderFrontOrbiters(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderFrontOrbiters(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
|
|
||||||
|
if (lightWaiter) {
|
||||||
|
int64_t start = Time::monotonicMilliseconds();
|
||||||
|
lightWaiter();
|
||||||
|
LogMap::set("render_light_wait", strf("{}ms", Time::monotonicMilliseconds() - start));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderData.isFullbright) {
|
||||||
|
m_renderer->setEffectTexture("lightMap", Image::filled(Vec2U(1, 1), { 255, 255, 255, 255 }, PixelFormat::RGB24));
|
||||||
|
m_renderer->setEffectTexture("tileLightMap", Image::filled(Vec2U(1, 1), { 0, 0, 0, 0 }, PixelFormat::RGBA32));
|
||||||
|
m_renderer->setEffectParameter("lightMapMultiplier", 1.0f);
|
||||||
|
} else {
|
||||||
|
adjustLighting(renderData);
|
||||||
|
m_renderer->setEffectParameter("lightMapMultiplier", m_assets->json("/rendering.config:lightMapMultiplier").toFloat());
|
||||||
|
m_renderer->setEffectParameter("lightMapScale", Vec2F::filled(TilePixels * m_camera.pixelRatio()));
|
||||||
|
m_renderer->setEffectParameter("lightMapOffset", m_camera.worldToScreen(Vec2F(renderData.lightMinPosition)));
|
||||||
|
m_renderer->setEffectTexture("lightMap", renderData.lightMap);
|
||||||
|
m_renderer->setEffectTexture("tileLightMap", renderData.tileLightMap);
|
||||||
|
}
|
||||||
|
|
||||||
// Parallax layers
|
// Parallax layers
|
||||||
|
|
||||||
auto parallaxDelta = m_camera.worldGeometry().diff(m_camera.centerWorldPosition(), m_previousCameraCenter);
|
auto parallaxDelta = m_camera.worldGeometry().diff(m_camera.centerWorldPosition(), m_previousCameraCenter);
|
||||||
|
Loading…
Reference in New Issue
Block a user