https://motioncanvas.online/preview/webgl-gravity-particle-swarm
Scroll Down

Loading Canvas Shader...

Next-Gen Scroll Mechanics

Experience Beautiful Ambient Depth

This browser window is simulating a production webpage. As you scroll down, the ambient WebGL Gravity Particle Swarm background dynamically zooms and pulls focus in real-time, creating beautiful, cinematic parallax depth.

Built for Ultra Performance

Modern web layouts require buttery-smooth animations. Our styles run completely on the GPU, avoiding CPU reflow and main-thread layout jank.

Focus Pull Parallax

Scroll depth controls blur intensity and lens scaling simultaneously to guide focus elegantly.

GPU-Accelerated

Uses hardware transforms and native filters, optimized for stable 120fps scrolling.

Highly Customizable

Adjust speed, maximum blur limit, zoom multipliers, and filters in real-time.

© 2026 MOTIONCANVAS. ALL RIGHTS RESERVED.ACTIVE BACKGROUND: WEBGL GRAVITY PARTICLE SWARM

WebGL Gravity Particle Swarm

🟠 WebGL

Thousands of soft glowing micro-particles swirling dynamically around your cursor, forming beautiful cosmic clusters and gravitation orbits.

#WebGL#particles#gravity#swarm#interactive#constellation
Advertisement
Sponsor Advertisement
728 × 90 | Responsive Banner

Responsive Horizontal Leaderboard

Slot ID: ca-pub-detail-below-preview

Google AdSense Placeholder

Interactive Settings

Motion PresetsCustom Tuning
Animation Speed1.0x
Blur (Aesthetic diffusion)0px
Layer Opacity100%
Scale Zoom1.0x
Rotation Angle0°
Advertisement
Sponsor Advertisement
300 × 250 | Rectangle

Medium Rectangle Block

Slot ID: ca-pub-detail-after-customization

Google AdSense Placeholder

Quick Copy Actions

Download File Packages

Keyboard Shortcuts

Space Play/Pause
F Fullscreen
R Reset Slider
C Copy Code
Advertisement
Sponsor Advertisement
728 × 90 | Responsive Banner

Responsive Horizontal Leaderboard

Slot ID: ca-pub-detail-before-related

Google AdSense Placeholder

More in WebGL

WebGL Gravity Particle Swarm - WebGL 3D GPU WebGL background for React & Tailwind

Integrate the WebGL Gravity Particle Swarm directly into your website. This asset is rendered using raw WebGL shader context. It is optimized for zero layout-shifts and runs with high-performance hardware-accelerated processing.

Performance Specifications

  • Render Mode: WEBGL (WebGL 3D GPU)
  • Fluidity: Locked at 60fps dynamic loop
  • Bundle Footprint: Zero external NPM dependencies
  • SEO Indexing status: 100% Crawlable static semantic HTML

🛠️ Integration Capabilities

Our templates expose inline design tokens like --color-1 and --color-2 for infinite color palettes. This template is designed to fit inside hero elements, full-screen landing pages, and interactive presentation cards.

Technical Code Reference & Syntaxes for Googlebot & Crawlers

The snippets below display the direct, unminified source code utilized for rendering this background.

HTML & Inline CSS Snippet (Vanilla)

<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>WebGL Gravity Particle Swarm</title>
  <style>
    html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #09090b;
    }
    
    #canvas-webgl-swarm {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: none;
    }
  </style>
