Repository navigation
Glass is a part of its mesh - #161
Merged
Merged
Conversation
The last reason to flatten a material's triangles at every placement goes (ROADMAP § 6 step 3). A mesh's glass is a geometry of its BLAS beside the opaque and the cutout one, the only one not flagged opaque; a placement stays one instance. - A shadow ray, which passed glass by the still scene's masks, culls the geometry that is not opaque where an instanced mesh has glass (kernel feature F_IGLASS); `glass_tr` weighs what the glass lets through as before. Software traversal: a flag a triangle (units), the flattening's flags. - A hit's triangle from its geometry and primitive: two starts in the instance's record (`InstMesh::part_offsets`). - Which side of a surface a ray meets goes by the instance's sign: a mirrored glass instance refracts as its mirror image does. - A glass mesh is added in place where the kernel has the feature; a material of instances' triangles that turns glass, or stops, rebuilds. - What still leaves a mesh: triangles on exactly the same vertices (`flatten_coincident`: a cutout on an emitter, glass on what lies under it), and the emitters of a mesh that deforms. Measured first on Metal with every geometry flagged opaque and the cull flag on shadow rays: the same pictures, at most 0.5 % of a frame's GPU time. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…by its mask Culled inside its BLAS, a scene of many glass panes traced slower (400 instanced panes under a low sun: trace 5.34 ms for 4.62 with the panes flattened). A mesh that is all glass needs no cull: its instances cast no shadow, by the mask a shadow ray already goes by (`InstMesh::casts`); the same scene reads 4.45 ms, the picture unchanged. The cull, and its kernel feature, are left to a mesh that has glass among other triangles. A glass mesh added in place needs nothing of the kernel. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Under software traversal its unit's glass triangles are skipped by their flag: no live test read that (the all-glass ones go by the unit's own flag). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A mesh that is all glass is out of a shadow ray's way by its instance's mask; the cull and its kernel feature are for a mesh that mixes glass with other triangles. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every group's geometry is flagged opaque since glass went into its mesh; the size estimate asks with that flag too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last reason to flatten a material's triangles at every placement goes: glass. Next part of ROADMAP § 6 step 3, after functions and mirrored placements (#160).
The experiment first
A shadow ray passes glass by the still scene's instance masks; an instance's glass sits in the same BLAS as its opaque triangles. Two structures were open: glass as a geometry of the mesh's BLAS that a shadow ray culls (
RAY_FLAG_CULL_NO_OPAQUE), or glass split into a BLAS and an instance of its own. The kernel's notes had the cull flag as slow on Metal (Bistro +1.7 ms; its use for cutouts then). Measured again before building anything: every geometry flagged opaque and shadow rays with the cull flag instead of forced opacity, so that nothing may change.So: one BLAS a mesh, and a placement stays one instance.
What changes
InstMesh::parts). Cutout geometries and the still scene's groups are flagged opaque now: every other query forces opacity and sees no difference.InstMesh::casts). No kernel feature, no cost.F_IGLASS). Under software traversal a unit's glass triangles carry the no-shadow flag, as the flattened ones do.glass_trweighs what the glass lets through as before.Why two rules: the first version culled inside every glass mesh's BLAS, and a scene of 400 glass panes then traced 5.34 ms for main's 4.62; with the mask 4.45 (under the loop guard: a direction, not a timing; the pictures the same).
What still leaves a mesh and is flattened at a placement: triangles on exactly the same vertices (
flatten_coincident: a cutout on an emitter, glass on whatever lies under it), and the emitters of a mesh that deforms. The rest arrays stay for those.Tests
shadow/glass-tint-instance*), an instanced copy (shadow/glass-tint-instanced).tests/render/data/frame-pane.glb): the light through the glass offline and live (shadow/glass-model,-live-exact), and the other two parts' shadows (-frame,-cutout).glass/mirrored-instance: two slabs, mirror images, one placed with a negative scale, show the wall behind alike.surface's normal without the instance's sign, the edit guard.Not covered
glass_at's normal under a mirroring instance (it decides total reflection where a volume's voxel rays cross glass): set by the same sign, no test reads it.THREERT_INSTANCING=log), so only the test model takes that path.🤖 Generated with Claude Code
Note
High Risk
Changes hardware and software ray traversal, BLAS layout, and live-edit feature gating for glass—core path-tracing behavior with performance-sensitive shadow-ray culling.
Overview
Instanced meshes no longer flatten glass at every placement. Glass triangles stay in the shared model-space BLAS as a third geometry (opaque → cutout → glass), with only the glass geometry left non-opaque.
Shadow handling uses two paths: all-glass meshes skip shadow queries via instance masks (
InstMesh::casts); mixed meshes enable kernel featureF_IGLASSso hardware RT usesRAY_FLAG_CULL_NO_OPAQUEon shadow rays and software traversal skipsTRI_NO_SHADOWglass. Transmission weighting viaglass_tris unchanged. Hit triangle indexing andglass_atnormals account for a third geometry offset in instance records and mirrored instance sign.Build and live paths classify materials with
mesh_class(glass = class 2), extendflatten_coincidentfor glass-on-coincident-vertices only, and allow adding all-glass meshes in place while rebuild when a fixed instanced material toggles glass. Docs and render/unit tests cover shadows through instance glass, mixed glTF meshes, and mirrored panes.Reviewed by Cursor Bugbot for commit 51ef9ba. Bugbot is set up for automated code reviews on this repo. Configure here.