API reference

aster_blueprint::fluid_render

Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.

Dye field -> image: tone mapping, colour ramp, glow, optional bicubic upscale, dithering.

Everything is f32 with + - * / sqrt only (no libm transcendentals), so a render is as deterministic as the simulation: the same [Fluid] and [FluidStyle] give the same bytes. The result is a straight RGBA8 image (opaque over a background, or premultiplied light when background is None) that [image_recording] wraps in one Recorder::image command, so it paints like any other recording (Surface::Recording, NodeDescription::drawing).

Structs

structaster_blueprint::fluid_render::FluidImage

pub struct FluidImage { /* see fields */ }

A rendered frame: tightly packed RGBA8, w * h * 4 bytes.

Public fields

fieldtype
wu32
hu32
rgbaVec<u8>
premultipliedbooltrue when the colour channels are premultiplied by alpha (background: None).

Trait implementations: Clone, Debug, Default, Eq, PartialEq, StructuralPartialEq

structaster_blueprint::fluid_render::FluidRenderer

pub struct FluidRenderer { /* see fields */ }

Reusable render buffers: rendering many frames allocates only when the size changes.

Methods

  • fn new() -> Self
  • fn render(&mut self, fluid: &Fluid, style: &FluidStyle) -> &FluidImage — Render fluid with style. The returned image borrows the renderer's buffer.

Trait implementations: Clone, Debug, Default

structaster_blueprint::fluid_render::FluidStyle

pub struct FluidStyle { /* see fields */ }

How a [Fluid] is turned into pixels.

Public fields

fieldtype
exposuref32Brightness before tone mapping (d -> 1 - 1/(1 + e d + (e d)^2 / 2), about 1 - exp(-e d)).
glowf32Bloom amount added from a blurred copy, 0 off, 0.3..0.8 is a soft glow.
backgroundOption<[u8; 3]>Colour the dye is added to (light on a dark base), sRGB. None renders premultiplied light on a transparent image so the panel behind shows through.
rampOption<Vec<(f32, [u8; 3])>>Colour ramp (position 0..1, sRGB) applied to the tone-mapped density; needs at least two stops. With a ramp the dye colour is ignored and only its density matters.
obstacle[u8; 3]Colour of obstacle cells.
upscaleusizeOutput pixels per grid cell per axis, 1..=4. 1 leaves the smoothing to the renderer's bilinear sampling, more upsamples with Catmull-Rom (sharper, costs time).
saturationf321 keeps the colours, <1 washes them out, >1 pushes them.

Methods

  • fn ember() -> Vec<(f32, [u8; 3])> — Flame / ember ramp: black, deep red, orange, yellow, white.
  • fn ice() -> Vec<(f32, [u8; 3])> — Cool ink ramp: navy, teal, cyan, white.

Trait implementations: Clone, Debug, Default, PartialEq, StructuralPartialEq

Functions

fnaster_blueprint::fluid_render::image_recording

pub fn image_recording(img: &FluidImage, width: f64, height: f64) -> Result<std::sync::Arc<aster_ui::Recording>, aster_ui::Error>

Wrap a rendered frame in a one-command recording that stretches it over (0, 0, width, height) with bilinear sampling. This is the value core.fluid.dye.v1 outputs inside a Surface.

fnaster_blueprint::fluid_render::render_recording

pub fn render_recording(fluid: &fluid::Fluid, style: &FluidStyle, width: f64, height: f64) -> Result<std::sync::Arc<aster_ui::Recording>, aster_ui::Error>

One-shot convenience: render fluid and wrap it.