diff --git a/packages/frontend/src/scripts/snowfall-effect.ts b/packages/frontend/src/scripts/snowfall-effect.ts index 54fb48c5e4..a09f02cec0 100644 --- a/packages/frontend/src/scripts/snowfall-effect.ts +++ b/packages/frontend/src/scripts/snowfall-effect.ts @@ -4,24 +4,20 @@ */ export class SnowfallEffect { - private VERTEX_SOURCE = ` - precision highp float; - - attribute vec4 a_position; - attribute vec4 a_color; - attribute vec3 a_rotation; - attribute vec3 a_speed; - attribute float a_size; - + private VERTEX_SOURCE = `#version 300 es + in vec4 a_position; + in vec4 a_color; + in vec3 a_rotation; + in vec3 a_speed; + in float a_size; + out vec4 v_color; + out float v_rotation; uniform float u_time; uniform mat4 u_projection; uniform vec3 u_worldSize; uniform float u_gravity; uniform float u_wind; - varying vec4 v_color; - varying float v_rotation; - void main() { v_color = a_color; v_rotation = a_rotation.x + u_time * a_rotation.y; @@ -41,13 +37,13 @@ export class SnowfallEffect { } `; - private FRAGMENT_SOURCE = ` + private FRAGMENT_SOURCE = `#version 300 es precision highp float; + in vec4 v_color; + in float v_rotation; uniform sampler2D u_texture; - - varying vec4 v_color; - varying float v_rotation; + out vec4 out_color; void main() { vec2 rotated = vec2( @@ -55,9 +51,9 @@ export class SnowfallEffect { cos(v_rotation) * (gl_PointCoord.y - 0.5) - sin(v_rotation) * (gl_PointCoord.x - 0.5) + 0.5 ); - vec4 snowflake = texture2D(u_texture, rotated); + vec4 snowflake = texture(u_texture, rotated); - gl_FragColor = vec4(snowflake.rgb * v_color.xyz, snowflake.a * v_color.a); + out_color = vec4(snowflake.rgb * v_color.xyz, snowflake.a * v_color.a); } `; @@ -104,9 +100,9 @@ export class SnowfallEffect { private depth = 100; private count = 1000; private gravity = 100; - private speed: number = 1 / 15000; + private speed: number = 1 / 10000; private color: number[] = [1, 1, 1]; - private opacity = 0.75; + private opacity = 1; private size = 4; private snowflake = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAA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bYRmgjta4cUTqCWXkg0UHatIR4SxxWKK9PeXhgKiZfxWOthzXuGff4p6b54bH3Y3W3pNxJcK8ebgdI44iys0G0N/8qKGOAGg9Ni50n3yjy2GkxSKtMRtT/21I7Fg/H9lRIX6qK5YX6zSjvDL4BGiBfBnUNmFdzwfKX4Ct40OtJv1sDj0Hlzrk6xbM3tob7uCf4amyk96VHvQg7gltGzQG9wpcwX6BCesfJ3/kJiMmgs+Gm4errUeZqF+Up4IoOzoWLcmqETyLve/2BsKkFpGUvK7VYCz6j06RbQx+ogHhN3Qdb3QF+a/wVKF94OhSHR77sWcXytcKm82usHGW9QE2B3skq/QB7APaqnJ9NuvaufnF1GIhxYH3LSAeA+hM0hMfgNzATdHvjgDHDv+qkP8gW77XW2gwmYsJe2F3zZDgxI7NteTo+/1WD/B9Au3Zjh2RyrgAAAABJRU5ErkJggg=='; @@ -159,7 +155,7 @@ export class SnowfallEffect { constructor() { const canvas = this.initCanvas(); - const gl = canvas.getContext('webgl', { antialias: true }); + const gl = canvas.getContext('webgl2', { antialias: true }); if (gl == null) throw new Error('Failed to get WebGL context'); document.body.append(canvas); @@ -190,6 +186,7 @@ export class SnowfallEffect { height: '100vh', background: 'transparent', 'pointer-events': 'none', + 'z-index': 2147483647, }); return canvas;