From 571f886782f3266840d546bd939257ae290affa4 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 17 Mar 2024 14:16:25 +0100 Subject: [PATCH] add the SUN --- src/world.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/world.rs b/src/world.rs index 6b8a215..166f051 100644 --- a/src/world.rs +++ b/src/world.rs @@ -4,6 +4,10 @@ use bevy::core_pipeline::Skybox; use bevy::asset::LoadState; use bevy::render::render_resource::{TextureViewDescriptor, TextureViewDimension}; use bevy::pbr::CascadeShadowConfigBuilder; +use bevy::core_pipeline::{ + bloom::{BloomCompositeMode, BloomSettings}, + tonemapping::Tonemapping, +}; use std::f32::consts::PI; #[derive(Resource)] @@ -25,6 +29,10 @@ pub fn setup( let skybox_handle = asset_server.load(CUBEMAP_PATH); commands.spawn(( Camera3dBundle { + camera: Camera { + hdr: true, // HDR is required for bloom + ..default() + }, transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() }, @@ -33,6 +41,10 @@ pub fn setup( image: skybox_handle.clone(), brightness: 500.0, }, + BloomSettings { + composite_mode: BloomCompositeMode::Additive, + ..default() + }, )); commands.insert_resource(Cubemap { is_loaded: false, @@ -52,7 +64,6 @@ pub fn setup( perceptual_roughness: 1.0, ..default() }); - commands.spawn(PbrBundle { mesh: sphere_handle.clone(), material: gray_handle.clone(), @@ -77,6 +88,26 @@ pub fn setup( ..default() }); + // Add THE SUN + let hydrogenfusion_handle = materials.add(StandardMaterial { + base_color: Color::WHITE, + emissive: Color::rgb_linear(2300.0, 900.0, 300.0), + perceptual_roughness: 0.0, + ..default() + }); + let sphere_radius = 5000.0; + let sphere_handle = meshes.add(Sphere::new(sphere_radius)); + commands.spawn(PbrBundle { + mesh: sphere_handle.clone(), + material: hydrogenfusion_handle.clone(), + transform: Transform::from_xyz( + 0.0, + 30000.0, + -400000.0, + ), + ..default() + }); + // Add alien commands.spawn(SceneBundle { transform: Transform {