</head>
<body>

  <canvas id="canvas-webgl-swarm"></canvas>
  <script>
  (function() {
    const canvas = document.getElementById('canvas-webgl-swarm');
    const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
    if (!gl) return;
  
    const count = 3000;
    const positions = new Float32Array(count * 2);
    const velocities = new Float32Array(count * 2);
  
    for (let i = 0; i < count; i++) {
      const angle = Math.random() * Math.PI * 2;
      const dist = 50 + Math.random() * 200;
      positions[i * 2] = Math.cos(angle) * dist;
      positions[i * 2 + 1] = Math.sin(angle) * dist;
      
      velocities[i * 2] = -Math.sin(angle) * (Math.random() * 1.5 + 0.5);
      velocities[i * 2 + 1] = Math.cos(angle) * (Math.random() * 1.5 + 0.5);
    }
  
    const positionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
  
    function createShader(gl, type, source) {
      const shader = gl.createShader(type);
      gl.shaderSource(shader, source);
      gl.compileShader(shader);
      if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
        console.error(gl.getShaderInfoLog(shader));
        gl.deleteShader(shader);
        return null;
      }
      return shader;
    }
  
    const vsSource = `
      attribute vec2 a_position;
      uniform vec2 u_resolution;
      void main() {
        vec2 clipSpace = (a_position / u_resolution) * 2.0;
        gl_Position = vec4(clipSpace, 0.0, 1.0);
        gl_PointSize = 2.0 + (1.0 - clamp(length(a_position) / 1000.0, 0.0, 1.0)) * 2.5;
      }
    `;
  
    const fsSource = `
      precision mediump float;
      void main() {
        float dist = length(gl_PointCoord - vec2(0.5));
        if (dist > 0.5) discard;
        float alpha = smoothstep(0.5, 0.0, dist) * 0.75;
        gl_FragColor = vec4(0.2, 0.75, 1.0, alpha);
      }
    `;
  
    const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
    const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
    if (!vs || !fs) return;
  
    const program = gl.createProgram();
    gl.attachShader(program, vs);
    gl.attachShader(program, fs);
    gl.linkProgram(program);
    if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
  
    gl.useProgram(program);
  
    const aPosition = gl.getAttribLocation(program, 'a_position');
    const uResolution = gl.getUniformLocation(program, 'u_resolution');
  
    let mouseX = 0, mouseY = 0;
    let centerInitialized = false;
  
    window.addEventListener('mousemove', (e) => {
      mouseX = e.clientX - canvas.width / 2;
      mouseY = -(e.clientY - canvas.height / 2);
      centerInitialized = true;
    });
  
    function resize() {
      const width = window.innerWidth;
      const height = window.innerHeight;
      if (canvas.width !== width || canvas.height !== height) {
        canvas.width = width;
        canvas.height = height;
        gl.viewport(0, 0, width, height);
      }
    }
    window.addEventListener('resize', resize);
    resize();
  
    function render() {
      gl.clearColor(0.04, 0.02, 0.07, 1.0);
      gl.clear(gl.COLOR_BUFFER_BIT);
  
      gl.enable(gl.BLEND);
      gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
  
      const targetX = centerInitialized ? mouseX : Math.cos(Date.now() / 1500) * (canvas.width * 0.2);
      const targetY = centerInitialized ? mouseY : Math.sin(Date.now() / 1500) * (canvas.height * 0.2);
  
      for (let i = 0; i < count; i++) {
        const idx = i * 2;
        const x = positions[idx];
        const y = positions[idx + 1];
  
        const dx = targetX - x;
        const dy = targetY - y;
        const distSq = dx * dx + dy * dy + 1000.0;
        const dist = Math.sqrt(distSq);
        
        const force = 0.85 / (distSq * 0.0001 + 1.0);
        velocities[idx] += (dx / dist) * force;
        velocities[idx + 1] += (dy / dist) * force;
  
        velocities[idx] *= 0.985;
        velocities[idx + 1] *= 0.985;
  
        positions[idx] += velocities[idx];
        positions[idx + 1] += velocities[idx + 1];
      }
  
      gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
      gl.bufferSubData(gl.ARRAY_BUFFER, 0, positions);
  
      gl.enableVertexAttribArray(aPosition);
      gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
  
      gl.uniform2f(uResolution, canvas.width, canvas.height);
  
      gl.drawArrays(gl.POINTS, 0, count);
      requestAnimationFrame(render);
    }
    requestAnimationFrame(render);
  })();
  </script>

  
</body>
</html>

React Component Wrapper (TSX)

import React from 'react';

