Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/rendering
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 08:37:27 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 08:37:27 +1000
commit204d449dda9180682d6077b96010f72fe758a505 (patch)
tree3f5534d4261fe42b452ac7a1e1e1d1aeb06b7f9b /source/rendering
parentb43c59e828b148d28e9c7ca0ff8da290b7f47b89 (diff)
Change how the game renders the world backdrops
Diffstat (limited to 'source/rendering')
-rw-r--r--source/rendering/StarEnvironmentPainter.cpp19
-rw-r--r--source/rendering/StarWorldPainter.cpp15
2 files changed, 26 insertions, 8 deletions
diff --git a/source/rendering/StarEnvironmentPainter.cpp b/source/rendering/StarEnvironmentPainter.cpp
index 32ff529..aa2763b 100644
--- a/source/rendering/StarEnvironmentPainter.cpp
+++ b/source/rendering/StarEnvironmentPainter.cpp
@@ -14,7 +14,7 @@ float const EnvironmentPainter::SunFadeRate = 0.07f;
float const EnvironmentPainter::MaxFade = 0.3f;
float const EnvironmentPainter::RayPerlinFrequency = 0.005f; // Arbitrary, part of using the Perlin as a PRNG
float const EnvironmentPainter::RayPerlinAmplitude = 2;
-int const EnvironmentPainter::RayCount = 60;
+int const EnvironmentPainter::RayCount = 60;
float const EnvironmentPainter::RayMinWidth = 0.8f; // % of its sector
float const EnvironmentPainter::RayWidthVariance = 5.0265f; // % of its sector
float const EnvironmentPainter::RayAngleVariance = 6.2832f; // Radians
@@ -125,7 +125,7 @@ void EnvironmentPainter::renderDebrisFields(float pixelRatio, Vec2F const& scree
biggest = biggest.piecewiseMax(texture->size());
}
- float screenBuffer = ceil((float)biggest.max() * (float)Constants::sqrt2) * 2.0f;
+ float screenBuffer = ceil((float)biggest.max() * (float)Constants::sqrt2);
PolyF field = PolyF(RectF::withSize(viewMin + velocityOffset, viewSize).padded(screenBuffer));
Vec2F debrisAngularVelocityRange = jsonToVec2F(debrisField.query("angularVelocityRange"));
@@ -400,7 +400,20 @@ void EnvironmentPainter::drawRay(float pixelRatio,
void EnvironmentPainter::drawOrbiter(float pixelRatio, Vec2F const& screenSize, SkyRenderData const& sky, SkyOrbiter const& orbiter) {
float alpha = 1.0f;
- Vec2F position = orbiter.position * pixelRatio;
+ Vec2F position;
+
+ // The way Starbound positions these is weird.
+ // It's a random point on a 400 by 400 area from the bottom left of the screen.
+ // That origin point is then multiplied by the zoom level.
+ // This does not intuitively scale with higher-resolution monitors, so lets fix that.
+ if (orbiter.type == SkyOrbiterType::Moon) {
+ const Vec2F correctionOrigin = { 320, 180 };
+ // correctionOrigin is 1920x1080 / default zoom level / 2, the most likely dev setup at the time.
+ Vec2F offset = orbiter.position - correctionOrigin;
+ position = (screenSize / 2) + offset * pixelRatio;
+ }
+ else
+ position = orbiter.position * pixelRatio;
if (orbiter.type == SkyOrbiterType::Sun) {
alpha = sky.dayLevel;
diff --git a/source/rendering/StarWorldPainter.cpp b/source/rendering/StarWorldPainter.cpp
index 07f61e0..693b419 100644
--- a/source/rendering/StarWorldPainter.cpp
+++ b/source/rendering/StarWorldPainter.cpp
@@ -57,12 +57,17 @@ void WorldPainter::render(WorldRenderData& renderData, function<void()> lightWai
// Stars, Debris Fields, Sky, and Orbiters
- m_environmentPainter->renderStars(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
- m_environmentPainter->renderDebrisFields(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
- m_environmentPainter->renderBackOrbiters(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
- m_environmentPainter->renderPlanetHorizon(m_camera.pixelRatio(), Vec2F(m_camera.screenSize()), renderData.skyRenderData);
+ // Use a fixed pixel ratio for certain things.
+ float pixelRatioBasis = m_camera.screenSize()[1] / 1080.0f;
+ float starAndDebrisRatio = lerp(0.0625f, pixelRatioBasis * 2.0f, m_camera.pixelRatio());
+ float orbiterAndPlanetRatio = lerp(0.125f, pixelRatioBasis * 3.0f, m_camera.pixelRatio());
+
+ m_environmentPainter->renderStars(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
+ m_environmentPainter->renderDebrisFields(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
+ m_environmentPainter->renderBackOrbiters(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
+ m_environmentPainter->renderPlanetHorizon(orbiterAndPlanetRatio, 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(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
if (lightWaiter) {
int64_t start = Time::monotonicMilliseconds();