particles

This commit is contained in:
Jonas H
2026-04-02 16:54:23 +02:00
parent 909ae8612a
commit dffd731b87
17 changed files with 739 additions and 45 deletions

View File

@@ -7,6 +7,8 @@ mod types;
pub mod billboard;
pub mod font_atlas;
pub mod particle_pipeline;
pub mod particle_types;
pub mod snow;
pub mod snow_light;
pub mod text_pipeline;
@@ -18,6 +20,8 @@ pub use global::{
set_terrain_data, update_spotlights, with_device, with_font_atlas, with_queue,
with_surface_format,
};
pub use particle_pipeline::ParticlePipeline;
pub use particle_types::ParticleInstanceRaw;
pub use text_pipeline::TextVertex;
pub use types::{DrawCall, Pipeline, Spotlight, SpotlightRaw, Uniforms, MAX_SPOTLIGHTS};
@@ -51,6 +55,7 @@ pub struct Renderer
debug_lines_pipeline: Option<wgpu::RenderPipeline>,
debug_overlay: Option<debug_overlay::DebugOverlay>,
billboard_pipeline: BillboardPipeline,
particle_pipeline: ParticlePipeline,
font_atlas: font_atlas::FontAtlas,
text_pipeline: text_pipeline::TextPipeline,
wireframe_supported: bool,
@@ -527,6 +532,7 @@ impl Renderer
));
let billboard_pipeline = BillboardPipeline::new(&device, config.format);
let particle_pipeline = ParticlePipeline::new(&device, config.format);
let font_atlas = font_atlas::FontAtlas::load(&device, &queue);
let text_pipeline = text_pipeline::TextPipeline::new(&device, config.format, &font_atlas);
@@ -560,6 +566,7 @@ impl Renderer
debug_lines_pipeline,
debug_overlay,
billboard_pipeline,
particle_pipeline,
font_atlas,
text_pipeline,
wireframe_supported,
@@ -607,6 +614,7 @@ impl Renderer
draw_calls: &[DrawCall],
billboard_calls: &[BillboardDrawCall],
text_vertices: &[text_pipeline::TextVertex],
particle_instances: &[ParticleInstanceRaw],
time: f32,
delta_time: f32,
debug_mode: DebugMode,
@@ -1068,16 +1076,29 @@ impl Renderer
billboard_calls,
);
let view_proj = (*projection * *view).to_cols_array_2d();
let view_proj_mat = *projection * *view;
self.text_pipeline.render(
&mut overlay_encoder,
&self.queue,
&screen_view,
&self.fullres_depth_view,
text_vertices,
view_proj,
view_proj_mat.to_cols_array_2d(),
);
if !particle_instances.is_empty()
{
self.particle_pipeline.render(
&mut overlay_encoder,
&self.queue,
&screen_view,
&self.fullres_depth_view,
particle_instances,
view_proj_mat,
*view,
);
}
self.queue.submit(std::iter::once(overlay_encoder.finish()));
frame
}