Skip to content

Commit bc86421

Browse files
committed
Update PSF core
1 parent b2d23fb commit bc86421

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

shaders/star_frag.glsl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@ varying vec3 v_color;
88
varying float max_theta;
99
varying float pointSize;
1010

11-
float psf_central(float offset)
11+
float psf_core(float offset)
1212
{
1313
// Human eye's point source function from the research by Greg Spencer et al.
14-
// Optimized for the central part of the PSF. The flow from the four neighboring pixels is constant.
14+
// Optimized for the central part of the PSF. The flow from the nine neighboring pixels is constant.
1515
// Designed for degree_per_px == 0.01.
16-
if (offset < 1.6667)
17-
{
18-
return 1.0 + 1.136 * offset * (0.3 * offset - 1.0);
19-
}
20-
return 0.0; // function starts to grow again
16+
return 1.0 + offset * (0.2789 * offset - 1.0);
17+
// the second summand is allowed to be scaled to achieve a seamless transition between modes
2118
}
2219

23-
float psf_outer(float offset)
20+
float psf_glow(float offset)
2421
{
2522
// Human eye's point source function from the research by Greg Spencer et al.
2623
// Optimized for the outer part of the PSF. Designed with bounds by arctangent in mind.
@@ -40,7 +37,6 @@ void main(void)
4037
{
4138
// in fragment shader all points have virtual dimension 1x1, so gl_PointCoord has a value from [0; 1]
4239
float offset = length((gl_PointCoord.xy - vec2(0.5)) * pointSize);
43-
float glow_bw = (max_theta == -1.0) ? psf_central(offset) : psf_outer(offset);
44-
vec3 glow_colored = v_color * glow_bw; // color and brightness scaling
45-
gl_FragColor = vec4(glow_colored, 1.0)+ vec4(0.1, 0.0, 0.0, 0.0);
40+
float black_and_white = (max_theta == -1.0) ? psf_core(offset) : psf_glow(offset);
41+
gl_FragColor = vec4(v_color * black_and_white, 1.0); // + vec4(0.1, 0.0, 0.0, 0.0); // square for debugging
4642
}

0 commit comments

Comments
 (0)