Skip to content

Commit e203600

Browse files
committed
labels fixing
1 parent 7719c66 commit e203600

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

shaders/star_frag.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ void main(void)
4444
// in fragment shader all points have virtual dimension 1x1, so gl_PointCoord has a value from [0; 1]
4545
float offset = length((gl_PointCoord.xy - vec2(0.5)) * pointSize);
4646
float point = (max_theta == -1.0) ? psf_core(offset) : psf_glow(offset);
47-
gl_FragColor = vec4(v_color * point, 1.0); // + vec4(0.1, 0.0, 0.0, 0.0); // square for debugging
47+
gl_FragColor = vec4(v_color * point, 1.0); // + vec4(0.1, 0.0, 0.0, 0.0); // red square for debugging
4848
}

shaders/star_vert.glsl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
// as published by the Free Software Foundation; either version 2
1010
// of the License, or (at your option) any later version.
1111

12-
const float a = 0.123; // empirical constant
13-
1412
const float degree_per_px = 0.01; // higher value causes blinking due to optimizations in the psf_glow()
15-
const float max_square_size = 256.0; // px
16-
const float max_irradiation = pow((degree_per_px * max_square_size / a), 2.0) / (2.0 * 3.141592653);
13+
const float max_square_size = 512.0; // px
14+
const float glow_scale = 0.123; // empirical constant, deg (not to change)
15+
const float max_irradiation = pow((degree_per_px * max_square_size / glow_scale), 2.0) / (2.0 * 3.141592653);
1716

1817
varying vec3 v_color;
1918
varying float max_theta;
@@ -25,7 +24,7 @@ attribute float in_PointSize;
2524

2625
const float color_saturation_limit = 0.1; // the ratio of the minimum color component to the maximum
2726

28-
//! Normalizes the color by its green value and corrects extreme saturation
27+
// Normalizes the color by its green value and corrects extreme saturation
2928
vec3 green_normalization(vec3 color)
3029
{
3130
// color /= max(color.r, max(color.g, color.b)); // we do this in XYZRGBConverter::convertUnnormalized()
@@ -54,8 +53,8 @@ void main(void)
5453
else
5554
{
5655
// Bright light source (glow mode)
57-
float irradiation = atan(in_PointSize / max_irradiation) * max_irradiation; // dimmed brightness
58-
max_theta = 0.123 * sqrt(irradiation); // emperical glow radius
56+
float irradiation = atan(in_PointSize / max_irradiation) * max_irradiation; // dimming
57+
max_theta = glow_scale * sqrt(irradiation);
5958
float half_sq = max_theta / degree_per_px;
6059
pointSize = 2.0 * half_sq - 1.0;
6160
v_color = color;

src/celengine/dsorenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void DSORenderer::process(DeepSkyObject* const &dso,
190190
float irradiationEff = astro::magToIrradiance(appMagEff) * exposure;
191191
if (irradiationEff > labelLowestIrradiation)
192192
{
193-
float distr = irradiationEff / labelLowestIrradiation;
193+
float distr = 1.0f - irradiationEff / labelLowestIrradiation;
194194
labelColor.alpha(distr * labelColor.alpha());
195195

196196
renderer->addBackgroundAnnotation(rep,

src/celengine/starrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void StarRenderer::process(const Star& star, float distance, float irradiance)
108108
Vector3f starDir = relPos.normalized();
109109
if (starDir.dot(viewNormal) > cosFOV)
110110
{
111-
float distr = labelLowestIrradiation / irradiation;
111+
float distr = 1.0f - labelLowestIrradiation / irradiation;
112112
Color color = Color(Renderer::StarLabelColor, distr * Renderer::StarLabelColor.alpha());
113113
renderer->addBackgroundAnnotation(nullptr,
114114
starDB->getStarName(star, true),

0 commit comments

Comments
 (0)