From 9acfacc1041b838cfc33e9a0870cbc042349bfd1 Mon Sep 17 00:00:00 2001 From: yuni Date: Sun, 6 Oct 2024 17:57:32 +0200 Subject: [PATCH] =?UTF-8?q?add=20sparkles=20to=20jupiter's=20ring=20?= =?UTF-8?q?=E2=9C=A8=F0=9F=98=8D=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/shaders/jupiters_rings.wgsl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/assets/shaders/jupiters_rings.wgsl b/assets/shaders/jupiters_rings.wgsl index 0629eb7..fb035dc 100644 --- a/assets/shaders/jupiters_rings.wgsl +++ b/assets/shaders/jupiters_rings.wgsl @@ -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 { + return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); +} + +//const PHI: f32 = 1.61803398874989484820459; +//fn gold_noise(xy: vec2, 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 { return vec4(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(color, alpha); }