Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions .agents/skills/mirai-rendering/references/frame-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,38 @@ or interleave its own passes.
a candidate for phase 1.
- One thread per cluster of the chunks: the level cut (`cut.slang`, projected error against
`lod_error_pixels`), frustum, normal cone (closed meshes only) and the pyramid. A visible one
enters the visible list (instance, cluster) and counts in the instance count of the phase's
draw; one that the pyramid hides stays a candidate for phase 1. One of a material with a
Surface program goes to the program list, which `cull_programs.comp` distributes per program
with one indirect draw per program and phase.
enters the visible list (instance, cluster, and where its triangles and posed vertices are:
`visible_entry`) and counts in the instance count of the phase's draw; one that the pyramid
hides stays a candidate for phase 1. One of a material with a Surface program goes to the
program list, which `cull_programs.comp` distributes per program with one indirect draw per
program and phase; so does, in its bin 0, one of no program whose triangles are not small
(`VISIBILITY_TRIANGLE_PIXELS` over the pixels across its box at rest): for large triangles
the vertices of the rasterizer cost less than the pixels of the visibility.
- An instance with all its blend materials is not drawn here; one with blend triangles that
passes the tests (in any phase) turns on the glass passes with their dispatch sizes.
3. **gbuffer**
- One non-indexed indirect draw per phase, 384 vertices per instance and one instance per
visible cluster: the vertex shader reads the cluster from the list and its triangle per
vertex (the triangles that do not pass collapse). Then, one per Surface program in use, with
its pipeline ([programs](materials.md#surface-programs-in-rays-and-raster)). The fragment
shader reads the material row of the cluster's slot and its textures from the table, without
binds per material or per object. Mask: discards below the threshold; blend: not drawn here.
The same on Vulkan and Metal, without mesh shaders or 64-bit atomics.
3. **visibility** and **gbuffer**
- Each phase draws the visibility of the view (`visibility_pass`): one non-indexed indirect
draw, 384 vertices per instance and one instance per visible cluster, whose vertices hand the
fragment only the instance, the cluster and the triangle (the triangles that do not pass
collapse); each pixel keeps the nearest triangle as its instance and primitive, and its
linear depth, which the depth pyramid between the phases reads. The fade of the instance and
the mask of the material are decided there, the mask sampled as the rasterizer would from
the triangle at the pixel (`visible_input.slang`; that of a program as a ray reads it).
Before it, the clusters of the program list leave their depth with the vertices of their
G-buffer and its fade and mask (`gbuffer_depth.frag`), and no triangle where they are in front.
Why: a forest of triangles smaller than a pixel drew every attribute of each vertex (three
a triangle) and its material per fragment; the rasterizer itself costs little.
- After both phases, the G-buffer: the clusters of the program list, one draw per program
with its pipeline ([programs](materials.md#surface-programs-in-rays-and-raster)) and bin 0
with `gbuffer.frag`, where their depth stayed (the test of the depth before the stage, which
writes texture feedback), so each pixel is shaded once;
then `gbuffer_visible.frag` draws each other pixel as `gbuffer.frag` would: the attributes of
its triangle interpolated where the ray of the pixel crosses it, and their derivatives from
the triangle at the next pixels (`MATERIAL_GRADIENTS`), so textures filter as rasterized.
The material row of the cluster's slot and its textures come from the table, without binds
per material or per object; blend is not drawn here. A view with a clip plane draws the
G-buffer with the rasterizer alone (`gbuffer_pass`). The same on Vulkan and Metal, without
mesh shaders or 64-bit atomics.
- The targets are encoded by `gbuffer.frag` and the passes read them only with
`include/gbuffer.slang` (`gbuffer_read`, `gbuffer_normal`, `gbuffer_shading`).
- A reflectance target exists only while a visible instance has an opaque material that does
Expand Down
6 changes: 3 additions & 3 deletions .agents/skills/mirai-rendering/references/scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
the levels of the meshes, the cuts rays trace and the levels of the textures, while visibility
and the image stay those of their own camera. It is what a paused game saw, kept while the
editor looks closer.
- The G-buffer is drawn with one non-indexed indirect draw per phase, whose instance count is
written by the culling: one instance per visible cluster, which the vertex shader reads from the
visible list ([culling](frame-graph.md#passes)). No binds per material or per object.
- The visibility of a view is drawn with one non-indexed indirect draw per phase, whose instance
count is written by the culling: one instance per visible cluster, which the vertex shader reads
from the visible list ([culling](frame-graph.md#passes)). No binds per material or per object.
- `mesh_add` encodes vertices and indices with `asset.mesh_build` at one level and registers them
with `mesh_add_geometry`, which takes the geometry from a file or that made earlier in a job
(`host.assets_render_geometry_make`) with its ray cuts. The meshes made at runtime
Expand Down
Binary file added demo/assets/foliage_extreme/Forest floor.terrain
Binary file not shown.
Binary file added demo/assets/foliage_extreme/Forest.foliage
Binary file not shown.
Binary file added demo/assets/foliage_extreme/foliage_extreme.scene
Binary file not shown.
Loading
Loading