new-stars-v2
Hleb Valoshka 2021-03-13 18:40:12 +02:00
parent 1748e3466b
commit c5f40088d1
5 changed files with 20 additions and 10 deletions

View File

@ -10,8 +10,8 @@ varying highp float brightness;
/*uniform*/ const float sigma2 = 0.35;
/*uniform highp*/ const float glareFalloff = 1.0 / 15.0;
/*uniform highp*/ const float glareBrightness = 0.003;
/*uniform*/ const float diffSpikeBrightness = 0.3;
/*uniform*/ const float exposure = 21.72534925735687;
/*uniform*/ const float diffSpikeBrightness = 0.9;
uniform /*const*/ float exposure/* = 21.72534925735687|74.430977*/;
mediump vec3 linearToSRGB(mediump vec3 c)
{
@ -31,5 +31,5 @@ void main()
float spikes = (max(0.0, 1.0 - abs(offset.x + offset.y)) + max(0.0, 1.0 - abs(offset.x - offset.y))) * diffSpikeBrightness;
b += glareBrightness / (glareFalloff * pow(r2, 1.5) + 1.0) * (spikes + 0.5);
#endif
gl_FragColor = vec4(linearToSRGB(b * exposure * color.rgb * brightness), 1.0);
gl_FragColor = vec4(linearToSRGB(b * exposure * color.rgb * brightness * 5.0), 1.0);
}

View File

@ -11,12 +11,12 @@ attribute vec4 in_Color;
uniform vec2 viewportSize;
uniform vec2 viewportCoord;
/*uniform*/ const float magScale = 1.3369011415551906;
uniform /*const*/ float magScale/* = 1.3369011415551906*/;
/*uniform*/ const float sigma2 = 0.35;
/*uniform highp*/ const float glareFalloff = 1.0 / 15.0;
/*uniform highp*/ const float glareBrightness = 0.003;
/*uniform*/ const float exposure = 21.72534925735687;
/*uniform*/ const float thresholdBrightness = 1.0 / 255.0;
uniform /*const*/ float exposure /*= 21.72534925735687|74.430977*/;
uniform /*const*/ float thresholdBrightness/* = 1.0 / 255.0*/;
varying vec2 pointCenter;
varying vec4 color;

View File

@ -31,10 +31,11 @@ PointStarVertexBuffer::~PointStarVertexBuffer()
delete[] vertices;
}
void PointStarVertexBuffer::startSprites()
void PointStarVertexBuffer::startSprites(float _limitingMagnitude)
{
program = renderer.getShaderManager().getShader("star_new");
pointSizeFromVertex = true;
limitingMagnitude = _limitingMagnitude;
}
void PointStarVertexBuffer::startBasicPoints()
@ -82,6 +83,14 @@ void PointStarVertexBuffer::makeCurrent()
renderer.getViewport(viewport);
program->vec2Param("viewportSize") = Eigen::Vector2f(viewport[2], viewport[3]);
program->vec2Param("viewportCoord") = Eigen::Vector2f(viewport[0], viewport[1]);
float visibilityThreshold = 1.0f / 255.0f;
float logMVisThreshold = log(visibilityThreshold) / log(2.512f);
float saturationMag = limitingMagnitude - 4.5f; //+ logMVisThreshold;
float magScale = (logMVisThreshold) / (saturationMag - limitingMagnitude);
program->floatParam("thresholdBrightness") = visibilityThreshold;
program->floatParam("exposure") = pow(2.512f, magScale * saturationMag);
program->floatParam("magScale") = magScale;
if (pointSizeFromVertex)
{
program->samplerParam("starTex") = 0;

View File

@ -32,7 +32,7 @@ public:
PointStarVertexBuffer& operator=(PointStarVertexBuffer&&) = delete;
void startBasicPoints();
void startSprites();
void startSprites(float);
void render();
void finish();
inline void addStar(const Eigen::Vector3f& pos, const Color&, float);
@ -59,6 +59,7 @@ private:
Texture* texture { nullptr };
bool pointSizeFromVertex { false };
float pointScale { 1.0f };
float limitingMagnitude { 7.0f };
CelestiaGLProgram* program { nullptr };
static PointStarVertexBuffer* current;

View File

@ -4649,11 +4649,11 @@ void Renderer::renderPointStars(const StarDatabase& starDB,
starRenderer.glareVertexBuffer->setPointScale(screenDpi / 96.0f);
PointStarVertexBuffer::enable();
starRenderer.glareVertexBuffer->startSprites();
starRenderer.glareVertexBuffer->startSprites(faintestMag);
if (starStyle == PointStars)
starRenderer.starVertexBuffer->startBasicPoints();
else
starRenderer.starVertexBuffer->startSprites();
starRenderer.starVertexBuffer->startSprites(faintestMag);
#ifdef OCTREE_DEBUG
m_starProcStats.nodes = 0;