Skip to content
cael-prussianPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

morphbg

Animated WebGL background shaders for modern websites

morphbg provides beautiful, performant animated backgrounds using WebGL shaders. Three shader systems, automatic scroll-based transitions, and zero configuration required.

๐ŸŽฎ Try Live Demos โ†’

โœจ Features

  • ๐ŸŽจ Three Shader Systems - Topographic Flow, Dynamic Warp, Dot Field
  • ๐Ÿ”„ Automatic Transitions - Smooth shader switching on scroll
  • โšก High Performance - Optimized WebGL rendering at 60fps
  • ๐Ÿ“ฆ Multiple Approaches - Complete bundle or modular loading
  • ๐ŸŽฏ Zero Config - Works out of the box with sensible defaults
  • ๐Ÿ“ฑ Responsive - Adapts to any screen size
  • ๐ŸŒ CDN Ready - Served via jsDelivr

๐Ÿš€ Quick Start

Method 1: Complete Bundle (Recommended)

โ†’ See this demo live

The simplest way - just 2 script tags:

<!DOCTYPE html>
<html>
<head>
    <style>
        body { margin: 0; }
        #bg-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }
        section { height: 100vh; display: flex; align-items: center; justify-content: center; color: white; }
    </style>
</head>
<body>
    <canvas id="bg-canvas"></canvas>
    
    <section data-shader-system="gs1" data-shader-preset="HERO">
        <h1>Welcome</h1>
    </section>
    
    <section data-shader-system="gs2" data-shader-preset="AMBIENT">
        <h2>About</h2>
    </section>
    
    <script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/dist/morphbg-all.complete.js"></script>
</body>
</html>

That's it! The background will automatically transition between shaders as you scroll.


Method 2: Single Shader (Smallest Size)

โ†’ See this demo live

For sites that only need one shader (~13KB gzipped):

<canvas id="bg-canvas"></canvas>

<section data-shader-preset="HERO">
    <h1>Content</h1>
</section>

<script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/engine.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs2/config.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs2/shader.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs2/adaptor.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs2/init.js"></script>

Method 3: Modular Multi-Shader

โ†’ See this demo live

Load only specific shaders you need:

<canvas id="bg-canvas"></canvas>

<section data-shader-system="gs1" data-shader-preset="HERO">
    <h1>Section 1</h1>
</section>

<section data-shader-system="gs3" data-shader-preset="AMBIENT">
    <h2>Section 2</h2>
</section>

<script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/engine.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/scroll-manager.js"></script>
<!-- Load only GS1 -->
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs1/config.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs1/shader.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs1/adaptor.js"></script>
<!-- Load only GS3 -->
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs3/config.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs3/shader.js"></script>
<script src="https://cdn.jsdelivr.net/gh/cael-prussian/morphbg@1.1.0/src/shaders/gs3/adaptor.js"></script>

๐Ÿ“š Documentation

๐ŸŽจ For Shader Developers

Create your own custom shaders with morphbg:

โ†’ Custom Shader Documentation

๐ŸŽจ Shader Systems

GS1: Topographic Flow

Flowing topographic lines with smooth motion. Perfect for technical sites and portfolios.

Presets: HERO, AMBIENT, READ

GS2: Dynamic Warp

Dynamic warping grid with multiple modes. Great for creative agencies and product launches.

Presets: HERO, AMBIENT, READ

GS3: Dot Field

Minimalist dot pattern. Ideal for reading-focused and minimal designs.

Presets: HERO, AMBIENT, READ

๐ŸŽฏ Use Cases

  • Landing Pages - Eye-catching animated backgrounds
  • Portfolios - Showcase creative work with dynamic visuals
  • Product Sites - Enhance product launches with motion
  • Documentation - Add visual interest to technical docs
  • Presentations - Create immersive presentation backgrounds

๐Ÿ“ฆ Bundle Sizes

Bundle Gzipped Contents
Complete ~25KB Engine + Manager + All 3 Shaders
Engine + Manager ~7KB For modular approach
Single Shader ~5-7KB One shader only

โšก Performance

  • Runs at 60fps on modern devices
  • GPU-accelerated WebGL rendering
  • Automatic viewport optimization
  • Smooth shader transitions
  • Mobile-friendly

๐ŸŒ Browser Support

  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+

Requires WebGL support.

๐Ÿ› ๏ธ Development

# Clone repository
git clone https://github.com/cael-prussian/morphbg.git
cd morphbg

# Build bundles
node scripts/build.js

# Open examples (no server needed)
open examples/demo-complete-bundle.html

See Contributing Guide for details.

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ™ Credits

Built with Three.js


Get Started โ†’ | Live Demos โ†’ | API Docs โ†’

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages