@@ -32,57 +32,16 @@ highp vec4 pack_depth(highp float ndc_z) {
3232 return res;
3333}
3434
35- #ifdef INDICATOR_CUTOUT
36- uniform vec3 u_indicator_cutout_centers;
37- uniform vec4 u_indicator_cutout_params;
38- #endif
39-
4035const float DITHER_THRESHOLDS[16 ] = float [16 ](
4136 1.0 / 17.0 , 9.0 / 17.0 , 3.0 / 17.0 , 11.0 / 17.0 ,
4237 13.0 / 17.0 , 5.0 / 17.0 , 15.0 / 17.0 , 7.0 / 17.0 ,
4338 4.0 / 17.0 , 12.0 / 17.0 , 2.0 / 17.0 , 10.0 / 17.0 ,
4439 16.0 / 17.0 , 8.0 / 17.0 , 14.0 / 17.0 , 6.0 / 17.0
4540);
4641
47- vec4 applyCutout(vec4 color, float height) {
48- #ifdef INDICATOR_CUTOUT
49- float verticalFadeRange = u_indicator_cutout_centers.z * 0.25 ; // Fade relative to the height of the indicator
50- float holeMinOpacity = mix (1.0 , u_indicator_cutout_params.x, smoothstep (u_indicator_cutout_centers.z, u_indicator_cutout_centers.z + verticalFadeRange, height));
51- float holeRadius = max (u_indicator_cutout_params.y, 0.0 );
52- float holeAspectRatio = u_indicator_cutout_params.z;
53- float fadeStart = u_indicator_cutout_params.w;
54- float distA = distance (vec2 (gl_FragCoord .x, gl_FragCoord .y * holeAspectRatio), vec2 (u_indicator_cutout_centers[0 ], u_indicator_cutout_centers[1 ] * holeAspectRatio));
55- return color * min (smoothstep (fadeStart, holeRadius, distA) + holeMinOpacity, 1.0 );
56- #else
57- return color;
58- #endif
59- }
60-
61- // Cutout with uniform vertical transparency across the building face.
62- // All coordinates are in NDC [-1,1]. Centers, radius, fadeStart pre-converted to NDC on CPU.
63- // groundRoof = (groundNdcX, groundNdcY, roofNdcX, roofNdcY).
64- // Returns indicator cutout opacity for dithering. Color is not modified.
65- float cutoutGroundRoofOpacity(vec4 groundRoof) {
66- #ifdef INDICATOR_CUTOUT
67- float fadeStartX = u_indicator_cutout_params.w;
68- float holeRadius = u_indicator_cutout_params.y;
69-
70- float holeMinOpacity = mix (u_indicator_cutout_params.x, 1.0 ,
71- smoothstep (u_indicator_cutout_params.z, u_indicator_cutout_centers.z, groundRoof.y));
72-
73- float distX = abs (u_indicator_cutout_centers.x - groundRoof.x);
74-
75- float roofOpacity = mix (holeMinOpacity, 1.0 ,
76- smoothstep (fadeStartX, holeRadius,
77- u_indicator_cutout_centers.y - groundRoof.w));
78-
79- float groundOpacity = min (smoothstep (fadeStartX, holeRadius, distX)
80- + holeMinOpacity, 1.0 );
81-
82- return max (roofOpacity, groundOpacity);
83- #else
84- return 1.0 ;
85- #endif
42+ // Bayer dither index in gl_FragCoord framebuffer space (front-cutoff, indicator cutout).
43+ int viewport_dither_index(vec2 fragCoordXY) {
44+ return (int (fragCoordXY.x) % 4 ) * 4 + (int (fragCoordXY.y) % 4 );
8645}
8746
8847#ifdef DEBUG_WIREFRAME
0 commit comments