Skip to main content

Module custom_pipeline

Module custom_pipeline 

Source
Expand description

A caller-owned pipeline: a procedural sky and an animated particle cloud.

Every other scene in the example draws through the built-in lit family. This one registers two families of its own — pipelines, vertex layouts and bind groups the example owns — to pin the parts of the renderer a caller reaches without going through the built-in shader at all:

  • a sky family whose shader reconstructs a view ray from the frame’s camera, samples a procedurally generated cube map, and blends a gradient and a sun from a uniform block the example writes every frame. Its only bind group is the caller’s own: the family names its three inputs when it makes the recipe, so the group is rebuilt when one of them is replaced and never because a draw moved to another camera;
  • a particle family whose per-instance stream comes from an ordinary world component, and whose vertex stage animates the sprite from a clock the example advances. It takes the frame-bound recipe for the camera, as a built-in family does, and adds its own uniform block at the material group.

Neither family declares a single mesh vertex attribute: the sky’s three vertices and each particle’s six come from the vertex index, so the meshes carry nothing but a count and a bounding box. The animation is parametric: the camera orbits the cloud while the particles drift and spin from one clock, so the window drives it from the frame delta instead of holding each frozen frame, and its snapshots freeze eight instants of that orbit. Its look is deliberately flat: banded colours, hard-edged sprites and a hard-edged sun rather than any attempt at a photographic sky.

Re-exports§

use std::sync::Arc; 🔒
use unlit_ecs::Bundle; 🔒
use unlit_ecs::DynamicBundle; 🔒
use unlit_ecs::bundle; 🔒
use super::SEQUENCE_STEP; 🔒
use super::SceneControl; 🔒
use super::SceneDef; 🔒
use super::SceneOptions; 🔒
use super::TEST_FORMAT; 🔒
use super::TEST_SIZE; 🔒
use super::camera_looking_at; 🔒
use unlit_wgpu::pipeline::GlobalBindings; 🔒
use unlit_wgpu::pipeline::global_bind_group_layout; 🔒
use unlit_wgpu::pipeline::supports_storage_buffers; 🔒
use unlit_wgpu::resources::ResHandle; 🔒
use unlit_wgpu::resources::ResourceGraph; 🔒
use unlit_wgpu::resources::TextureExt; 🔒
use unlit_wgpu::resources::TextureView; 🔒
use unlit_wgpu::specialize::PipelineVariant; 🔒
use unlit_wgpu::specialize::RenderPipelineDesc; 🔒
use unlit_wgpu::specialize::SpecializedPipeline; 🔒
use unlit_wgpu::specialize::SurfaceKey; 🔒
use unlit_wgpu::specialize::SurfaceTarget; 🔒
use unlit3d::pipeline::DrawContext; 🔒
use unlit3d::pipeline::FamilyContext; 🔒
use unlit3d::pipeline::GlobalRecipe; 🔒
use unlit3d::pipeline::InstanceContext; 🔒
use unlit3d::pipeline::InstanceData; 🔒
use unlit3d::pipeline::InstanceStreamDesc; 🔒
use unlit3d::pipeline::RegisteredRenderPipeline; 🔒
use unlit3d::pipeline::RenderPipelineFactory; 🔒
use unlit3d::pipeline::RenderPipelineKey; 🔒
use zerocopy::IntoBytes; 🔒
use zerocopy::IntoBytes; 🔒
use unlit3d::prelude::*; 🔒

Structs§

Particle 🔒
The per-particle data the family reads, as a plain world component.
ParticleFactory 🔒
The particle family’s factory.
ParticleInstances 🔒
The particle family’s per-instance stream.
ParticleKey 🔒
The identity of the particle family’s pipeline.
ParticleRecord 🔒
One particle’s record on the instance stream.
ParticleUniforms 🔒
The particle family’s uniform block, as the shader reads it.
ParticleVariant 🔒
The particle family’s blueprint, specialised for one render target.
Sky 🔒
The scene’s sky: the mesh that covers the target and the pipeline that shades it.
SkyFactory 🔒
The sky family’s factory.
SkyKey 🔒
The identity of the sky family’s pipeline, keyed on the compiled descriptor.
SkyUniforms 🔒
The sky family’s uniform block, as the shader reads it.
SkyVariant 🔒
The sky family’s blueprint, specialised for one render target.
Sprite 🔒
One particle of the cloud.

Constants§

CAMERA_TARGET 🔒
The point the camera looks at.
FRAMES 🔒
How many frames the scene freezes.
ORBIT_HEIGHT 🔒
The height the camera orbits at, in metres.
ORBIT_RADIANS_PER_SECOND 🔒
Radians the window turns the orbit per second.
ORBIT_RADIUS 🔒
The radius the camera orbits at, in metres.
ORBIT_START 🔒
The angle the orbit starts at, in radians.
ORBIT_STEP 🔒
Radians the orbit turns between two frames of the frozen sequence.
PARTICLE_COUNT 🔒
How many particles the cloud holds.
PARTICLE_INSTANCE_SLOT 🔒
The vertex-buffer slot the particle family’s instance stream takes.
PARTICLE_SHADER 🔒
The particle shader.
PARTICLE_TINTS 🔒
The hues the particles cycle through.
PARTICLE_VERTICES 🔒
The vertices of one particle’s billboard quad.
SKY_EXTENT 🔒
How far the sky’s bounding box reaches, in metres.
SKY_FACE_SIZE 🔒
The edge of one cube face of the procedural sky, in texels.
SKY_FORMAT 🔒
The format of the procedural cube map.
SKY_SHADER 🔒
The sky’s shader.
SKY_VERTICES 🔒
The vertices of the sky’s full-target triangle.
SUN_DIRECTION 🔒
The direction the sun sits in, in world space.

Statics§

SCENE
The scene: a procedural sky and an orbiting particle cloud, both drawn by families the example owns and animated in real time from the frame delta.

Functions§

build 🔒
Build the scene’s world content.
cube_direction 🔒
The direction a cube-map texel looks along.
hash3 🔒
A deterministic hash of three integers into the unit interval.
orbit_eye 🔒
The eye point of the orbit at angle radians.
particle_cloud 🔒
The particle cloud: a ring of sprites, each with its own orbit, size, hue and shape.
particle_instance_layout 🔒
The instance-step vertex layout of one particle record.
particle_material_layout 🔒
The layout of the particle family’s material group.
particle_pipeline 🔒
Compile the particle family’s pipeline.
sky_bind_group_layout 🔒
The layout of the sky family’s one bind group.
sky_pipeline 🔒
Compile the sky family’s pipeline against the family’s bind group layout.
sky_texel 🔒
The colour one cube-map texel takes, from the direction it looks along.
upload_sky_cubemap 🔒
Create the procedural cube map and fill each of its six faces.
value_noise 🔒
Trilinearly interpolated value noise over the integer lattice.