Path: blob/main/crates/bevy_solari/src/pathtracer/prepare.rs
6596 views
use super::Pathtracer;1use bevy_ecs::{2component::Component,3entity::Entity,4query::With,5system::{Commands, Query, Res, ResMut},6};7use bevy_image::ToExtents;8use bevy_render::{9camera::ExtractedCamera,10render_resource::{TextureDescriptor, TextureDimension, TextureFormat, TextureUsages},11renderer::RenderDevice,12texture::{CachedTexture, TextureCache},13};1415#[derive(Component)]16pub struct PathtracerAccumulationTexture(pub CachedTexture);1718pub fn prepare_pathtracer_accumulation_texture(19query: Query<(Entity, &ExtractedCamera), With<Pathtracer>>,20mut texture_cache: ResMut<TextureCache>,21render_device: Res<RenderDevice>,22mut commands: Commands,23) {24for (entity, camera) in &query {25let Some(viewport) = camera.physical_viewport_size else {26continue;27};2829let descriptor = TextureDescriptor {30label: Some("pathtracer_accumulation_texture"),31size: viewport.to_extents(),32mip_level_count: 1,33sample_count: 1,34dimension: TextureDimension::D2,35format: TextureFormat::Rgba32Float,36usage: TextureUsages::STORAGE_BINDING,37view_formats: &[],38};3940commands41.entity(entity)42.insert(PathtracerAccumulationTexture(43texture_cache.get(&render_device, descriptor),44));45}46}474849