#[derive(Copy, Clone, bytemuck::NoUninit)]
#[repr(C)]
pub struct TransparentView {
pub vp: [[f32; 4]; 4],
pub inv_vp: [[f32; 4]; 4],
pub camera_pos: [f32; 4],
pub viewport: [f32; 2],
pub time: f32,
pub prefilter_mip_count: f32,
}
#[derive(Copy, Clone, bytemuck::NoUninit)]
#[repr(C)]
pub struct GlassParams {
pub centre: [f32; 4],
pub normal: [f32; 4],
pub tint: [f32; 4],
pub opacity: f32,
pub refraction_strength: f32,
pub fresnel_power: f32,
pub planar: f32,
}
#[derive(Copy, Clone, bytemuck::NoUninit)]
#[repr(C)]
pub struct GlassMeshParams {
pub model: [[f32; 4]; 4],
pub tint: [f32; 4],
pub opacity: f32,
pub refraction_strength: f32,
pub fresnel_power: f32,
pub prefilter_mip_count: f32,
}
pub const WATER_MAX_WAVES: usize = 4;
#[derive(Copy, Clone, Default, bytemuck::Zeroable, bytemuck::Pod)]
#[repr(C)]
pub struct WaterWaveGpu {
pub dir_amp_wave: [f32; 4],
pub speed_steep_pad: [f32; 4],
}
#[derive(Copy, Clone, bytemuck::NoUninit)]
#[repr(C)]
pub struct WaterParams {
pub centre: [f32; 4],
pub deep_colour: [f32; 4],
pub shallow_colour: [f32; 4],
pub depth_falloff: f32,
pub foam_width: f32,
pub foam_intensity: f32,
pub fresnel_power: f32,
pub roughness: f32,
pub refraction_strength: f32,
pub wave_count: u32,
pub _pad: f32,
pub waves: [WaterWaveGpu; WATER_MAX_WAVES],
pub planar: [f32; 4],
}
#[cfg(test)]
mod tests {
use super::*;
use core::mem::{offset_of, size_of};
#[test]
fn glass_mesh_params_layout_matches_shader() {
assert_eq!(size_of::<GlassMeshParams>(), 96);
assert_eq!(offset_of!(GlassMeshParams, model), 0);
assert_eq!(offset_of!(GlassMeshParams, tint), 64);
assert_eq!(offset_of!(GlassMeshParams, opacity), 80);
assert_eq!(offset_of!(GlassMeshParams, refraction_strength), 84);
assert_eq!(offset_of!(GlassMeshParams, fresnel_power), 88);
assert_eq!(offset_of!(GlassMeshParams, prefilter_mip_count), 92);
assert_eq!(size_of::<GlassMeshParams>() % 16, 0);
}
#[test]
fn water_params_layout_matches_shader() {
assert_eq!(size_of::<WaterParams>(), 224);
assert_eq!(offset_of!(WaterParams, centre), 0);
assert_eq!(offset_of!(WaterParams, deep_colour), 16);
assert_eq!(offset_of!(WaterParams, shallow_colour), 32);
assert_eq!(offset_of!(WaterParams, depth_falloff), 48);
assert_eq!(offset_of!(WaterParams, foam_width), 52);
assert_eq!(offset_of!(WaterParams, foam_intensity), 56);
assert_eq!(offset_of!(WaterParams, fresnel_power), 60);
assert_eq!(offset_of!(WaterParams, roughness), 64);
assert_eq!(offset_of!(WaterParams, refraction_strength), 68);
assert_eq!(offset_of!(WaterParams, wave_count), 72);
assert_eq!(offset_of!(WaterParams, _pad), 76);
assert_eq!(offset_of!(WaterParams, waves), 80);
assert_eq!(offset_of!(WaterParams, planar), 208);
assert_eq!(size_of::<WaterWaveGpu>(), 32);
}
}