#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub struct CameraAttribs {
pub f4_position: [f32; 4],
pub f4_viewport_size: [f32; 4],
pub f_near_plane_z: f32,
pub f_far_plane_z: f32,
pub f_near_plane_depth: f32,
pub f_far_plane_depth: f32,
pub f_scene_near_z: f32,
pub f_scene_far_z: f32,
pub f_scene_near_depth: f32,
pub f_scene_far_depth: f32,
pub f_handness: f32,
pub ui_frame_index: u32,
pub padding0: f32,
pub padding1: f32,
pub f_focus_distance: f32,
pub f_f_stop: f32,
pub f_focal_length: f32,
pub f_sensor_width: f32,
pub f_sensor_height: f32,
pub f_exposure: f32,
pub f2_jitter: [f32; 2],
pub m_view: [f32; 16],
pub m_proj: [f32; 16],
pub m_view_proj: [f32; 16],
pub m_view_inv: [f32; 16],
pub m_proj_inv: [f32; 16],
pub m_view_proj_inv: [f32; 16],
pub f4_extra_data: [[f32; 4]; 5],
}
impl Default for CameraAttribs {
fn default() -> Self {
Self {
f_focus_distance: 10.0,
f_f_stop: 5.6,
f_focal_length: 50.0,
f_sensor_width: 36.0,
f_sensor_height: 24.0,
f_exposure: 0.0,
..bytemuck::Zeroable::zeroed()
}
}
}
impl CameraAttribs {
pub fn set_clip_planes(&mut self, f_near_z: f32, f_far_z: f32) {
let use_reverse_depth = f_near_z > f_far_z;
self.f_near_plane_z = if use_reverse_depth { f_far_z } else { f_near_z };
self.f_far_plane_z = if use_reverse_depth { f_near_z } else { f_far_z };
self.f_near_plane_depth = if use_reverse_depth { 1.0 } else { 0.0 };
self.f_far_plane_depth = if use_reverse_depth { 0.0 } else { 1.0 };
self.f_scene_near_z = self.f_near_plane_z;
self.f_scene_far_z = self.f_far_plane_z;
self.f_scene_near_depth = self.f_near_plane_depth;
self.f_scene_far_depth = self.f_far_plane_depth;
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub struct ScreenSpaceReflectionAttribs {
pub depth_buffer_thickness: f32,
pub roughness_threshold: f32,
pub most_detailed_mip: u32,
pub is_roughness_perceptual: i32,
pub roughness_channel: u32,
pub max_traversal_intersections: u32,
pub ggx_importance_sample_bias: f32,
pub spatial_reconstruction_radius: f32,
pub temporal_radiance_stability_factor: f32,
pub temporal_variance_stability_factor: f32,
pub bilateral_cleanup_spatial_sigma_factor: f32,
pub alpha_interpolation: f32,
}
impl Default for ScreenSpaceReflectionAttribs {
fn default() -> Self {
Self {
depth_buffer_thickness: 0.025,
roughness_threshold: 0.2,
most_detailed_mip: 0,
is_roughness_perceptual: 1,
roughness_channel: 0,
max_traversal_intersections: 128,
ggx_importance_sample_bias: 0.3,
spatial_reconstruction_radius: 4.0,
temporal_radiance_stability_factor: 0.95,
temporal_variance_stability_factor: 0.9,
bilateral_cleanup_spatial_sigma_factor: 0.9,
alpha_interpolation: 1.0,
}
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub struct TemporalAntiAliasingAttribs {
pub temporal_stability_factor: f32,
pub reset_accumulation: u32,
pub skip_rejection: u32,
pub rigid_object_motion: u32,
pub camera_motion: u32,
pub padding0: u32,
pub padding1: u32,
pub padding2: u32,
}
impl Default for TemporalAntiAliasingAttribs {
fn default() -> Self {
Self {
temporal_stability_factor: 0.9375,
reset_accumulation: 0,
skip_rejection: 0,
rigid_object_motion: 0,
camera_motion: 0,
padding0: 0,
padding1: 0,
padding2: 0,
}
}
}
const _: () = assert!(size_of::<CameraAttribs>().is_multiple_of(16));
const _: () = assert!(size_of::<ScreenSpaceReflectionAttribs>().is_multiple_of(16));
const _: () = assert!(size_of::<TemporalAntiAliasingAttribs>().is_multiple_of(16));