From 98a4a3720d0bb5eb9fdae6dbf2dd2b5fd6383f2a Mon Sep 17 00:00:00 2001 From: shubidumdu Date: Sun, 24 Mar 2024 00:10:34 +0900 Subject: [PATCH] Adjust style --- pages/visualizer/main.ts | 6 ++++++ pages/visualizer/shaders/compute.wgsl | 6 +++++- pages/visualizer/shaders/vertex.glsl | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pages/visualizer/main.ts b/pages/visualizer/main.ts index a85ef35..7f19b07 100644 --- a/pages/visualizer/main.ts +++ b/pages/visualizer/main.ts @@ -149,12 +149,16 @@ const init = async () => { uniforms.addUniform('particleCount', 1); uniforms.addUniform('time', 1); uniforms.addUniform('high', 1); + uniforms.addUniform('mid', 1); + uniforms.addUniform('low', 1); uniforms.updateFloat('deltaTime', 0.001); uniforms.updateFloat('radius', RADIUS); uniforms.updateInt('particleCount', PARTICLE_NUMS); uniforms.updateFloat('time', 0); uniforms.updateFloat('high', 0); + uniforms.updateFloat('mid', 0); + uniforms.updateFloat('low', 0); uniforms.update(); const particleBuffer = new StorageBuffer( @@ -219,6 +223,8 @@ const init = async () => { uniforms.updateFloat('deltaTime', deltaTime); uniforms.updateFloat('time', time); uniforms.updateFloat('high', dataArray[12]); + uniforms.updateFloat('mid', dataArray[8]); + uniforms.updateFloat('low', dataArray[4]); uniforms.update(); camera.alpha += deltaTime * 0.00025; computeShader.dispatch(Math.ceil(PARTICLE_NUMS / 64)); diff --git a/pages/visualizer/shaders/compute.wgsl b/pages/visualizer/shaders/compute.wgsl index ec22014..8ac6438 100644 --- a/pages/visualizer/shaders/compute.wgsl +++ b/pages/visualizer/shaders/compute.wgsl @@ -4,6 +4,8 @@ struct Uniforms { particleCount: u32, time: f32, high: f32, + mid: f32, + low: f32, } struct Particle { @@ -29,11 +31,13 @@ const core = vec3(0., 0., 0.); let time = uniforms.time * 0.02; let high = uniforms.high / 255.; + let mid = uniforms.mid / 255.; + let low = uniforms.low / 255.; let speed = uniforms.deltaTime * 0.002; let rotateYMatrix = mat3x3(vec3(cos(speed), 0, -sin(speed)), vec3(0., 1., 0.), vec3(sin(speed), 0, cos(speed))); let radius = uniforms.radius; let position = particles[index].position; - let noise = fbm3d((position.xyz * (.4 + .2 * high) + vec3(0, time, 0)) * .3); + let noise = fbm3d((vec3(1. + .2 * low, 1. + .2 * mid, 1. + .2 * high) * position.xyz * .4 + vec3(0, time, 0)) * .3); let nPosition = normalize(position - core); let velocity = (rotateYMatrix * (nPosition * radius) - position) * .05; diff --git a/pages/visualizer/shaders/vertex.glsl b/pages/visualizer/shaders/vertex.glsl index 20e674d..8ab5e82 100644 --- a/pages/visualizer/shaders/vertex.glsl +++ b/pages/visualizer/shaders/vertex.glsl @@ -25,5 +25,5 @@ void main() { float nMid = mid / 255.; float nLow = low / 255.; float nHigh = high / 255.; - gl_Position = worldViewProjection * vec4(((.8 + .2 * nLow ) * position + (4. + nMid * 20. + nHigh * 20.) * noise * outer), 1.); + gl_Position = worldViewProjection * vec4(((.8 + .2 * nLow ) * position + (4. + nLow * 10. + nMid * 20. + nHigh * 20.) * noise * outer), 1.); }