Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
Solari: the world cache counts sky light only where a ray reaches the sky
shinyobjectz4506c0ca2bcc
diff --git a/vendor/bevy_solari/src/realtime/mod.rs b/vendor/bevy_solari/src/realtime/mod.rsindex 737975a5..f9cac0f7 100644--- a/vendor/bevy_solari/src/realtime/mod.rs+++ b/vendor/bevy_solari/src/realtime/mod.rs@@ -187,8 +187,10 @@ pub struct SolariLighting {/// GI at the cost of longer (more expensive) ray traversal and increased noise./// Lower values are faster and less noisy but may miss distant lighting or leak sky lighting.///- /// Rays that miss within this distance are treated as reaching the environment- /// map light, and leak sky lighting into the cache.+ /// raea: a ray that misses within this distance counts the environment map light only if the rest of it+ /// reaches the sky too (an any-hit query past the cut), so a cut shorter than the scene no longer leaks sky light+ /// into the cache; one blocked past the cut adds nothing. Defaults to 1000 m (upstream 50 m, which flooded photo+ /// 5's hall with sky light).pub world_cache_max_gi_ray_distance: f32,/// Soft upper limit on the number of world cache cells to update each frame.@@ -241,7 +243,7 @@ impl Default for SolariLighting {first_bounce_probability: 1.0,world_cache_max_temporal_samples: 32.0,world_cache_direct_light_sample_count: 32,- world_cache_max_gi_ray_distance: 50.0,+ world_cache_max_gi_ray_distance: 1000.0,world_cache_cell_updates_soft_target: 40000,world_cache_position_base_cell_size: 0.15,world_cache_position_lod_scale: 15.0,diff --git a/vendor/bevy_solari/src/realtime/world_cache_update.wesl b/vendor/bevy_solari/src/realtime/world_cache_update.weslindex c749f9da..73fa4597 100644--- a/vendor/bevy_solari/src/realtime/world_cache_update.wesl+++ b/vendor/bevy_solari/src/realtime/world_cache_update.wesl@@ -3,7 +3,7 @@ import bevy_pbr::render::utils::{rand_f, rand_range_u, sample_cosine_hemisphere}import bevy_render::maths::PI;import package::realtime::presample_light_tiles::unpack_resolved_light_sample;import package::scene::sampling::{calculate_resolved_light_contribution, trace_visibility, sample_environment_map_light};-import package::scene::bindings::{trace_ray, resolve_ray_hit_full, RAY_T_MIN};+import package::scene::bindings::{trace_ray, resolve_ray_hit_full, RAY_T_MIN, RAY_T_MAX};import package::realtime::world_cache_query::query_world_cache_found;import package::realtime::bindings::{light_tile_resolved_samples,@@ -58,10 +58,21 @@ fn sample_gi(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(global_invlet direct = sample_random_light_ris(ray_hit.world_position, ray_hit.geometric_world_normal, workgroup_id.xy, &rng);world_cache.active_cells_new_radiance[active_cell_id.x] += ray_hit.material.base_color * (direct + cached.rgb);} else {- // The ray is cut short at world_cache_max_gi_ray_distance to save on traversal costs.- // A miss here may actually have been a surface further away if we kept tracing, and not actually have been a miss.- // We could be leaking sky light due to this if world_cache_max_gi_ray_distance is too small.- world_cache.active_cells_new_radiance[active_cell_id.x] += PI * sample_environment_map_light(ray_direction);+ // The ray is cut short at world_cache_max_gi_ray_distance to save on traversal costs, so a miss may be a surface+ // further on. raea: it counts the sky only if the rest of the ray reaches it too (one any-hit query, cheap).+ // Upstream counted every miss as sky: in a hall larger than the cut (photo 5's, 41 x 88 x 38 m, under a sky+ // at its physical share of the sun) the cache filled with sky light, and the hall's dark surfaces came out+ // 2-80 times the path tracer's. A ray blocked past the cut adds nothing (the far surface's light is lost, a+ // darker bias where upstream's was a leak); the default cut is 1000 m, so that's rare.+ var escapes = true;+ let cut = constants.world_cache_max_gi_ray_distance;+ if cut < RAY_T_MAX {+ let origin = geometry_data.world_position + (geometry_data.world_normal * RAY_T_MIN) + ray_direction * cut;+ escapes = trace_ray(origin, ray_direction, 0.0, RAY_T_MAX, RAY_FLAG_TERMINATE_ON_FIRST_HIT).kind == RAY_QUERY_INTERSECTION_NONE;+ }+ if escapes {+ world_cache.active_cells_new_radiance[active_cell_id.x] += PI * sample_environment_map_light(ray_direction);+ }}}