lactea_render/lib.rs
1// SPDX-FileCopyrightText: 2026 Gianluca Boiano
2// SPDX-FileCopyrightText: 2005-2013 Nullsoft, Inc.
3// SPDX-License-Identifier: (MIT OR Apache-2.0) AND BSD-3-Clause
4
5//! wgpu backend reproducing the MilkDrop 2 frame pipeline; host-provided device, renders into any texture.
6//!
7//! This crate is a port of MilkDrop 2's `CPlugin::RenderFrame` (milkdropfs.cpp) and the texture /
8//! noise setup of plugin.cpp. It knows nothing about presets, expressions, HLSL or audio: the
9//! engine evaluates a preset's equations, builds a [`FrameInput`] and calls
10//! [`Renderer::render_frame`].
11//!
12//! Frame pipeline (all internal images `Rgba8Unorm`, never sRGB):
13//!
14//! 1. motion vectors are drawn onto the *previous* image (MD2 order),
15//! 2. warp pass `prev -> next` (user warp shader, or `WarpedBlit_NoShaders`),
16//! 3. blur chain from the previous image, only up to the highest level a shader uses,
17//! 4. custom shapes, custom waves, main wave, darken-center, borders on `next`,
18//! 5. composite `next -> final` (user comp shader on the 32x24 comp mesh, or
19//! `ShowToUser_NoShaders`: video echo, gamma, brighten/darken/solarize/invert),
20//! 6. blit `final` to the host target (sRGB-compensated if needed).
21//!
22//! With `Compat::MilkDrop2` the engine may hand over [`Md2Blend`] data (`FrameInput::md2_blend`): MilkDrop 2's own
23//! preset blend, where steps 2, 4 and 5 run once or twice (old and new shader, alpha-tiled) on a blended warp mesh.
24//!
25//! Where MilkDrop 2 and projectM differ, [`Compat`] picks the behaviour (default projectM).
26//!
27//! # Features
28//!
29//! * `diagnostics` (off by default): reference-comparison hooks (image injection, extra read-backs).
30#![warn(missing_docs)]
31// The pipeline is a port of MD2 / projectM code: their literals (`6.28`, `3.1415926535898`, ...) are deliberate and
32// differ from the exact constants, the per-pass functions take the reference code's many parameters, and the loops
33// index several parallel arrays the way the reference does.
34#![allow(
35 clippy::approx_constant,
36 clippy::excessive_precision,
37 clippy::too_many_arguments,
38 clippy::needless_range_loop
39)]
40// Test code builds `FrameInput`s field by field and walks pixel buffers in 4-byte chunks; clarity over lint style.
41#![cfg_attr(
42 test,
43 allow(clippy::field_reassign_with_default, clippy::chunks_exact_to_as_chunks)
44)]
45
46mod blend;
47mod blur;
48mod config;
49mod frame;
50mod geom;
51mod motion;
52pub mod noise;
53mod renderer;
54mod rng;
55mod shaders;
56mod stroke;
57mod transition;
58pub mod uniforms;
59pub mod warp_mesh;
60pub mod wavegen;
61
62pub use blend::{Md2Blend, Md2OldPass, cosine_interp};
63pub use config::{Compat, CompatRules, CompiledShader, RenderConfig, RenderError, StrokeRaster};
64pub use frame::{
65 BlurParams, Borders, CustomWave, FrameInput, MainWave, MotionVectors, PassRandom, PostParams,
66 ShapeImage, ShapeInstance, WarpGpu, WavePoint,
67};
68pub use renderer::Renderer;
69pub use rng::Rng;
70pub use transition::{TransitionBlender, TransitionKind, TransitionParams};
71#[cfg(feature = "diagnostics")]
72pub use uniforms::RotParams;
73pub use warp_mesh::MeshGeometry;
74
75pub use lactea_abi as abi;