ShaderUniforms

Struct ShaderUniforms 

Source
#[repr(C)]
pub struct ShaderUniforms {
Show 34 fields pub time: f32, pub fps: f32, pub frame: f32, pub progress: f32, pub bass: f32, pub mid: f32, pub treb: f32, pub vol: f32, pub bass_att: f32, pub mid_att: f32, pub treb_att: f32, pub vol_att: f32, pub blur1_min: f32, pub blur1_max: f32, pub blur2_min: f32, pub blur2_max: f32, pub blur3_min: f32, pub blur3_max: f32, pub gamma_adj: f32, pub _reserved1: f32, pub echo_zoom: f32, pub echo_alpha: f32, pub echo_orient: f32, pub red_blue_stereo: f32, pub aspect: [f32; 4], pub texsize: [f32; 4], pub rand_preset: [f32; 4], pub rand_frame: [f32; 4], pub slow_roam_cos: [f32; 4], pub slow_roam_sin: [f32; 4], pub roam_cos: [f32; 4], pub roam_sin: [f32; 4], pub hue_shader: [f32; 4], pub q: [[f32; 4]; 8],
}
Expand description

Rust mirror of the WGSL ShaderUniforms struct.

Field order, alignment, and padding must exactly match SHADER_UNIFORMS_WGSL; the tests module in this file enforces this with a byte-for-byte naga round-trip.

Fields§

§time: f32

Wall-clock time in seconds since preset load.

§fps: f32

Smoothed FPS estimate.

§frame: f32

Frame counter (cast from u32).

§progress: f32

Position within the preset’s display window, [0, 1]. 0 at load, 1 just before the next hard cut.

§bass: f32

Bass band level (raw, ~0 baseline, can spike >1 on beats).

§mid: f32

Mid band level.

§treb: f32

Treble band level.

§vol: f32

(bass + mid + treb) / 3.

§bass_att: f32

Smoothed (attenuated) bass level — exponential moving average.

§mid_att: f32§treb_att: f32§vol_att: f32§blur1_min: f32

bN_min / bN_max are remap bounds — the comp shader applies lerp(min, max, sample) to recover usable contrast from the downsampled blur pyramid.

§blur1_max: f32§blur2_min: f32§blur2_max: f32§blur3_min: f32§blur3_max: f32§gamma_adj: f32

MilkDrop’s f_gamma_adj. Display-only multiplier (not a true gamma); applied in the comp pass after any user shader work.

§_reserved1: f32

Reserved for a future scalar; keeps the slot count a multiple of 4.

§echo_zoom: f32

MilkDrop’s f_video_echo_zoom. Comp pass samples the previous frame’s display at (uv-0.5)*echo_zoom + 0.5 and blends it with the current warp output. 0.0 disables the echo branch entirely (treated as echo_alpha = 0).

§echo_alpha: f32

MilkDrop’s f_video_echo_alpha. Mix weight: 0.0 = no echo, full current frame; 1.0 = pure echo from the previous frame.

§echo_orient: f32

MilkDrop’s n_video_echo_orientation. 0 = no flip, 1 = flip X, 2 = flip Y, 3 = flip both. Stored as f32 to avoid mixed scalar types in the uniform layout; the comp shader casts to an integer at use site.

§red_blue_stereo: f32

MilkDrop’s b_red_blue_stereo. 1.0 = anaglyph mode active, 0.0 = off. Wired through to comp.wgsl.

§aspect: [f32; 4]

(aspect_x, aspect_y, 1/aspect_x, 1/aspect_y). MD2 historically supplies all four to spare the shader an extra division.

§texsize: [f32; 4]

(width, height, 1/width, 1/height) of the warp/comp render target — the texture user shaders sample as sampler_main.

§rand_preset: [f32; 4]

Four [0, 1) floats sampled once at preset load. MD2’s rand_preset.

§rand_frame: [f32; 4]

Four [0, 1) floats resampled every frame.

§slow_roam_cos: [f32; 4]

Pre-computed cos of the four MD2 “slow roam” oscillators.

§slow_roam_sin: [f32; 4]

Pre-computed sin of the same.

§roam_cos: [f32; 4]

Faster-cycling roam oscillators.

§roam_sin: [f32; 4]§hue_shader: [f32; 4]

MD2’s per-frame RGB tint (.xyz). Many comp shaders multiply ret * hue_shader for a slow rainbow rotation across frames; without this populated, the multiplication degrades to identity (vec3(1, 1, 1)) and the rotation disappears. The engine computes a time-driven tri-phase oscillator each frame; the .w lane is reserved for a future per-corner mix factor.

§q: [[f32; 4]; 8]

q[0] packs q1..q4, q[1] packs q5..q8, etc. Filled from MilkEngine::q_snapshot().

Implementations§

Source§

impl ShaderUniforms

Source

pub const SIZE: usize = 368usize

Size of the uniform buffer in bytes. Useful when allocating GPU buffers without taking size_of::<Self>() at the call site.

Source

pub fn set_q_channels(&mut self, q: &[f32; 32])

Pack q1..q32 into the eight-vec4 layout the WGSL struct expects.

Trait Implementations§

Source§

impl Clone for ShaderUniforms

Source§

fn clone(&self) -> ShaderUniforms

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShaderUniforms

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShaderUniforms

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Zeroable for ShaderUniforms

§

fn zeroed() -> Self

Source§

impl Copy for ShaderUniforms

Source§

impl Pod for ShaderUniforms

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> AnyBitPattern for T
where T: Pod,

§

impl<T> NoUninit for T
where T: Pod,