Skip to main content
Animated rays of light radiating from the center, blended with up to 5 colors. Features adjustable density, brightness, center glow, and bloom effects.

React Usage

import { GodRays } from '@paper-design/shaders-react';

export default function MyComponent() {
  return (
    <GodRays
      colorBack="#000000"
      colorBloom="#0000ff"
      colors={['#a600ff6e', '#6200fff0', '#ffffff', '#33fff5']}
      density={0.3}
      spotty={0.3}
      midIntensity={0.4}
      midSize={0.2}
      intensity={0.8}
      bloom={0.4}
      speed={0.75}
      style={{ width: '100%', height: '400px' }}
    />
  );
}

Vanilla JavaScript Usage

import { mountGodRays } from '@paper-design/shaders';

const canvas = document.getElementById('myCanvas');
const cleanup = mountGodRays(canvas, {
  colorBack: '#000000',
  colorBloom: '#0000ff',
  colors: ['#a600ff6e', '#6200fff0', '#ffffff', '#33fff5'],
  density: 0.3,
  spotty: 0.3,
  midIntensity: 0.4,
  midSize: 0.2,
  intensity: 0.8,
  bloom: 0.4,
  speed: 0.75,
});

// Call cleanup() when done

Parameters

colorBack
string
default:"'#000000'"
Background color in hex format.
colorBloom
string
default:"'#0000ff'"
Color overlay blended with the rays in hex format.
colors
string[]
Array of up to 5 ray colors in hex format. Supports alpha channel.
density
number
default:"0.3"
The number of rays. Higher values create more rays. Range: 0 to 1.
spotty
number
default:"0.3"
The length of the rays. Higher values create more spots and shorter rays. Range: 0 to 1.
intensity
number
default:"0.8"
Visibility and strength of the rays. Range: 0 to 1.
midSize
number
default:"0.2"
Size of the circular glow shape in the center. Range: 0 to 1.
midIntensity
number
default:"0.4"
Brightness and intensity of the central glow. Range: 0 to 1.
bloom
number
default:"0.4"
Power of glow effect. 0 uses alpha blending, 1 uses additive blending. Range: 0 to 1.
speed
number
default:"0.75"
Animation speed multiplier. Set to 0 to pause animation.
frame
number
default:"0"
Specific frame to display when speed is 0.

Common Sizing Parameters

scale
number
default:"1"
Overall zoom level of the graphics. Range: 0.01 to 4.
rotation
number
default:"0"
Rotation angle in degrees. Range: 0 to 360.
fit
'none' | 'contain' | 'cover'
default:"'contain'"
How to fit the shader into the canvas dimensions.
offsetX
number
default:"0"
Horizontal offset of the graphics center. Range: -1 to 1.
offsetY
number
default:"-0.55"
Vertical offset of the graphics center. Range: -1 to 1.

Presets

The God Rays shader comes with several built-in presets:
  • Default: Purple and blue rays with bright center
  • Warp: Pink, orange, and white with higher density
  • Linear: White rays with additive bloom
  • Ether: Blue ethereal glow with low density
import { GodRays, warpPreset } from '@paper-design/shaders-react';

<GodRays {...warpPreset.params} />