export default function WebGLGravityParticleSwarmBackground() {
  

  return (
    <div 
       
      style={{ width: '100%', height: '100%', position: 'relative', overflow: 'hidden' }}
    >
      <style dangerouslySetInnerHTML={{ __html: `
        #canvas-webgl-swarm {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          border: none;
        }
      ` }} />
      
      {/* HTML Structure */}
      <div 
        style={{ width: '100%', height: '100%' }}
        dangerouslySetInnerHTML={{ __html: `
          <canvas id="canvas-webgl-swarm"></canvas>
          <script>
          (function() {
            const canvas = document.getElementById('canvas-webgl-swarm');
            const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
            if (!gl) return;
          
            const count = 3000;
            const positions = new Float32Array(count * 2);
            const velocities = new Float32Array(count * 2);
          
            for (let i = 0; i < count; i++) {
              const angle = Math.random() * Math.PI * 2;
              const dist = 50 + Math.random() * 200;
              positions[i * 2] = Math.cos(angle) * dist;
              positions[i * 2 + 1] = Math.sin(angle) * dist;
              
              velocities[i * 2] = -Math.sin(angle) * (Math.random() * 1.5 + 0.5);
              velocities[i * 2 + 1] = Math.cos(angle) * (Math.random() * 1.5 + 0.5);
            }
          
            const positionBuffer = gl.createBuffer();
            gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
            gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
          
            function createShader(gl, type, source) {
              const shader = gl.createShader(type);
              gl.shaderSource(shader, source);
              gl.compileShader(shader);
              if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
                console.error(gl.getShaderInfoLog(shader));
                gl.deleteShader(shader);
                return null;
              }
              return shader;
            }
          
            const vsSource = \`
              attribute vec2 a_position;
              uniform vec2 u_resolution;
              void main() {
                vec2 clipSpace = (a_position / u_resolution) * 2.0;
                gl_Position = vec4(clipSpace, 0.0, 1.0);
                gl_PointSize = 2.0 + (1.0 - clamp(length(a_position) / 1000.0, 0.0, 1.0)) * 2.5;
              }
            \`;
          
            const fsSource = \`
              precision mediump float;
              void main() {
                float dist = length(gl_PointCoord - vec2(0.5));
                if (dist > 0.5) discard;
                float alpha = smoothstep(0.5, 0.0, dist) * 0.75;
                gl_FragColor = vec4(0.2, 0.75, 1.0, alpha);
              }
            \`;
          
            const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
            const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
            if (!vs || !fs) return;
          
            const program = gl.createProgram();
            gl.attachShader(program, vs);
            gl.attachShader(program, fs);
            gl.linkProgram(program);
            if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
          
            gl.useProgram(program);
          
            const aPosition = gl.getAttribLocation(program, 'a_position');
            const uResolution = gl.getUniformLocation(program, 'u_resolution');
          
            let mouseX = 0, mouseY = 0;
            let centerInitialized = false;
          
            window.addEventListener('mousemove', (e) => {
              mouseX = e.clientX - canvas.width / 2;
              mouseY = -(e.clientY - canvas.height / 2);
              centerInitialized = true;
            });
          
            function resize() {
              const width = window.innerWidth;
              const height = window.innerHeight;
              if (canvas.width !== width || canvas.height !== height) {
                canvas.width = width;
                canvas.height = height;
                gl.viewport(0, 0, width, height);
              }
            }
            window.addEventListener('resize', resize);
            resize();
          
            function render() {
              gl.clearColor(0.04, 0.02, 0.07, 1.0);
              gl.clear(gl.COLOR_BUFFER_BIT);
          
              gl.enable(gl.BLEND);
              gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
          
              const targetX = centerInitialized ? mouseX : Math.cos(Date.now() / 1500) * (canvas.width * 0.2);
              const targetY = centerInitialized ? mouseY : Math.sin(Date.now() / 1500) * (canvas.height * 0.2);
          
              for (let i = 0; i < count; i++) {
                const idx = i * 2;
                const x = positions[idx];
                const y = positions[idx + 1];
          
                const dx = targetX - x;
                const dy = targetY - y;
                const distSq = dx * dx + dy * dy + 1000.0;
                const dist = Math.sqrt(distSq);
                
                const force = 0.85 / (distSq * 0.0001 + 1.0);
                velocities[idx] += (dx / dist) * force;
                velocities[idx + 1] += (dy / dist) * force;
          
                velocities[idx] *= 0.985;
                velocities[idx + 1] *= 0.985;
          
                positions[idx] += velocities[idx];
                positions[idx + 1] += velocities[idx + 1];
              }
          
              gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
              gl.bufferSubData(gl.ARRAY_BUFFER, 0, positions);
          
              gl.enableVertexAttribArray(aPosition);
              gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
          
              gl.uniform2f(uResolution, canvas.width, canvas.height);
          
              gl.drawArrays(gl.POINTS, 0, count);
              requestAnimationFrame(render);
            }
            requestAnimationFrame(render);
          })();
          </script>
        ` }}
      />
    </div>
  );
}

Next.js App Router Component (use client)

'use client';

import React from 'react';

