@@ -8,21 +8,18 @@ varying vec3 v_color;
88varying float max_theta;
99varying float pointSize;
1010
11- float psf_central (float offset)
11+ float psf_core (float offset)
1212{
13- // 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.
13+ // Human eye's point source function from the research by Greg Spencer et al. (1995)
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{
25- // Human eye's point source function from the research by Greg Spencer et al.
22+ // Human eye's point source function from the research by Greg Spencer et al. (1995)
2623 // Optimized for the outer part of the PSF. Designed with bounds by arctangent in mind.
2724 // Causes star blinking with degree_per_px > 0.01, large grid misses the center peak of brightness.
2825 float theta = offset * degree_per_px;
@@ -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