Skip to content

Commit 85ee257

Browse files
committed
New label brightness formula
1 parent 317f973 commit 85ee257

File tree

4 files changed

+17
-27
lines changed

4 files changed

+17
-27
lines changed

src/celastro/astro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ constexpr inline float LN_MAG = 1.0857362f; // 5/ln(100)
3030

3131
// Lowest screen brightness of a point to render
3232
constexpr inline float LOWEST_IRRADIATION = 1.0f / 255.0f;
33-
// = 1.0f / (255.0f * 12.92f); after implementing gamma correction
33+
// = 1.0f / (255.0f * 12.92f); after implementing gamma correction
3434

3535
namespace detail
3636
{

src/celengine/dsorenderer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ void DSORenderer::process(DeepSkyObject* const &dso,
190190
float irradiationEff = astro::magToIrradiance(appMagEff) * exposure;
191191
if (irradiationEff > labelLowestIrradiation)
192192
{
193-
// TODO: the label transparency is not tested, most likely need fixes
194-
float distr = std::min(1.0f, step * (irradiationEff - labelLowestIrradiation) / labelLowestIrradiation);
193+
float distr = irradiationEff / labelLowestIrradiation;
195194
labelColor.alpha(distr * labelColor.alpha());
196195

197196
renderer->addBackgroundAnnotation(rep,

src/celengine/pointstarrenderer.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,20 @@ void PointStarRenderer::process(const Star& star, float distance, float irradian
101101
if (irradiation > astro::LOWEST_IRRADIATION)
102102
{
103103
starVertexBuffer->addStar(relPos, starColor, irradiation);
104-
}
105104

106-
// Place labels for stars brighter than the specified label threshold brightness
107-
if (((labelMode & Renderer::StarLabels) != 0) && irradiation > labelLowestIrradiation)
108-
{
109-
Vector3f starDir = relPos.normalized();
110-
if (starDir.dot(viewNormal) > cosFOV)
105+
// Place labels for stars brighter than the specified label threshold brightness
106+
if (((labelMode & Renderer::StarLabels) != 0) && irradiation > labelLowestIrradiation)
111107
{
112-
// TODO: the label transparency is not tested, most likely need fixes
113-
float distr = min(1.0f, 3.5f * (irradiation - labelLowestIrradiation)/labelLowestIrradiation);
114-
Color color = Color(Renderer::StarLabelColor, distr * Renderer::StarLabelColor.alpha());
115-
renderer->addBackgroundAnnotation(nullptr,
116-
starDB->getStarName(star, true),
117-
color,
118-
relPos);
108+
Vector3f starDir = relPos.normalized();
109+
if (starDir.dot(viewNormal) > cosFOV)
110+
{
111+
float distr = labelLowestIrradiation / irradiation;
112+
Color color = Color(Renderer::StarLabelColor, distr * Renderer::StarLabelColor.alpha());
113+
renderer->addBackgroundAnnotation(nullptr,
114+
starDB->getStarName(star, true),
115+
color,
116+
relPos);
117+
}
119118
}
120119
}
121120
}

src/celengine/render.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ using namespace celestia::engine;
9696
using namespace celestia::render;
9797
using celestia::util::GetLogger;
9898

99-
static const int REF_DISTANCE_TO_SCREEN = 400; //[mm]
100-
10199
// Contribution from planetshine beyond this distance (in units of object radius)
102100
// is considered insignificant.
103101
static const float PLANETSHINE_DISTANCE_LIMIT_FACTOR = 100.0f;
@@ -3739,10 +3737,7 @@ void Renderer::renderPointStars(const StarDatabase& starDB,
37393737
starRenderer.labelMode = labelMode;
37403738
starRenderer.SolarSystemMaxDistance = SolarSystemMaxDistance;
37413739

3742-
// Original function
3743-
// float effDistanceToScreen = mmToInches((float) REF_DISTANCE_TO_SCREEN) * pixelSize * getScreenDpi(); // = 1.0 at startup
3744-
// starRenderer.labelThresholdMag = 1.2f * max(1.0f, (faintestMag - 4.0f) * (1.0f - 0.5f * std::log10(effDistanceToScreen)));
3745-
starRenderer.labelLowestIrradiation = 1.0f; // refinement is needed
3740+
starRenderer.labelLowestIrradiation = 1.0f;
37463741

37473742
starRenderer.colorTemp = &starColors;
37483743

@@ -3815,11 +3810,8 @@ void Renderer::renderDeepSkyObjects(const Universe& universe,
38153810

38163811
dsoRenderer.frustum = projectionMode->getInfiniteFrustum(MinNearPlaneDistance, observer.getZoom());
38173812
// Use pixelSize * screenDpi instead of FoV, to eliminate windowHeight dependence.
3818-
3819-
// Original function
3820-
// float effDistanceToScreen = mmToInches((float) REF_DISTANCE_TO_SCREEN) * pixelSize * getScreenDpi(); // = 1.0 at startup
3821-
// dsoRenderer.labelThresholdMag = 2.0f * max(1.0f, (faintestMag - 4.0f) * (1.0f - 0.5f * log10(effDistanceToScreen)));
3822-
dsoRenderer.labelLowestIrradiation = 1.0f; // refinement is needed
3813+
3814+
dsoRenderer.labelLowestIrradiation = 1.0f;
38233815

38243816
using namespace celestia;
38253817
galaxyRep = MarkerRepresentation(MarkerRepresentation::Triangle, 8.0f, GalaxyLabelColor);

0 commit comments

Comments
 (0)