commit
9ae14a3d0b
23
assets/opensb/sky.config.patch
Normal file
23
assets/opensb/sky.config.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"sun" : {
|
||||||
|
"rayColor" : [255, 255, 200],
|
||||||
|
"scale" : 0.7, // base scale, dynamic scaling aplies after it (sun image appears to have a higher scale in osb client?)
|
||||||
|
"dynamicImage" : {
|
||||||
|
"enabled" : true,
|
||||||
|
"images" : {
|
||||||
|
"whitestar" : "/sky/orbitals/whitestar.png",
|
||||||
|
"orangestar" : "/sky/orbitals/orangestar.png",
|
||||||
|
"yellowstar" : "/sky/orbitals/yellowstar.png",
|
||||||
|
"bluestar" : "/sky/orbitals/bluestar.png",
|
||||||
|
"redstar" : "/sky/orbitals/redstar.png"
|
||||||
|
},
|
||||||
|
"rayColors" : {
|
||||||
|
"whitestar" : [199, 245, 255],
|
||||||
|
"orangestar" : [255, 227, 199],
|
||||||
|
"yellowstar" : [245, 255, 199],
|
||||||
|
"bluestar" : [199, 199, 255],
|
||||||
|
"redstar" : [255, 213, 199]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
assets/opensb/sky/orbitals/bluestar.png
Normal file
BIN
assets/opensb/sky/orbitals/bluestar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
BIN
assets/opensb/sky/orbitals/orangestar.png
Normal file
BIN
assets/opensb/sky/orbitals/orangestar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
assets/opensb/sky/orbitals/redstar.png
Normal file
BIN
assets/opensb/sky/orbitals/redstar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
assets/opensb/sky/orbitals/whitestar.png
Normal file
BIN
assets/opensb/sky/orbitals/whitestar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
assets/opensb/sky/orbitals/yellowstar.png
Normal file
BIN
assets/opensb/sky/orbitals/yellowstar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -16,6 +16,7 @@ SkyParameters::SkyParameters(CelestialCoordinate const& coordinate, CelestialDat
|
|||||||
auto params = celestialDatabase->parameters(coordinate);
|
auto params = celestialDatabase->parameters(coordinate);
|
||||||
if (!params)
|
if (!params)
|
||||||
return;
|
return;
|
||||||
|
auto systemParams = celestialDatabase->parameters(coordinate.system());
|
||||||
seed = staticRandomU64(params->seed(), "SkySeed");
|
seed = staticRandomU64(params->seed(), "SkySeed");
|
||||||
|
|
||||||
// Gather up all the CelestialParameters and scales for all the celestial
|
// Gather up all the CelestialParameters and scales for all the celestial
|
||||||
@ -50,6 +51,8 @@ SkyParameters::SkyParameters(CelestialCoordinate const& coordinate, CelestialDat
|
|||||||
horizonImages = CelestialGraphics::worldHorizonImages(*params);
|
horizonImages = CelestialGraphics::worldHorizonImages(*params);
|
||||||
|
|
||||||
readVisitableParameters(params->visitableParameters());
|
readVisitableParameters(params->visitableParameters());
|
||||||
|
|
||||||
|
sunType = systemParams->getParameter("typeName").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyParameters::SkyParameters(SkyParameters const& oldSkyParameters, VisitableWorldParametersConstPtr newVisitableParameters) : SkyParameters() {
|
SkyParameters::SkyParameters(SkyParameters const& oldSkyParameters, VisitableWorldParametersConstPtr newVisitableParameters) : SkyParameters() {
|
||||||
@ -108,6 +111,8 @@ SkyParameters::SkyParameters(Json const& config) : SkyParameters() {
|
|||||||
|
|
||||||
spaceLevel = config.optFloat("spaceLevel");
|
spaceLevel = config.optFloat("spaceLevel");
|
||||||
surfaceLevel = config.optFloat("surfaceLevel");
|
surfaceLevel = config.optFloat("surfaceLevel");
|
||||||
|
|
||||||
|
sunType = config.getString("sunType", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
Json SkyParameters::toJson() const {
|
Json SkyParameters::toJson() const {
|
||||||
@ -149,6 +154,7 @@ Json SkyParameters::toJson() const {
|
|||||||
{"ambientLightLevel", jsonFromMaybe<Color>(skyColoring.maybeRight(), [](Color c) { return jsonFromColor(c); })},
|
{"ambientLightLevel", jsonFromMaybe<Color>(skyColoring.maybeRight(), [](Color c) { return jsonFromColor(c); })},
|
||||||
{"spaceLevel", jsonFromMaybe<float>(spaceLevel)},
|
{"spaceLevel", jsonFromMaybe<float>(spaceLevel)},
|
||||||
{"surfaceLevel", jsonFromMaybe<float>(surfaceLevel)},
|
{"surfaceLevel", jsonFromMaybe<float>(surfaceLevel)},
|
||||||
|
{"sunType", sunType},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +169,7 @@ void SkyParameters::read(DataStream& ds) {
|
|||||||
ds >> skyColoring;
|
ds >> skyColoring;
|
||||||
ds >> spaceLevel;
|
ds >> spaceLevel;
|
||||||
ds >> surfaceLevel;
|
ds >> surfaceLevel;
|
||||||
|
ds >> sunType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyParameters::write(DataStream& ds) const {
|
void SkyParameters::write(DataStream& ds) const {
|
||||||
@ -176,6 +183,7 @@ void SkyParameters::write(DataStream& ds) const {
|
|||||||
ds << skyColoring;
|
ds << skyColoring;
|
||||||
ds << spaceLevel;
|
ds << spaceLevel;
|
||||||
ds << surfaceLevel;
|
ds << surfaceLevel;
|
||||||
|
ds << sunType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyParameters::readVisitableParameters(VisitableWorldParametersConstPtr visitableParameters) {
|
void SkyParameters::readVisitableParameters(VisitableWorldParametersConstPtr visitableParameters) {
|
||||||
|
@ -44,6 +44,7 @@ struct SkyParameters {
|
|||||||
Either<SkyColoring, Color> skyColoring;
|
Either<SkyColoring, Color> skyColoring;
|
||||||
Maybe<float> spaceLevel;
|
Maybe<float> spaceLevel;
|
||||||
Maybe<float> surfaceLevel;
|
Maybe<float> surfaceLevel;
|
||||||
|
String sunType;
|
||||||
};
|
};
|
||||||
|
|
||||||
DataStream& operator>>(DataStream& ds, SkyParameters& sky);
|
DataStream& operator>>(DataStream& ds, SkyParameters& sky);
|
||||||
|
@ -95,10 +95,15 @@ List<SkyOrbiter> SkyRenderData::frontOrbiters(Vec2F const& viewSize) const {
|
|||||||
|
|
||||||
List<SkyOrbiter> orbiters;
|
List<SkyOrbiter> orbiters;
|
||||||
if (type == SkyType::Atmospheric || type == SkyType::Atmosphereless) {
|
if (type == SkyType::Atmospheric || type == SkyType::Atmosphereless) {
|
||||||
|
String image;
|
||||||
|
if (settings.queryBool("sun.dynamicImage.enabled", false) && !skyParameters.sunType.empty())
|
||||||
|
image = settings.queryString("sun.dynamicImage.images." + skyParameters.sunType, settings.queryString("sun.image"));
|
||||||
|
else
|
||||||
|
image = settings.queryString("sun.image");
|
||||||
orbiters.append({SkyOrbiterType::Sun,
|
orbiters.append({SkyOrbiterType::Sun,
|
||||||
1.0f,
|
settings.queryFloat("sun.scale", 1.0f),
|
||||||
0.0f,
|
0.0f,
|
||||||
settings.queryString("sun.image"),
|
image,
|
||||||
Vec2F::withAngle(orbitAngle, settings.queryFloat("sun.radius")) + viewSize / 2});
|
Vec2F::withAngle(orbitAngle, settings.queryFloat("sun.radius")) + viewSize / 2});
|
||||||
} else if (type == SkyType::Orbital) {
|
} else if (type == SkyType::Orbital) {
|
||||||
auto planetCenter = Vec2F(viewSize[0] / 2, 0)
|
auto planetCenter = Vec2F(viewSize[0] / 2, 0)
|
||||||
|
@ -380,21 +380,27 @@ void EnvironmentPainter::drawRay(float pixelRatio,
|
|||||||
// Sum is used to vary the ray intensity based on sky color
|
// Sum is used to vary the ray intensity based on sky color
|
||||||
// Rays show up more on darker backgrounds, so this scales to remove that
|
// Rays show up more on darker backgrounds, so this scales to remove that
|
||||||
float sum = std::pow((color[0] + color[1]) * RayColorDependenceScale, RayColorDependenceLevel);
|
float sum = std::pow((color[0] + color[1]) * RayColorDependenceScale, RayColorDependenceLevel);
|
||||||
|
Vec3B rayColor;
|
||||||
|
if (sky.settings.queryBool("sun.dynamicImage.enabled", false) && !sky.skyParameters.sunType.empty())
|
||||||
|
rayColor = jsonToVec3B(sky.settings.query("sun.dynamicImage.rayColors." + sky.skyParameters.sunType, sky.settings.query("sun.rayColor", JsonArray{RayColor[0], RayColor[1], RayColor[2]})));
|
||||||
|
else
|
||||||
|
rayColor = jsonToVec3B(sky.settings.query("sun.rayColor", JsonArray{RayColor[0], RayColor[1], RayColor[2]}));
|
||||||
|
float sunScale = sky.settings.queryFloat("sun.scale", 1.0f);
|
||||||
m_renderer->immediatePrimitives().emplace_back(std::in_place_type_t<RenderQuad>(), TexturePtr(),
|
m_renderer->immediatePrimitives().emplace_back(std::in_place_type_t<RenderQuad>(), TexturePtr(),
|
||||||
RenderVertex{start + Vec2F(std::cos(angle + width), std::sin(angle + width)) * length, {}, Vec4B(RayColor, 0), 0.0f},
|
RenderVertex{start + Vec2F(std::cos(angle + width), std::sin(angle + width)) * length, {}, Vec4B(rayColor, 0), 0.0f},
|
||||||
RenderVertex{start + Vec2F(std::cos(angle + width), std::sin(angle + width)) * SunRadius * pixelRatio,
|
RenderVertex{start + Vec2F(std::cos(angle + width), std::sin(angle + width)) * SunRadius * sunScale * pixelRatio,
|
||||||
{},
|
{},
|
||||||
Vec4B(RayColor,
|
Vec4B(rayColor,
|
||||||
(int)(RayMinUnscaledAlpha + std::abs(m_rayPerlin.get(angle * 896 + time * 30) * RayUnscaledAlphaVariance))
|
(int)(RayMinUnscaledAlpha + std::abs(m_rayPerlin.get(angle * 896 + time * 30) * RayUnscaledAlphaVariance))
|
||||||
* sum
|
* sum
|
||||||
* alpha), 0.0f},
|
* alpha), 0.0f},
|
||||||
RenderVertex{start + Vec2F(std::cos(angle), std::sin(angle)) * SunRadius * pixelRatio,
|
RenderVertex{start + Vec2F(std::cos(angle), std::sin(angle)) * SunRadius * sunScale * pixelRatio,
|
||||||
{},
|
{},
|
||||||
Vec4B(RayColor,
|
Vec4B(rayColor,
|
||||||
(int)(RayMinUnscaledAlpha + std::abs(m_rayPerlin.get(angle * 626 + time * 30) * RayUnscaledAlphaVariance))
|
(int)(RayMinUnscaledAlpha + std::abs(m_rayPerlin.get(angle * 626 + time * 30) * RayUnscaledAlphaVariance))
|
||||||
* sum
|
* sum
|
||||||
* alpha), 0.0f},
|
* alpha), 0.0f},
|
||||||
RenderVertex{start + Vec2F(std::cos(angle), std::sin(angle)) * length, {}, Vec4B(RayColor, 0), 0.0f});
|
RenderVertex{start + Vec2F(std::cos(angle), std::sin(angle)) * length, {}, Vec4B(rayColor, 0), 0.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentPainter::drawOrbiter(float pixelRatio, Vec2F const& screenSize, SkyRenderData const& sky, SkyOrbiter const& orbiter) {
|
void EnvironmentPainter::drawOrbiter(float pixelRatio, Vec2F const& screenSize, SkyRenderData const& sky, SkyOrbiter const& orbiter) {
|
||||||
|
@ -66,10 +66,13 @@ void WorldPainter::render(WorldRenderData& renderData, function<void()> lightWai
|
|||||||
|
|
||||||
m_environmentPainter->renderStars(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderStars(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
m_environmentPainter->renderDebrisFields(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderDebrisFields(starAndDebrisRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
|
if (renderData.skyRenderData.type != SkyType::Atmosphereless)
|
||||||
m_environmentPainter->renderBackOrbiters(orbiterAndPlanetRatio, 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->renderPlanetHorizon(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
m_environmentPainter->renderSky(Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderSky(Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
m_environmentPainter->renderFrontOrbiters(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
m_environmentPainter->renderFrontOrbiters(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
|
if (renderData.skyRenderData.type == SkyType::Atmosphereless)
|
||||||
|
m_environmentPainter->renderBackOrbiters(orbiterAndPlanetRatio, Vec2F(m_camera.screenSize()), renderData.skyRenderData);
|
||||||
|
|
||||||
m_renderer->flush();
|
m_renderer->flush();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user