chris wrote:Here's a patch that addresses the black stars and core in globulars.
glob-patch.zip
I changed just two lines in globular.cpp. First the blending of the sprite:
Code: Select all
@@ -387,7 +387,7 @@
if (br > 1.0f)
br = 1.0f;
- glColor4f(Rr * br, Gg * br, Bb * br, A);
+ glColor4f(Rr, Gg, Bb, A * br);
glBegin(GL_QUADS);
The alpha factor is multiplied by the brightness instead of the color components. Since source blend mode is GL_SRC_ALPHA, the color components will be multiplied by the alpha factor during rasterization. Thus, my patch results in no change to the color of the stars. Multiplying alpha by br means that a dark cloud sprite will also tend to be nearly transparent.
The change for stars is quite similar:
Code: Select all
@@ -462,7 +462,7 @@
Color col = (r_3d < 2 * r_c && pow2 < 256)? colorTable[255]: colorTable[iR];
- glColor4f(col.red() * br, col.green() * br, col.blue() * br, 1.0f - wgt);
+ glColor4f(col.red(), col.green(), col.blue(), (1.0f - wgt) * br);
Point3f relPos = p + offset;
I
think that this is OK. Certainly it fixes the dark stars problem, but I look at the code some more to better understand the role of the (1 - wgt) term.
I will also have a look at the possibility of using additive blending.
--Chris
Chris,
that sounds almost too simple to me?
Your patch does not affect the RGB colors. No doubt about that
BUT....
The way I constructed things in alpha was as follows:
--------------------------------------------------------------------
The procedural "cloud" texture is RGBA, with A containing as a weight ONLY the
rho-dependent part
relStarDensity(rho) ; rho = r_2d / r_c
of the overall alpha blending weight.
The resolution dependent (pixelWeight), but rho-independent part is subsequently implemented into the cloud texture via
glColor4f(Rr * br, Gg * br, Bb * br, A);
where A = 3.0f * pixelWeight
Hence altogether we have the
overall alpha-weight for the cloud texture:
A * relStarDensity(rho)
For the star sprite textures, the overall blending weight should be
1 - A * relStarDensity(r_2d / r_c))
in order to
maintain the underlying King profile, independently of the blending transition. That's what it is in my code!
It seems to me that your simple proposal breaks that basic relation once you multiply with the factor br. At least that's why I didn't do that!
Fridger