Expand description
wgpu backend reproducing the MilkDrop 2 frame pipeline; host-provided device, renders into any texture.
This crate is a port of MilkDrop 2’s CPlugin::RenderFrame (milkdropfs.cpp) and the texture /
noise setup of plugin.cpp. It knows nothing about presets, expressions, HLSL or audio: the
engine evaluates a preset’s equations, builds a FrameInput and calls
Renderer::render_frame.
Frame pipeline (all internal images Rgba8Unorm, never sRGB):
- motion vectors are drawn onto the previous image (MD2 order),
- warp pass
prev -> next(user warp shader, orWarpedBlit_NoShaders), - blur chain from the previous image, only up to the highest level a shader uses,
- custom shapes, custom waves, main wave, darken-center, borders on
next, - composite
next -> final(user comp shader on the 32x24 comp mesh, orShowToUser_NoShaders: video echo, gamma, brighten/darken/solarize/invert), - blit
finalto the host target (sRGB-compensated if needed).
With Compat::MilkDrop2 the engine may hand over Md2Blend data (FrameInput::md2_blend): MilkDrop 2’s own
preset blend, where steps 2, 4 and 5 run once or twice (old and new shader, alpha-tiled) on a blended warp mesh.
Where MilkDrop 2 and projectM differ, Compat picks the behaviour (default projectM).
§Features
diagnostics(off by default): reference-comparison hooks (image injection, extra read-backs).
Re-exports§
pub use warp_mesh::MeshGeometry;pub use lactea_abi as abi;
Modules§
- noise
- Port of MD2’s procedural noise textures (plugin.cpp
AddNoiseTex/AddNoiseVol,fCubicInterpolate,dwCubicInterpolate). - uniforms
- Filling of
MilkUniformsexactly likeCPlugin::ApplyShaderParams(milkdropfs.cpp), including its quirks, plus the preset-level random state (CState::RandomizePresetVars). - warp_
mesh - Warp-mesh geometry and MD2’s per-vertex UV formula (milkdropfs.cpp
CPlugin::ComputeGridAlphaValues, vertex setup in plugin.cppAllocateMilkDropDX9). - wavegen
- Geometry generation for the main waveform (
CPlugin::DrawWave) and custom-wave helpers (DrawCustomWaves,SmoothWave). Pure functions: no GPU.
Structs§
- Blur
Params - Blur-chain parameters (
var_pf_blur*). - Borders
- Outer/inner border:
var_pf_ob_*/var_pf_ib_*. - Compat
Rules - The individual behaviours selected by a
Compatvalue (see the table there for the projectM / MilkDrop 2 values of each). - Compiled
Shader - A warp or composite shader: WGSL module source (starting with
lactea_abi::WGSL_COMMON, entryfs_main) plus the resource interface the renderer binds in group 1. - Custom
Wave - One evaluated custom wave (
CWave).points.len()is thesamplesactually produced (<= 512). Spectrum /sep/ smoothing / scaling are the engine’s job (seecrate::wavegen::custom_wave_values). - Frame
Input - Per-frame values after per-frame equations.
- Main
Wave - Main waveform (
DrawWaveinputs). - Md2Blend
- Everything the renderer needs to draw a blend frame, on top of the new state’s
crate::FrameInput(whose per-frame values are already the blendedm_pState->var_pf_*). - Md2Old
Pass - What the old state contributes to the shader passes of a blend frame (its
ApplyShaderParams(.., m_pOldState)inputs that differ from the new state’s:q1..q32, blur range,rand_preset/rot_*). - Motion
Vectors - Motion vector field:
var_pf_mv_x/y/dx/dy/l/r/g/b/a. - Pass
Random - Per-shader-pass random state. projectM gives the warp and the composite shader independent
rand_preset/rand_frame/rot_*streams (MD2 shares one set per preset); the engine supplies them here. AnyNonefalls back to the renderer’s own state. - Post
Params - Decay, composite-pass controls.
- Render
Config - Renderer construction parameters.
- Renderer
- The MilkDrop 2 frame renderer. See the crate docs for the pass order.
- Rng
- The renderer’s deterministic generator (SplitMix64).
- Shape
Image - The texture of a shape’s
image=key, already split like projectM’sExtractTextureSettings(fw_/fc_/pw_/pc_prefixes pick filter and wrapping; no prefix = linear + repeat). - Shape
Instance - One evaluated custom-shape instance (
CShapeafter per-frame code for that instance). - Transition
Blender - The six transition pipelines and the bilinear / clamp sampler (
m_presetSampler). - Transition
Params - Per-frame inputs of a transition draw (
PresetTransition::Draw). - WarpGpu
- See
FrameInput::warp_gpu. - Wave
Point - One evaluated custom-wave point (
var_pp_x/y/r/g/b/aafter per-point code).x/yare the VM’sf64: projectM turns them into clip space asstatic_cast<float>((x * 2.0 - 1.0) * invAspectX), i.e. the product is also taken in double (MD2:(float)(x * 2 - 1) * invAspectX, seeCompatRules::wave_point_f64_aspect).
Enums§
- Compat
- Which reference behaviour the renderer follows where MilkDrop 2 (
third_party/md2) and projectM differ. Default: projectM. - Render
Error - Errors reported by the renderer.
- Stroke
Raster - How 1-pixel lines and points (custom/main waves, shape outlines, motion vectors) are rasterised.
- Transition
Kind - The six built-in transition shaders, in projectM’s
TransitionShaderManagerorder.
Functions§
- cosine_
interp CosineInterp(vis_milk2utility.h, not part ofthird_party/md2):0.5 - 0.5 cos(pi x). Used for the blend of the per-frame variables, the wave blend and the video-echo flip.