export default function WebGLGravityParticleSwarmBackground() {
  

  return (
    <div 
       
      className="w-full h-full relative overflow-hidden"
    >
      <style dangerouslySetInnerHTML={{ __html: `
        #canvas-webgl-swarm {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          border: none;
        }
      ` }} />
      
      {/* HTML Structure */}
      <div 
        className="w-full h-full"
        dangerouslySetInnerHTML={{ __html: `
          <canvas id="canvas-webgl-swarm"></canvas>
          <script>
          (function() {
            const canvas = document.getElementById('canvas-webgl-swarm');
            const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
            if (!gl) return;
          
            const count = 3000;
            const positions = new Float32Array(count * 2);
            const velocities = new Float32Array(count * 2);
          
            for (let i = 0; i < count; i++) {
              const angle = Math.random() * Math.PI * 2;
              const dist = 50 + Math.random() * 200;
              positions[i * 2] = Math.cos(angle) * dist;
              positions[i * 2 + 1] = Math.sin(angle) * dist;
              
              velocities[i * 2] = -Math.sin(angle) * (Math.random() * 1.5 + 0.5);
              velocities[i * 2 + 1] = Math.cos(angle) * (Math.random() * 1.5 + 0.5);
            }
          
            const positionBuffer = gl.createBuffer();
            gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
            gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
          
            function createShader(gl, type, source) {
              const shader = gl.createShader(type);
              gl.shaderSource(shader, source);
              gl.compileShader(shader);
              if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
                console.error(gl.getShaderInfoLog(shader));
                gl.deleteShader(shader);
                return null;
              }
              return shader;
            }
          
            const vsSource = \`
              attribute vec2 a_position;
              uniform vec2 u_resolution;
              void main() {
                vec2 clipSpace = (a_position / u_resolution) * 2.0;
                gl_Position = vec4(clipSpace, 0.0, 1.0);
                gl_PointSize = 2.0 + (1.0 - clamp(length(a_position) / 1000.0, 0.0, 1.0)) * 2.5;
              }
            \`;
          
            const fsSource = \`
              precision mediump float;
              void main() {
                float dist = length(gl_PointCoord - vec2(0.5));
                if (dist > 0.5) discard;
                float alpha = smoothstep(0.5, 0.0, dist) * 0.75;
                gl_FragColor = vec4(0.2, 0.75, 1.0, alpha);
              }
            \`;
          
            const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
            const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
            if (!vs || !fs) return;
          
            const program = gl.createProgram();
            gl.attachShader(program, vs);
            gl.attachShader(program, fs);
            gl.linkProgram(program);
            if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
          
            gl.useProgram(program);
          
            const aPosition = gl.getAttribLocation(program, 'a_position');
            const uResolution = gl.getUniformLocation(program, 'u_resolution');
          
            let mouseX = 0, mouseY = 0;
            let centerInitialized = false;
          
            window.addEventListener('mousemove', (e) => {
              mouseX = e.clientX - canvas.width / 2;
              mouseY = -(e.clientY - canvas.height / 2);
              centerInitialized = true;
            });
          
            function resize() {
              const width = window.innerWidth;
              const height = window.innerHeight;
              if (canvas.width !== width || canvas.height !== height) {
                canvas.width = width;
                canvas.height = height;
                gl.viewport(0, 0, width, height);
              }
            }
            window.addEventListener('resize', resize);
            resize();
          
            function render() {
              gl.clearColor(0.04, 0.02, 0.07, 1.0);
              gl.clear(gl.COLOR_BUFFER_BIT);
          
              gl.enable(gl.BLEND);
              gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
          
              const targetX = centerInitialized ? mouseX : Math.cos(Date.now() / 1500) * (canvas.width * 0.2);
              const targetY = centerInitialized ? mouseY : Math.sin(Date.now() / 1500) * (canvas.height * 0.2);
          
              for (let i = 0; i < count; i++) {
                const idx = i * 2;
                const x = positions[idx];
                const y = positions[idx + 1];
          
                const dx = targetX - x;
                const dy = targetY - y;
                const distSq = dx * dx + dy * dy + 1000.0;
                const dist = Math.sqrt(distSq);
                
                const force = 0.85 / (distSq * 0.0001 + 1.0);
                velocities[idx] += (dx / dist) * force;
                velocities[idx + 1] += (dy / dist) * force;
          
                velocities[idx] *= 0.985;
                velocities[idx + 1] *= 0.985;
          
                positions[idx] += velocities[idx];
                positions[idx + 1] += velocities[idx + 1];
              }
          
              gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
              gl.bufferSubData(gl.ARRAY_BUFFER, 0, positions);
          
              gl.enableVertexAttribArray(aPosition);
              gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
          
              gl.uniform2f(uResolution, canvas.width, canvas.height);
          
              gl.drawArrays(gl.POINTS, 0, count);
              requestAnimationFrame(render);
            }
            requestAnimationFrame(render);
          })();
          </script>
        ` }}
      />
    </div>
  );
}

Raw CSS Stylesheet Snippet

#canvas-webgl-swarm {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}