add ring types to shader, remove shadow from ring for uranus/neptune
This commit is contained in:
parent
2310fdf83d
commit
c4d78c1116
|
@ -5,9 +5,14 @@
|
|||
|
||||
@group(2) @binding(0) var<uniform> ring_radius: f32;
|
||||
@group(2) @binding(1) var<uniform> jupiter_radius: f32;
|
||||
@group(2) @binding(2) var<uniform> ringtype: i32;
|
||||
|
||||
const jupiter_radius_Mm: f32 = 69.911;
|
||||
const brightness = 0.025;
|
||||
const ring_jupiter = 1;
|
||||
const ring_saturn = 2;
|
||||
const ring_uranus = 3;
|
||||
const ring_neptune = 4;
|
||||
|
||||
fn smooth_edge(start: f32, end: f32, value: f32) -> f32 {
|
||||
var x: f32 = (value - start) / (end - start);
|
||||
|
@ -79,7 +84,8 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
|||
return vec4<f32>(color, 0.0);
|
||||
}
|
||||
|
||||
if in.uv[0] < 0.5 {
|
||||
// apply shadow
|
||||
if ringtype <= ring_saturn && in.uv[0] < 0.5 {
|
||||
let dist = (0.5 - in.uv[0]) * 2.0; // 0.0=jupiter's center, 1.0=edge of the ring
|
||||
let side_dist = abs(in.uv[1] - 0.5);
|
||||
|
||||
|
|
25
src/cmd.rs
25
src/cmd.rs
|
@ -22,6 +22,11 @@ pub const ID_PLAYER: &str = "player";
|
|||
pub const ID_EARTH: &str = "earth";
|
||||
pub const ID_SOL: &str = "sol";
|
||||
pub const ID_JUPITER: &str = "jupiter";
|
||||
pub const RING_NONE: i32 = 0;
|
||||
pub const RING_JUPITER: i32 = 1;
|
||||
pub const RING_SATURN: i32 = 2;
|
||||
pub const RING_URANUS: i32 = 3;
|
||||
pub const RING_NEPTUNE: i32 = 4;
|
||||
|
||||
pub struct CmdPlugin;
|
||||
impl Plugin for CmdPlugin {
|
||||
|
@ -110,7 +115,7 @@ struct ParserState {
|
|||
orbit_object_id: Option<String>,
|
||||
orbit_phase: Option<f64>,
|
||||
has_physics: bool,
|
||||
has_ring: bool,
|
||||
has_ring: i32,
|
||||
has_aurora: bool,
|
||||
wants_maxrotation: Option<f64>,
|
||||
wants_maxvelocity: Option<f64>,
|
||||
|
@ -178,7 +183,7 @@ impl Default for ParserState {
|
|||
orbit_object_id: None,
|
||||
orbit_phase: None,
|
||||
has_physics: true,
|
||||
has_ring: false,
|
||||
has_ring: 0,
|
||||
has_aurora: false,
|
||||
wants_maxrotation: None,
|
||||
wants_maxvelocity: None,
|
||||
|
@ -484,8 +489,17 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
|
|||
["sun", "yes"] => {
|
||||
state.is_sun = true;
|
||||
}
|
||||
["ring", "yes"] => {
|
||||
state.has_ring = true;
|
||||
["ring", "jupiter"] => {
|
||||
state.has_ring = RING_JUPITER;
|
||||
}
|
||||
["ring", "saturn"] => {
|
||||
state.has_ring = RING_SATURN;
|
||||
}
|
||||
["ring", "uranus"] => {
|
||||
state.has_ring = RING_URANUS;
|
||||
}
|
||||
["ring", "neptune"] => {
|
||||
state.has_ring = RING_NEPTUNE;
|
||||
}
|
||||
["aurora", "yes"] => {
|
||||
state.has_aurora = true;
|
||||
|
@ -1692,7 +1706,7 @@ fn spawn_entities(
|
|||
load_asset(model, &mut entitycmd, &*asset_server);
|
||||
}
|
||||
|
||||
if state.has_ring {
|
||||
if state.has_ring > 0 {
|
||||
let ring_radius =
|
||||
state.model_scale * (nature::JUPITER_RING_RADIUS / nature::JUPITER_RADIUS) as f32;
|
||||
commands.spawn((
|
||||
|
@ -1703,6 +1717,7 @@ fn spawn_entities(
|
|||
alpha_mode: AlphaMode::Blend,
|
||||
ring_radius: nature::JUPITER_RING_RADIUS as f32,
|
||||
jupiter_radius: nature::JUPITER_RADIUS as f32,
|
||||
ringtype: state.has_ring,
|
||||
}),
|
||||
transform: Transform::from_translation(absolute_pos.as_vec3()),
|
||||
..default()
|
||||
|
|
|
@ -90,7 +90,7 @@ actor 0 0 0
|
|||
displayed_mass_kg 1.8982e27
|
||||
planet yes
|
||||
sphere yes
|
||||
ring yes
|
||||
ring jupiter
|
||||
aurora yes
|
||||
atmosphere jupiter
|
||||
physics off
|
||||
|
@ -262,7 +262,7 @@ actor 0 0 0
|
|||
name Saturn
|
||||
planet yes
|
||||
sphere yes
|
||||
ring yes
|
||||
ring saturn
|
||||
aurora yes
|
||||
physics off
|
||||
scale 58232e3
|
||||
|
@ -278,7 +278,7 @@ actor 0 0 0
|
|||
name Uranus
|
||||
planet yes
|
||||
sphere yes
|
||||
ring yes
|
||||
ring uranus
|
||||
physics off
|
||||
scale 25362e3
|
||||
displayed_mass_kg 8.6810e25
|
||||
|
@ -293,7 +293,7 @@ actor 0 0 0
|
|||
name Neptune
|
||||
planet yes
|
||||
sphere yes
|
||||
ring yes
|
||||
ring neptune
|
||||
physics off
|
||||
scale 24622e3
|
||||
displayed_mass_kg 1.02409e26
|
||||
|
|
|
@ -102,6 +102,8 @@ pub struct JupitersRing {
|
|||
pub ring_radius: f32,
|
||||
#[uniform(1)]
|
||||
pub jupiter_radius: f32,
|
||||
#[uniform(2)]
|
||||
pub ringtype: i32,
|
||||
}
|
||||
|
||||
impl Material for JupitersRing {
|
||||
|
|
Loading…
Reference in a new issue