WIP better star brightnesses

This commit is contained in:
yuni 2024-03-21 02:11:07 +01:00
parent 573d27bb6e
commit 6d98a0e459
5 changed files with 15617 additions and 15571 deletions

View file

@ -3,7 +3,7 @@ actor 300000 0 500000 jupiter
rotationy -1.40 rotationy -1.40
angularmomentum 0 0.0001 0 angularmomentum 0 0.0001 0
actor 2000 0 0 asteroid1 actor 2000 2000 0 asteroid1
scale 200 scale 200
actor -2300 10 0 pizzeria actor -2300 10 0 pizzeria
@ -23,10 +23,6 @@ actor -2265 10 0 suit
alive yes alive yes
pronoun it pronoun it
chat error
name ERROR
msg 0 INIT EXIT "Unspecified conversation ID"
chat hi_icarus chat hi_icarus
name Icarus name Icarus
msg 2 INIT hi "Requesting permission to communicate..." msg 2 INIT hi "Requesting permission to communicate..."
@ -43,6 +39,7 @@ chat hi_icarus
msg 2.5 pizza end "Make sure to check out the Pizza place." msg 2.5 pizza end "Make sure to check out the Pizza place."
choice 3 end end1 "Will do, bye!" choice 3 end end1 "Will do, bye!"
msg 0 end1 EXIT "Disconnected." msg 0 end1 EXIT "Disconnected."
lvl info
msg 0 end EXIT "Disconnected." msg 0 end EXIT "Disconnected."
lvl info lvl info
@ -57,3 +54,7 @@ chat pizzeria
msg 10 anyone end "Hello? Is anyone there? Is this a prank?" msg 10 anyone end "Hello? Is anyone there? Is this a prank?"
msg 0 end EXIT "Disconnected." msg 0 end EXIT "Disconnected."
lvl info lvl info
chat error
name ERROR
msg 0 INIT EXIT "Unspecified conversation ID"

File diff suppressed because it is too large Load diff

View file

@ -37,8 +37,8 @@ pub struct Settings {
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Settings { Settings {
mute_sfx: false, mute_sfx: true,
mute_music: false, mute_music: true,
volume_sfx: 100, volume_sfx: 100,
volume_music: 100, volume_music: 100,
font_size_hud: 32.0, font_size_hud: 32.0,

View file

@ -145,14 +145,51 @@ pub fn setup(
// Generate starmap // Generate starmap
let sphere_handle = meshes.add(Sphere::new(1.0)); let sphere_handle = meshes.add(Sphere::new(1.0));
for star in nature::STARS { for star in nature::STARS {
let brightness = star[3] * 2000.0; //let clr = {|c: f32| c * 0.01 * (brightness * 50.0).powf(1.2).clamp(0.1, 100000.0) };
//let clr = {|c: f32| c * 0.15 };
//let clr = {|c: f32| c * 1.78136 * c.ln() + 5.03726 };
//let clr = {|c: f32| c * 1.9293*c.powf(0.1382) };
//let clr = {|c: f32| c * 0.0431866*brightness*brightness - 0.688256*brightness + 2.90952 };
//let clr = {|c: f32| c * 0.0275015*mag*mag - 0.59251*mag + 2.93566 };
//let size = {|mag: f32| 10.0 * 8.0*mag*mag - 100.0*mag + 400.0 };
//let size = {|mag: f32| 10.0 * 8.0*mag*mag - 100.0*mag + 400.0 };
let mag = star[3];
let clr = {|color: f32|
if mag < -20.0 {
color * 13.0 // Sun
} else if mag < 0.0 {
color * 5.0
} else if mag < 0.5 {
color * 4.2
} else if mag < 1.5 {
color * 3.5
} else if mag < 2.5 {
color * 2.0
} else if mag < 3.5 {
color * 1.0
} else {
color * 0.15
}
};
let size = {|mag: f32|
if mag < -20.0 {
40000.0f32 // Sun
} else if mag < 0.0 {
20000.0f32
} else if mag < 2.0 {
10000.0f32
} else {
5000.0f32
}
};
let (r, g, b) = nature::star_color_index_to_rgb(star[4]); let (r, g, b) = nature::star_color_index_to_rgb(star[4]);
let star_color_handle = materials.add(StandardMaterial { let star_color_handle = materials.add(StandardMaterial {
base_color: Color::rgb(r, g, b), base_color: Color::rgb(clr(r), clr(g), clr(b)),
emissive: Color::rgb_linear(r*brightness, g*brightness, b*brightness), //emissive: Color::rgb_linear(r*brightness, g*brightness, b*brightness),
unlit: true,
..default() ..default()
}); });
let dist = 1e6; let dist = 1e7;
commands.spawn(( commands.spawn((
Star, Star,
PbrBundle { PbrBundle {
@ -163,7 +200,7 @@ pub fn setup(
dist * star[1], dist * star[1],
dist * star[2], dist * star[2],
) )
.with_scale(Vec3::splat((1000.0*star[3]).clamp(500.0, 2000.0))), .with_scale(Vec3::splat(size(mag))),
..default() ..default()
} }
)); ));

View file

@ -28,10 +28,11 @@ import math
# Meissa (orion's head, 8th brightest star in orion) = 3.33 # Meissa (orion's head, 8th brightest star in orion) = 3.33
MAX_APPARENT_MAGNITUDE = 7.0 MAX_APPARENT_MAGNITUDE = 7.0
print("// The \"STARS\" was autogenerated by \"genrate_starchart.py\" using data") print("// The \"STARS\" constant was autogenerated by \"genrate_starchart.py\" using data")
print("// from the HYG database: https://github.com/astronexus/HYG-Database/tree/main/hyg") print("// from the HYG database: https://github.com/astronexus/HYG-Database/tree/main/hyg")
print("// License: CC BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/") print("// License: CC BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/")
print("") print("")
print("// Each star's values: [x, y, z, magnitude, color index]")
print("pub const STARS: &[[f32; 5]] = &[") print("pub const STARS: &[[f32; 5]] = &[")
@ -56,14 +57,20 @@ def render(ra, dec, mag, ci, proper):
brightness = 2.512 ** (0 - mag) brightness = 2.512 ** (0 - mag)
print(f" [{x:.04}, {y:.04}, {z:.04}, {brightness:.04}, {ci}],{comment}") print(f" [{x:.04}, {y:.04}, {z:.04}, {mag:.04}, {ci}],{comment}")
total = 0 total = 0
count = 0 count = 0
count_extra = 0 count_extra = 0
entries = []
with open("assets/tmp/hygdata_v41.csv", "r", encoding="utf-8") as f: with open("assets/tmp/hygdata_v41.csv", "r", encoding="utf-8") as f:
for entry in csv.DictReader(f): for entry in csv.DictReader(f):
entries.append(entry)
entries.sort(key=lambda entry: float(entry['mag']))
for entry in entries:
total += 1 total += 1
ra = entry['ra'] ra = entry['ra']
dec = entry['dec'] dec = entry['dec']