even nicer rings
This commit is contained in:
parent
394390a4d6
commit
3c7077f448
|
@ -140,6 +140,53 @@ fn ring_density(radius: f32) -> f32 {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn smooth_edge2(start: f32, end: f32, value: f32) -> f32 {
|
||||||
|
var x: f32 = (value - start) / (end - start);
|
||||||
|
return 4 * x * x * (1 - x * x);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ring_density2(radius: f32) -> f32 {
|
||||||
|
let halo_inner: f32 = 92.0;
|
||||||
|
let halo_outer: f32 = 122.5;
|
||||||
|
let main_inner: f32 = 122.5;
|
||||||
|
let main_outer: f32 = 129.0;
|
||||||
|
let amalthea_inner: f32 = 129.0;
|
||||||
|
let amalthea_outer: f32 = 182.0;
|
||||||
|
let thebe_inner: f32 = 129.0;
|
||||||
|
let thebe_outer: f32 = 229.0;
|
||||||
|
let metis_notch_center: f32 = 128.0;
|
||||||
|
let metis_notch_width: f32 = 0.6;
|
||||||
|
|
||||||
|
let halo_brightness: f32 = 0.3;
|
||||||
|
let main_brightness: f32 = 1.0;
|
||||||
|
let almathea_brightness: f32 = 0.2;
|
||||||
|
let thebe_brightness: f32 = 0.2;
|
||||||
|
|
||||||
|
let inner_smooth_factor: f32 = 2.0; // Smooth inner edges
|
||||||
|
let outer_smooth_factor: f32 = 1.5; // Rougher outer edges
|
||||||
|
|
||||||
|
var density: f32 = 0.0;
|
||||||
|
|
||||||
|
if (radius >= halo_inner && radius <= halo_outer) {
|
||||||
|
density = halo_brightness * smooth_edge2(halo_inner, halo_outer, radius);
|
||||||
|
} else if (radius >= main_inner && radius <= main_outer) {
|
||||||
|
var metis_notch_effect: f32 = 1.0;
|
||||||
|
if (radius > metis_notch_center - metis_notch_width * 0.5 && radius < metis_notch_center + metis_notch_width * 0.5) {
|
||||||
|
metis_notch_effect = 0.5 * (1.0 - smooth_edge2(metis_notch_center - metis_notch_width * 0.5, metis_notch_center + metis_notch_width * 0.5, radius));
|
||||||
|
}
|
||||||
|
density = main_brightness * metis_notch_effect * smooth_edge2(main_inner, main_outer, radius);
|
||||||
|
} else {
|
||||||
|
if (radius >= amalthea_inner && radius <= amalthea_outer) {
|
||||||
|
density = almathea_brightness * smooth_edge2(amalthea_inner, amalthea_outer, radius);
|
||||||
|
}
|
||||||
|
if (radius >= thebe_inner && radius <= thebe_outer) {
|
||||||
|
density += thebe_brightness * smooth_edge2(thebe_inner, thebe_outer, radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return density;
|
||||||
|
}
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||||
let jupiter_percent = jupiter_radius / ring_radius;
|
let jupiter_percent = jupiter_radius / ring_radius;
|
||||||
|
@ -148,7 +195,7 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||||
let r_uv = 2 * distance(in.uv, vec2<f32>(0.5));
|
let r_uv = 2 * distance(in.uv, vec2<f32>(0.5));
|
||||||
let r = r_uv * ring_radius / jupiter_radius * jupiter_radius_Mm;
|
let r = r_uv * ring_radius / jupiter_radius * jupiter_radius_Mm;
|
||||||
|
|
||||||
alpha *= ring_density(r);
|
alpha *= ring_density2(r);
|
||||||
if alpha <= 0.0 {
|
if alpha <= 0.0 {
|
||||||
return vec4<f32>(color, alpha);
|
return vec4<f32>(color, alpha);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue