@@ -14,7 +14,10 @@ uniform float u_edge_radius;
1414uniform float u_width_scale;
1515
1616in ivec4 a_pos_normal_ed;
17+
18+ #if defined(HAS_CENTROID) || defined(TERRAIN)
1719in uvec2 a_centroid_pos;
20+ #endif
1821
1922#ifdef RENDER_WALL_MODE
2023in ivec3 a_join_normal_inside;
@@ -101,28 +104,26 @@ void main() {
101104 base *= u_vertical_scale;
102105 height *= u_vertical_scale;
103106
104- vec4 pos_normal_ed = vec4 (a_pos_normal_ed);
105- vec4 pos_nx = floor (pos_normal_ed * 0.5 );
107+ vec4 top_up_ny_start = vec4 (a_pos_normal_ed & 1 );
108+ vec4 pos_nx = vec4 (a_pos_normal_ed >> 1 );
106109 // The least significant bits of a_pos_normal_ed hold:
107110 // x is 1 if it's on top, 0 for ground.
108111 // y is 1 if the normal points up, and 0 if it points to side.
109112 // z is sign of ny: 1 for positive, 0 for values <= 0.
110113 // w marks edge's start, 0 is for edge end, edgeDistance increases from start to end.
111- vec4 top_up_ny_start = pos_normal_ed - 2.0 * pos_nx;
112- vec3 top_up_ny = top_up_ny_start.xyz;
113114
114115 float x_normal = pos_nx.z / 8192.0 ;
115- vec3 normal = top_up_ny .y == 1.0 ? vec3 (0.0 , 0.0 , 1.0 ) : normalize (vec3 (x_normal, (2.0 * top_up_ny .z - 1.0 ) * (1.0 - abs (x_normal)), 0.0 ));
116+ vec3 normal = top_up_ny_start .y == 1.0 ? vec3 (0.0 , 0.0 , 1.0 ) : normalize (vec3 (x_normal, (2.0 * top_up_ny_start .z - 1.0 ) * (1.0 - abs (x_normal)), 0.0 ));
116117#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
117118 v_normal = normal;
118119#endif
119120
120121 base = max (0.0 , base);
121122
122123 float attr_height = height;
123- height = max (0.0 , top_up_ny .y == 0.0 && top_up_ny .x == 1.0 ? height - u_edge_radius : height);
124+ height = max (0.0 , top_up_ny_start .y == 0.0 && top_up_ny_start .x == 1.0 ? height - u_edge_radius : height);
124125
125- float t = top_up_ny .x;
126+ float t = top_up_ny_start .x;
126127
127128 vec2 centroid_pos = vec2 (0.0 );
128129#if defined(HAS_CENTROID) || defined(TERRAIN)
@@ -141,11 +142,10 @@ void main() {
141142 float h_height = is_flat_height ? max (c_ele + height, ele + base + 2.0 ) : ele + height;
142143 float h_base = is_flat_base ? max (c_ele + base, ele + base) : ele + (base == 0.0 ? - 5.0 : base);
143144 h = t > 0.0 ? max (h_base, h_height) : h_base;
144- pos = vec3 (pos_nx.xy, h);
145145#else
146146 h = t > 0.0 ? height : base;
147- pos = vec3 (pos_nx.xy, h);
148147#endif
148+ pos = vec3 (pos_nx.xy, h);
149149
150150#ifdef PROJECTION_GLOBE_VIEW
151151 // If t > 0 (top) we always add the lift, otherwise (ground) we only add it if base height is > 0
@@ -247,7 +247,7 @@ void main() {
247247 y_ground += y_ground * 5.0 / max (3.0 , top_height);
248248#endif // TERRAIN
249249 v_ao = vec2 (mix (concave, - concave, start), y_ground);
250- NdotL *= (1.0 + 0.05 * (1.0 - top_up_ny .y) * u_ao[0 ]); // compensate sides faux ao shading contribution
250+ NdotL *= (1.0 + 0.05 * (1.0 - top_up_ny_start .y) * u_ao[0 ]); // compensate sides faux ao shading contribution
251251
252252#ifdef PROJECTION_GLOBE_VIEW
253253 top_height += u_height_lift;
@@ -258,7 +258,7 @@ void main() {
258258#ifdef LIGHTING_3D_MODE
259259
260260#ifdef FLOOD_LIGHT
261- float is_wall = 1.0 - float (t > 0.0 && top_up_ny .y > 0.0 );
261+ float is_wall = 1.0 - float (t > 0.0 && top_up_ny_start .y > 0.0 );
262262 v_has_floodlight = float (flood_light_wall_radius > 0.0 && is_wall > 0.0 );
263263 v_flood_radius = flood_light_wall_radius * u_vertical_scale;
264264#endif // FLOOD_LIGHT
0 commit comments