Skip to content

Commit

Permalink
(semi)fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
375gnu committed Jul 7, 2024
1 parent 2bd203f commit 7719c66
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion shaders/star_vert.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// star_frag.glsl
// star_vert.glsl
//
// Copyright (C) 2023-present, the Celestia Development Team
// Original rendering algorithm by Askaniy Anpilogov <[email protected]>
Expand All @@ -9,6 +9,8 @@
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

const float a = 0.123; // empirical constant

const float degree_per_px = 0.01; // higher value causes blinking due to optimizations in the psf_glow()
const float max_square_size = 256.0; // px
const float max_irradiation = pow((degree_per_px * max_square_size / a), 2.0) / (2.0 * 3.141592653);
Expand Down
15 changes: 7 additions & 8 deletions src/celengine/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ static void renderSphereUnlit(const RenderInfo& ri,
textures.push_back(ri.overlayTex);
}
if (ri.isStar)
shadprop.lightModel = ShaderProperties::StarModel;
shadprop.lightModel = LightingModel::StarModel;

// Get a shader for the current rendering configuration
auto* prog = r->getShaderManager().getShader(shadprop);
Expand Down Expand Up @@ -2791,12 +2791,14 @@ void Renderer::renderPlanet(Body& body,
{
if (float maxCoeff = body.getSurface().color.toVector3().maxCoeff(); maxCoeff > 0.0f) // ignore [ 0 0 0 ]; used by old addons to make objects not get rendered as point
{
#if 0
renderObjectAsPoint(pos,
body.getRadius(),
appMag,
discSizeInPixels,
body.getSurface().color * (1.0f / maxCoeff), // normalize point color; 'darkness' is handled by size of point determined by GeomAlbedo.
false, false, m);
#endif
}
}
}
Expand Down Expand Up @@ -2851,13 +2853,15 @@ void Renderer::renderStar(const Star& star,
rp, LightingState(), m);
}

#if 0
renderObjectAsPoint(pos,
star.getRadius(),
appMag,
discSizeInPixels,
color,
star.hasCorona(), true,
m);
#endif
}


Expand Down Expand Up @@ -3166,7 +3170,7 @@ void Renderer::buildRenderLists(const Vector3d& astrocentricObserverPos,
// Compute the irradiance
// Instead of summing the reflected light from all nearby stars,
// we just consider the one with the highest irradiance.
float irradiance = 1.175494e-38f; // minimum positive float value
float irradiance = std::numeric_limits<float>::min();
for (const auto &lightSource : lightSourceList)
{
Eigen::Vector3d sunPos = pos_v - lightSource.position;
Expand All @@ -3183,7 +3187,7 @@ void Renderer::buildRenderLists(const Vector3d& astrocentricObserverPos,
rle.position = pos_v.cast<float>();
rle.distance = (float) dist_v;
rle.centerZ = pos_v.cast<float>().dot(viewMatZ);
rle.irradiation = irradiation;
rle.irradiation = irradiance;
rle.discSizeInPixels = body->getRadius() / ((float) dist_v * pixelSize);

// TODO: Remove this. It's only used in two places: for calculating comet tail
Expand Down Expand Up @@ -3625,11 +3629,6 @@ void Renderer::renderStars(const StarDatabase& starDB,

starRenderer.starVertexBuffer->finish();
StarVertexBuffer::disable();

#ifndef GL_ES
if (toggleAA)
enableMSAA();
#endif
}

void Renderer::renderDeepSkyObjects(const Universe& universe,
Expand Down
1 change: 0 additions & 1 deletion src/celengine/renderinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Texture;
struct RenderInfo
{
Eigen::Quaternionf orientation{ Eigen::Quaternionf::Identity() };
Color color{ 1.0f, 1.0f, 1.0f };
Texture* baseTex{ nullptr };
Texture* bumpTex{ nullptr };
Texture* nightTex{ nullptr };
Expand Down
2 changes: 1 addition & 1 deletion src/celengine/shadermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ ShaderManager::buildFragmentShader(const ShaderProperties& props)
}

// Include the effect of limb darkening.
if (props.lightModel == ShaderProperties::StarModel)
if (props.lightModel == LightingModel::StarModel)
{
source += "gl_FragColor.rgb = gl_FragColor.rgb - vec3(1.0 - NV) * vec3(0.56, 0.61, 0.72);\n";
}
Expand Down
18 changes: 11 additions & 7 deletions src/celestia/celestiacore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,15 +1467,19 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers)
break;

case '[':
setExposure(sim->getExposure() * 0.5);
auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure());
flash(buf);
{
setExposure(sim->getExposure() * 0.5);
auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure());
flash(buf);
}
break;

case ']':
setExposure(sim->getExposure() * 2.0);
auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure());
flash(buf);
{
setExposure(sim->getExposure() * 2.0);
auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure());
flash(buf);
}
break;

case '\\':
Expand Down Expand Up @@ -2459,7 +2463,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
set_or_unset(interactionFlags, InteractionFlags::FocusZooming, config->mouse.focusZooming);

sim = new Simulation(universe);
sim->setExposure(config->renderDetails.Exposure);
sim->setExposure(config->renderDetails.exposure);

viewManager = std::make_unique<ViewManager>(new View(View::ViewWindow, sim->getActiveObserver(), 0.0f, 0.0f, 1.0f, 1.0f));

Expand Down

0 comments on commit 7719c66

Please sign in to comment.