Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerson Coskey committed Dec 21, 2024
1 parent 7a11933 commit 0d87b2d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 38 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/atmosphere/functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ fn position_ndc_to_world(ndc_pos: vec3<f32>) -> vec3<f32> {
}

/// Converts a direction in world space to atmosphere space
fn direction_world_to_atmosphere(atmo_dir: vec3<f32>) -> vec3<f32> {
let world_dir = atmosphere_transforms.atmosphere_from_world * vec4(atmo_dir, 0.0);
fn direction_world_to_atmosphere(world_dir: vec3<f32>) -> vec3<f32> {
let world_dir = atmosphere_transforms.atmosphere_from_world * vec4(world_dir, 0.0);
return world_dir.xyz;
}

Expand Down
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/atmosphere/render_sky.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ fn main(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {

let sun_illuminance = sample_sun_illuminance(ray_dir_ws.xyz, transmittance);
return vec4(inscattering + sun_illuminance, (transmittance.r + transmittance.g + transmittance.b) / 3.0);
//return vec4(ray_dir_ws);
} else {
let ndc_xy = uv_to_ndc(in.uv);
let ndc = vec3(ndc_xy, depth);
Expand Down
38 changes: 3 additions & 35 deletions examples/3d/atmosphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use light_consts::lux;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(
Startup,
(setup_camera_fog, setup_terrain_scene, setup_instructions),
)
.add_systems(Startup, (setup_camera_fog, setup_terrain_scene))
.add_systems(Update, rotate_sun)
.add_systems(Update, translate_camera)
.run();
Expand Down Expand Up @@ -72,40 +69,11 @@ fn setup_terrain_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
)));
}

//TODO: update this
fn setup_instructions(mut commands: Commands) {
// commands.spawn(
// TextBundle::from_section(
// "Press Spacebar to Toggle Atmospheric Fog.\nPress S to Toggle Directional Light Fog Influence.",
// TextStyle::default(),
// )
// .with_style(Style {
// position_type: PositionType::Absolute,
// bottom: Val::Px(12.0),
// left: Val::Px(12.0),
// ..default()
// }),
// );
}

// fn toggle_system(keycode: Res<ButtonInput<KeyCode>>, mut fog: Query<&mut FogSettings>) {
// let mut fog_settings = fog.single_mut();
//
// if keycode.just_pressed(KeyCode::Space) {
// let a = fog_settings.color.alpha();
// fog_settings.color.set_alpha(1.0 - a);
// }
//
// if keycode.just_pressed(KeyCode::KeyS) {
// let a = fog_settings.directional_light_color.alpha();
// fog_settings.directional_light_color.set_alpha(0.5 - a);
// }
// }

fn rotate_sun(mut sun: Single<&mut Transform, With<DirectionalLight>>, time: Res<Time>) {
sun.rotate_z(time.delta_secs() * PI / 30.0);
}

fn translate_camera(mut camera: Single<&mut Transform, With<Camera>>, time: Res<Time>) {
camera.translation.y += time.delta_secs() * 0.05;
//camera.translation.y += time.delta_secs() * 0.05;
camera.rotate_y(time.delta_secs() * 0.1);
}

0 comments on commit 0d87b2d

Please sign in to comment.