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
Ray tracing: a chrome ball under Solari reflects a panorama's sun
shinyobjectzbc052693ac25
diff --git a/vendor/bevy_solari/src/pathtracer/pathtracer.wesl b/vendor/bevy_solari/src/pathtracer/pathtracer.weslindex 767dea6c..9913812d 100644--- a/vendor/bevy_solari/src/pathtracer/pathtracer.wesl+++ b/vendor/bevy_solari/src/pathtracer/pathtracer.wesl@@ -73,7 +73,6 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3<u32>) {// Sample direct lighting, but only if the surface is not mirror-likelet is_perfectly_specular = ray_hit.material.roughness <= MIRROR_ROUGHNESS_THRESHOLD && ray_hit.material.metallic > 0.9999;- sees_sun = is_perfectly_specular;if !is_perfectly_specular {let direct_lighting = sample_random_light(ray_hit.world_position, ray_hit.world_normal, &rng);@@ -90,6 +89,8 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3<u32>) {// Sample new ray direction from the material BRDF for next bounce and apply BRDFlet next_bounce = evaluate_and_sample_brdf(wo, ray_hit.world_normal, ray_hit.material, F_ab, &rng);if next_bounce.pdf == 0.0 { break; }+ // raea: off a mirror's specular lobe, which light sampling can't reach, the ray sees the sun itself+ sees_sun = ray_hit.material.roughness <= MIRROR_ROUGHNESS_THRESHOLD && !next_bounce.diffuse_selected;ray_direction = next_bounce.wi;ray_origin = ray_hit.world_position + (ray_hit.geometric_world_normal * RAY_T_MIN);ray_t_min = RAY_T_MIN;diff --git a/vendor/bevy_solari/src/realtime/initial_path.wesl b/vendor/bevy_solari/src/realtime/initial_path.weslindex ba0efb13..71bba079 100644--- a/vendor/bevy_solari/src/realtime/initial_path.wesl+++ b/vendor/bevy_solari/src/realtime/initial_path.wesl@@ -6,7 +6,7 @@ import package::scene::brdf::{brdf_pdf, evaluate_and_sample_brdf, evaluate_brdf,import package::realtime::presample_light_tiles::unpack_resolved_light_sample;import package::realtime::bindings::{empty_reservoir, light_tile_resolved_samples, light_tile_samples, Reservoir, constants, view};import package::scene::sampling::{calculate_resolved_light_contribution, isinf, LightSample, NULL_LIGHT_ID, power_heuristic, trace_visibility, sample_environment_map_light_and_sun};-import package::scene::bindings::{light_sources, RAY_T_MAX, RAY_T_MIN, resolve_ray_hit_full, ResolvedMaterial, ResolvedRayHitFull, trace_ray};+import package::scene::bindings::{light_sources, MIRROR_ROUGHNESS_THRESHOLD, RAY_T_MAX, RAY_T_MIN, resolve_ray_hit_full, ResolvedMaterial, ResolvedRayHitFull, trace_ray};import package::realtime::world_cache_query::{get_cell_size, query_world_cache, WORLD_CACHE_CELL_LIFETIME};@if(DLSS_RR_GUIDE_BUFFERS)@@ -92,7 +92,11 @@ fn generate_initial_path(world_position: vec3<f32>, world_normal: vec3<f32>, mat// Stochastic NEE, with probability proportional to how diffuse the vertex is. Mirror-like// metals have too narrow a lobe for NEE to help, so mostly skip it there and let// BRDF-sampled emissive do the work. Pure dielectrics always run NEE.- let p_nee = mix(1.0, path.material.perceptual_roughness, path.material.metallic);+ // raea: at least a quarter on a glossy metal short of a perfect mirror, so a small bright light it reflects (a+ // panorama's sun, EnvironmentSun) is sampled often enough to show; NEE's weights divide by p_nee, so this stays+ // unbiased. A perfect mirror still never samples lights and sees the sun in the environment map.+ let p_nee_upstream = mix(1.0, path.material.perceptual_roughness, path.material.metallic);+ let p_nee = select(max(p_nee_upstream, 0.25), p_nee_upstream, path.material.roughness <= MIRROR_ROUGHNESS_THRESHOLD);let di_samples = select(constants.secondary_di_samples, constants.primary_di_samples, bounce == 0u);generate_nee_candidate(&path, F_ab, p_nee, di_samples, workgroup_id, bounce, rng);@@ -107,8 +111,8 @@ fn generate_initial_path(world_position: vec3<f32>, world_normal: vec3<f32>, matpsr_environment_miss(pixel_id, wo);}- // raea: the sun only where this vertex never samples lights (a mirror); elsewhere light sampling finds it- let environment_map_light_radiance = sample_environment_map_light_and_sun(next_bounce.wi, p_nee <= 0.0);+ // raea: the sun only off a mirror's specular lobe, which light sampling can't reach; elsewhere it finds the sun+ let environment_map_light_radiance = sample_environment_map_light_and_sun(next_bounce.wi, path.material.roughness <= MIRROR_ROUGHNESS_THRESHOLD && !next_bounce.diffuse_selected);@if(RESTIR) {generate_environment_map_light_candidate(&path, next_bounce, environment_map_light_radiance, primary_F_ab, bounce, rng);} @else {