Skip to main content

Module render

Module render 

Source
Expand description

The demo’s render bridge: an asset server over entities in the render sub-world.

unlit3dx leaves the render bridge to its callers; this module is the demo’s own, built on the runtime’s core and on unlit3d’s generic MeshSource registry. It is a template for a caller’s bridge: register a pipeline family and allocate through the mesh source, and the world is the same registry either way.

The server helpers follow one rule: the world is the registry. A mesh or a material is allocated inside the render world and left there as the GpuMesh or GpuMaterial component of its own asset entity — the GPU handles inside carry Rc, so they cannot cross a thread, but the entity can. A simulation world builds through a job that names the assets by entity, or asks for an entity it does not have yet with a Pending: the answer comes back under the key the request was asked under, and the next job names it.

Re-exports§

use glam::Affine3A; 🔒
use glam::Vec3; 🔒
use unlit_ecs::Bundle; 🔒
use unlit_ecs::DynamicBundle; 🔒
use unlit_ecs::Entity; 🔒
use unlit_ecs::Scope; 🔒
use unlit_ecs::World; 🔒
use unlit_wgpu::pipeline::LitOptions; 🔒
use unlit3d::bounds::FrustumPlanes; 🔒
use unlit3d::components::Camera; 🔒
use unlit3d::components::GpuMaterial; 🔒
use unlit3d::components::GpuMesh; 🔒
use unlit3d::components::GpuRenderPipeline; 🔒
use unlit3d::components::InstanceVisibility; 🔒
use unlit3d::components::Transform; 🔒
use unlit3d::culling::is_culled; 🔒
use unlit3d::lit::LitMeshDesc; 🔒
use unlit3d::lit::LitPipelineKey; 🔒
use unlit3d::mesh_source::MeshSource; 🔒
use unlit3d::source::Source; 🔒
use unlit_ecs::bundle; 🔒
use unlit3dx::job::Job; 🔒

Structs§

BallInstance
One ball and the render instance that stands for it.
OwnedLitMeshDesc
A mesh description that owns its vertex data, so it can cross a thread inside a job; LitMeshDesc is what the render world finally sees.
RenderEntity
An entity of the render sub-world.
Rendered 🔒
One thing the render world draws: a mesh, the material bound to it, the pipeline that draws it and where it stands.

Constants§

FACES 🔒
The unit right and up axes for each cuboid face, with the face’s outward normal, so the six faces share one loop.
WHITE_COLOR
The opaque white every generated mesh vertex carries; materials tint via textures, so the geometry itself stays colorless.

Functions§

allocate_material 🔒
Allocate one material in the render world from a texture built on its device, and answer its asset entity.
allocate_mesh 🔒
Allocate a mesh in the render world, answering its asset entity.
allocate_rgba_material 🔒
Allocate a material over the RGBA image pixels, answering its asset entity.
camera_looking_at
A camera at eye looking at target, with a reverse-z infinite perspective of fov_y_radians fitted to size.
cuboid_mesh
An axis-aligned cuboid from its half extents: 24 vertices (four per face, so each face has clean uvs) and 36 indices, wound CCW as seen from outside.
despawn_instances_job 🔒
A job that despawns the instances it names.
hidden_instance_of 🔒
Spawn one rendered instance that starts hidden, until its body is ready.
instance_of 🔒
Spawn one rendered instance from asset entities, answering the new entity.
linear_sampler
The sampler most textured materials want: linear filtering keeps flat colors clean under minification.
mesh_source 🔒
The render world’s mesh source and the pipeline key its server jobs use.
rgba_texture
A texture of size.0 by size.1 RGBA pixels.
show 🔒
Show one instance: point it at a mesh and material, place it, and make it visible.
sweep 🔒
Retire the instances the camera cannot see: despawn each one and answer with the ones that went, each naming the ball it stood for.
uv_sphere
A lat-long sphere: positions, uvs, opaque white colors and indices.