22 vec4 center_color = imageLoad(uInputLightmap, coord);
23 vec4 center_dir = imageLoad(uInputDir, coord);
29 imageStore(uOutputLightmap, coord,
vec4(0.0));
30 imageStore(uOutputDir, coord,
vec4(0.0));
36 float total_weight = 0.0;
43 vec4 neighbor_color = imageLoad(uInputLightmap, neighbor_coord);
44 vec4 neighbor_dir = imageLoad(uInputDir, neighbor_coord);
48 if (neighbor_ids.
y < 0)
continue;
50 float dist_sq = float(x*x + y*y);
51 float w_spatial = exp(-dist_sq / 16.0);
53 float normal_dot = max(0.0, dot(center_normal, neighbor_normal));
54 float w_normal = pow(normal_dot, 16.0);
56 float pos_dist_sq = dot(center_pos - neighbor_pos, center_pos - neighbor_pos);
57 float w_position = exp(-pos_dist_sq / 0.05);
59 float weight = w_spatial * w_normal * w_position;
61 sum_color += neighbor_color * weight;
62 sum_dir += neighbor_dir * weight;
63 total_weight += weight;
67 vec4 final_color = (total_weight > 0.0) ? (sum_color / total_weight) : center_color;
68 vec4 final_dir = (total_weight > 0.0) ? (sum_dir / total_weight) : center_dir;
69 imageStore(uOutputLightmap, coord, final_color);
70 imageStore(uOutputDir, coord, final_dir);