Thank you for your interest in contributing! This guide will help you get started.
- Node.js (for build script)
- Git
- A modern web browser
git clone https://github.com/cael-prussian/morphbg.git
cd morphbgNo npm install needed - the build script uses only Node.js built-ins.
morphbg/
├── src/ # Source code
│ ├── engine.js # Core shader engine
│ ├── scroll-manager.js # Multi-shader orchestration
│ └── shaders/ # Shader systems
│ ├── gs1/ # Topographic Flow
│ ├── gs2/ # Dynamic Warp
│ └── gs3/ # Dot Field
├── examples/ # Demo files
├── docs/ # Technical documentation
├── scripts/ # Build/deployment scripts
└── dist/ # Generated bundles (gitignored)
Edit source files in src/ or src/shaders/:
# Edit a shader
vim src/shaders/gs1/shader.js
# Edit the engine
vim src/engine.jsOpen example files directly in your browser (no server needed):
# macOS
open examples/demo-complete-bundle.html
# Linux
xdg-open examples/demo-complete-bundle.html
# Windows
start examples/demo-complete-bundle.htmlGenerate deployment bundles:
node scripts/build.jsThis creates files in dist/:
morphbg-gs1.bundle.jsmorphbg-gs2.bundle.jsmorphbg-gs3.bundle.jsmorphbg-engine.bundle.jsmorphbg-all.complete.js
Test the bundled version:
open examples/demo-complete-bundle.htmlgit add src/
git commit -m "Description of changes"
git push origin your-branch-nameThen create a PR on GitHub.
mkdir -p src/shaders/gs4config.js - Define modes and presets:
window.BG4_SHADER_CONFIG = {
modes: {
'mode-name': {
spatialMotion: 0.5,
temporalMotion: 0.5,
cursorStrength: 1.0,
calmDown: 0.3
}
},
presets: {
HERO: {
mode: 'mode-name',
cursorStrength: 1.0
}
}
};shader.js - Fragment shader code:
window.BG4_FRAGMENT_SHADER = `
precision highp float;
uniform vec2 u_resolution;
uniform float u_time;
// ... shader code
`;adaptor.js - Shader adapter (optional):
window.BG4_Adapter = {
extendUniforms(THREE, config, presets) {
return {
u_custom: { value: 0.0 }
};
},
computeTargets(preset, section, viewportInfo, config) {
return {
customValue: 1.0
};
},
applyToMaterial(material, targets, config) {
material.uniforms.u_custom.value = targets.customValue;
}
};init.js - Auto-initialization:
(function () {
function initBG4() {
if (!window.initBGShaderSystem) return;
window.__BG4_INSTANCE__ = window.initBGShaderSystem({
canvasId: 'bg-canvas',
fragmentShader: window.BG4_FRAGMENT_SHADER,
config: window.BG4_SHADER_CONFIG,
adapter: window.BG4_Adapter
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initBG4);
} else {
initBG4();
}
})();Edit src/scroll-manager.js and add your shader to the registry:
const shaders = {
gs1: { /* ... */ },
gs2: { /* ... */ },
gs3: { /* ... */ },
gs4: {
name: 'Your Shader Name',
config: () => window.BG4_SHADER_CONFIG,
fragment: () => window.BG4_FRAGMENT_SHADER,
adapter: () => window.BG4_Adapter,
}
};Edit scripts/build.js to include your shader:
const shaders = [
// ... existing shaders
{
id: 'gs4',
name: 'Your Shader Name',
files: ['src/shaders/gs4/config.js', 'src/shaders/gs4/shader.js', 'src/shaders/gs4/adaptor.js']
}
];Create examples/test-gs4.html to showcase your shader.
- Use consistent indentation (4 spaces)
- Add comments for complex logic
- Follow existing naming conventions
- Keep functions focused and small
Before submitting:
- ✅ Test in Chrome, Firefox, and Safari
- ✅ Test on mobile devices
- ✅ Verify no console errors
- ✅ Check performance (should maintain 60fps)
- ✅ Test all presets work correctly
- ✅ Verify scroll-based switching works
- ✅ Run build script successfully
Use clear, descriptive commit messages:
# Good
git commit -m "Add wave effect to GS1 shader"
git commit -m "Fix GS2 performance on mobile"
git commit -m "Update API documentation"
# Bad
git commit -m "Update stuff"
git commit -m "Fix bug"If you add new features:
- Update
docs/api-reference.md - Add examples to
examples/ - Update wiki pages if needed
- Add comments in code
- Open an issue on GitHub
- Check existing issues/discussions
- Review the wiki for documentation
By contributing, you agree that your contributions will be licensed under the same license as the project.