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
Closed solids: a ray that finds a solid's inside ends there
shinyobjectz4d5deeedac1e
diff --git a/vendor/bevy_solari/src/pathtracer/pathtracer.wesl b/vendor/bevy_solari/src/pathtracer/pathtracer.weslindex 63c49e53..58e11009 100644--- a/vendor/bevy_solari/src/pathtracer/pathtracer.wesl+++ b/vendor/bevy_solari/src/pathtracer/pathtracer.wesl@@ -102,6 +102,7 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3<u32>) {// raea: a hit seen from its back shaded as its front (bindings.wesl face_hit); its light only from its front,// as light sampling finds itlet hit_front = dot(ray_hit.geometric_world_normal, wo) >= 0.0;+ if !hit_front && !ray_hit.back_lit { break; }ray_hit = face_hit(ray_hit, wo);let NdotV = max(dot(ray_hit.world_normal, wo), 0.0001);let F_ab = F_AB(ray_hit.material.perceptual_roughness, NdotV);diff --git a/vendor/bevy_solari/src/realtime/initial_path.wesl b/vendor/bevy_solari/src/realtime/initial_path.weslindex 62d3d74a..c7aa1199 100644--- a/vendor/bevy_solari/src/realtime/initial_path.wesl+++ b/vendor/bevy_solari/src/realtime/initial_path.wesl@@ -192,6 +192,9 @@ fn generate_initial_path(world_position: vec3<f32>, world_normal: vec3<f32>, matgenerate_emissive_candidate(&path, ray_hit, next_bounce.wi, p_brdf, ray.t, p_nee, di_samples, bounce, rng);}+ // raea: a closed solid's inside (face_hit): dark, nothing more to find+ if !hit_front && !ray_hit.back_lit { break; }+// Try terminating into the world cacheif terminate_into_cache(&path, ray_hit, next_bounce.wi, ray.t, p_brdf, bounce, workgroup_id, rng) {break;diff --git a/vendor/bevy_solari/src/realtime/world_cache_update.wesl b/vendor/bevy_solari/src/realtime/world_cache_update.weslindex ec433fc7..23b1c08d 100644--- a/vendor/bevy_solari/src/realtime/world_cache_update.wesl+++ b/vendor/bevy_solari/src/realtime/world_cache_update.wesl@@ -44,8 +44,11 @@ fn sample_gi(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(global_invlet ray_direction = sample_cosine_hemisphere(geometry_data.world_normal, &rng);let ray = trace_ray(geometry_data.world_position + (geometry_data.world_normal * RAY_T_MIN), ray_direction, RAY_T_MIN, constants.world_cache_max_gi_ray_distance, RAY_FLAG_NONE);if ray.kind != RAY_QUERY_INTERSECTION_NONE {- // raea: a hit seen from its back as its front (bindings.wesl face_hit): its own cell, its light from its side- let ray_hit = face_hit(resolve_ray_hit_full(ray), -ray_direction);+ // raea: a hit seen from its back as its front (bindings.wesl face_hit): its own cell, its light from its side; a+ // closed solid's inside is dark, a sample of nothing+ let unfaced = resolve_ray_hit_full(ray);+ if dot(unfaced.geometric_world_normal, ray_direction) > 0.0 && !unfaced.back_lit { return; }+ let ray_hit = face_hit(unfaced, -ray_direction);let cell_life = atomicLoad(&world_cache.life[cell_index]);let cached = query_world_cache_found(ray_hit.world_position, ray_hit.geometric_world_normal, view.world_position, ray.t, cell_life, &rng);// raea: a hit whose cell holds no light yet is no sample for a cell that has light: this update is skippeddiff --git a/vendor/bevy_solari/src/scene/binder/assets.rs b/vendor/bevy_solari/src/scene/binder/assets.rsindex 5929b9f5..81a514c2 100644--- a/vendor/bevy_solari/src/scene/binder/assets.rs+++ b/vendor/bevy_solari/src/scene/binder/assets.rs@@ -51,9 +51,13 @@ pub struct GpuMaterial {uv_transform_t: Vec2,// raea: StandardMaterial's diffuse_transmission, for a ray's light through a leaf or a curtain (brdf.wesl)diffuse_transmission: f32,- padding: f32,+ // raea: MATERIAL_* below+ flags: u32,}+// raea: GpuMaterial's flags (bindings.wesl MATERIAL_*): StandardMaterial's double_sided, so a ray shades a back face+pub const MATERIAL_DOUBLE_SIDED: u32 = 1;+// raea: how a traced ray treats a material's alpha (bindings.wesl's alpha_accepts)pub const ALPHA_OPAQUE: u32 = 0;pub const ALPHA_MASK: u32 = 1;@@ -246,7 +250,7 @@ impl AssetState {uv_transform_xy: Vec4::new(uv.matrix2.x_axis.x, uv.matrix2.x_axis.y, uv.matrix2.y_axis.x, uv.matrix2.y_axis.y),uv_transform_t: uv.translation,diffuse_transmission: material.diffuse_transmission.clamp(0.0, 1.0),- padding: 0.0,+ flags: if material.double_sided { MATERIAL_DOUBLE_SIDED } else { 0 },},);// raea: a material that turns see-through (or back) moves its instances between the TLAS masksdiff --git a/vendor/bevy_solari/src/scene/bindings.wesl b/vendor/bevy_solari/src/scene/bindings.weslindex 0f14d922..10b33895 100644--- a/vendor/bevy_solari/src/scene/bindings.wesl+++ b/vendor/bevy_solari/src/scene/bindings.wesl@@ -63,9 +63,13 @@ struct Material {uv_transform_t: vec2<f32>,// raea: StandardMaterial's diffuse_transmission: the share of the diffuse light let through to the far sidediffuse_transmission: f32,- padding: f32,+ // raea: MATERIAL_* (assets.rs)+ flags: u32,}+// raea: StandardMaterial's double_sided (assets.rs MATERIAL_DOUBLE_SIDED)+const MATERIAL_DOUBLE_SIDED = 1u;+const TEXTURE_MAP_NONE = 0xFFFFFFFFu;// raea: kept in step with assets.rs ALPHA_*@@ -103,7 +107,8 @@ fn facing_normal(world_normal: vec3<f32>, geometric_world_normal: vec3<f32>, wo:// normals turned toward the ray, as raster turns a double-sided material's. A ray found a back face black before (its// BRDF has nothing below the normal), in the path tracer and in Solari alike. Light passes a thin surface by its// material's diffuse_transmission (brdf.wesl), never by which side was hit. Emission stays one-sided, as light sampling-// has it: a caller checks the side before the turn+// has it: a caller checks the side before the turn. Only a two-sided hit (back_lit) is shaded from behind; a caller+// ends a path at any other back face, the inside of a closed solid, as beforefn face_hit(hit: ResolvedRayHitFull, wo: vec3<f32>) -> ResolvedRayHitFull {var faced = hit;if dot(faced.geometric_world_normal, wo) < 0.0 {@@ -306,6 +311,11 @@ struct ResolvedRayHitFull {world_normal: vec3<f32>,geometric_world_normal: vec3<f32>,world_tangent: vec4<f32>,+ // raea: whether its back is lit as its front: a double-sided material (a sheet, a leaf, a curtain) or one passing+ // light through (diffuse transmission). Any other material is a closed solid's outside, whose inside (found only by a+ // ray started within a hair of a contact) is dark: a path there ends, as raster's back-face culling has it, rather+ // than bounce round a white sphere's inside a hundred times for nothing+ back_lit: bool,uv: vec2<f32>,triangle_area: f32,triangle_count: u32,@@ -423,6 +433,7 @@ fn resolve_triangle_data_full(instance_id: u32, triangle_id: u32, barycentrics:world_normal,geometric_world_normal,world_tangent,+ (material.flags & MATERIAL_DOUBLE_SIDED) != 0u || material.diffuse_transmission > 0.0,uv,triangle_area,instance_geometry_ids.triangle_count,