#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct GpuParticle {
pub position: [f32; 3],
pub life: f32,
pub velocity: [f32; 3],
pub max_life: f32,
pub color: [f32; 4],
pub size_start: f32,
pub size_end: f32,
pub _padding: [f32; 2],
}
impl GpuParticle {
pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<GpuParticle>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Instance,
attributes: &[
wgpu::VertexAttribute {
offset: 0,
shader_location: 0,
format: wgpu::VertexFormat::Float32x4,
}, wgpu::VertexAttribute {
offset: 16,
shader_location: 1,
format: wgpu::VertexFormat::Float32x4,
}, wgpu::VertexAttribute {
offset: 32,
shader_location: 2,
format: wgpu::VertexFormat::Float32x4,
}, wgpu::VertexAttribute {
offset: 48,
shader_location: 3,
format: wgpu::VertexFormat::Float32x4,
}, ],
}
}
}
#[repr(C)]
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
pub struct ParticleSimParams {
pub dt: f32,
pub global_gravity: f32,
pub global_drag: f32,
pub _padding: f32,
}