god rays

Animated rays of light radiating from a centre point — sun beams, cathedral light, nebula glow. Up to five ray colours plus a bloom overlay.

Preview

live

Install

npm
npm i @devmischief/shaders-svelte

Code

import { GodRays } from '@devmischief/shaders-svelte';

<GodRays
  width={1280}
  height={720}
  colors={['#ffffff', '#ffe066', '#ffba47']}
  colorBack="#000000"
  colorBloom="#0000ff"
  bloom={0.4}
  intensity={0.8}
  density={0.3}
  spotty={0.3}
  midSize={0.2}
  midIntensity={0.4}
  scale={1}
  rotation={0}
  offsetX={0}
  offsetY={-0.55}
  speed={0.75}
  fit="contain"
/>
			
			

Shader Props

11
namedescriptiontypevalues
colorsRay colors (up to 5).string[]hex / rgb
colorBackBackground color shown behind the rays.stringhex / rgba
colorBloomColor overlay blended with the rays.stringhex / rgb
bloomBloom blend mode. 0 = alpha blending, 1 = additive blending.number0 → 1
intensityVisibility / strength of the rays.number0 → 1
densityNumber of rays radiating from the center.number0 → 1
spottyLength of the rays. Higher = shorter, more spotty rays.number0 → 1
midSizeSize of the circular glow at the center.number0 → 1
midIntensityBrightness of the central glow.number0 → 1
speedAnimation speed of the rays.number0 → 3
fitHow the rays world is fit into the canvas.stringnone · cover · contain

Common Props

6
namedescriptiontypevalues
originXReference point for positioning width in the canvas.number0 → 1
originYReference point for positioning height in the canvas.number0 → 1
worldWidthVirtual width of the graphic before it's scaled to fit the canvas.number
worldHeightVirtual height of the graphic before it's scaled to fit the canvas.number
minPixelRatioMinimum pixel ratio used when rendering the shader (default 2).number
maxPixelCountMaximum pixel count the shader may process.number

built with mischief by devmischief

@devmischief/shaders-svelte