add sparkles to jupiter's ring 😍

This commit is contained in:
yuni 2024-10-06 17:57:32 +02:00
parent 131a49b7f9
commit 9acfacc104

View file

@ -14,6 +14,15 @@ fn smooth_edge(start: f32, end: f32, value: f32) -> f32 {
return 4 * x * x * (1 - x * x);
}
fn rand(co: vec2<f32>) -> f32 {
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
}
//const PHI: f32 = 1.61803398874989484820459;
//fn gold_noise(xy: vec2<f32>, seed: f32) -> f32 {
//return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);
//}
fn ring_density(radius: f32) -> f32 {
// NOTE: Keep this in sync with src/nature.rs::ring_density
// Input: distance to center of jupiter in million meters
@ -83,5 +92,11 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(color, alpha * (side_dist - cutoff) / fuzzy_boundary);
}
}
//if (sin(in.uv[0] * 1000.0) + cos(in.uv[1] * 10412.0) > 1.999) {
//if (sin(in.uv[0] * 10000.0 + in.uv[1] * 5132.0) + cos(in.uv[0] * 12399.0 + in.uv[1] * 10412.0) > 1.999) {
//if (sin(sin(in.uv[0] * 10000000.0) * 412.0 + cos(in.uv[1] * 11132000.0) * 12.0) + cos(sin(in.uv[0] * 12309900.0) * 93.0 + sin(in.uv[1] * 10410200.0) * 115.0) > 1.999) {
if (rand(in.uv) + rand(vec2(in.uv[1]*10.0, in.uv[0]*10.0)) > 1.997) {
alpha *= 200.0;
}
return vec4<f32>(color, alpha);
}