Skip to content
🎉 Angular Three v4 is here! Read the announcement

NgtpGodRays

The god rays effect creates volumetric light shafts emanating from a light source, simulating how light scatters through atmosphere or dust particles.

import { NgtpEffectComposer, NgtpGodRays } from 'angular-three-postprocessing';
@Component({
template: `
<ngt-mesh #sun [position]="[0, 5, -10]">
<ngt-sphere-geometry *args="[1, 32, 32]" />
<ngt-mesh-basic-material color="yellow" />
</ngt-mesh>
<ngtp-effect-composer>
<ngtp-god-rays [options]="{ sun: sun }" />
</ngtp-effect-composer>
`,
imports: [NgtpEffectComposer, NgtpGodRays, NgtArgs],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class SceneGraph {}
PropertyTypeDefaultDescription
sunMesh | Points | ElementRefrequiredThe light source mesh
densitynumber0.96Ray density
decaynumber0.9Ray decay factor
weightnumber0.4Ray weight/intensity
exposurenumber0.6Overall exposure
samplesnumber60Number of samples (quality vs performance)
clampMaxnumber1.0Maximum brightness clamp
blurbooleantrueApply blur to rays
@Component({
template: `
<ngt-mesh #sunMesh [position]="[5, 3, -15]">
<ngt-sphere-geometry *args="[2, 32, 32]" />
<ngt-mesh-basic-material color="#ffaa00" />
</ngt-mesh>
<ngtp-effect-composer>
<ngtp-god-rays [options]="{
sun: sunMesh,
density: 0.97,
decay: 0.94,
weight: 0.5,
exposure: 0.5,
samples: 80
}" />
</ngtp-effect-composer>
`,
imports: [NgtpEffectComposer, NgtpGodRays, NgtArgs],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class SceneGraph {}
  • The sun mesh should use MeshBasicMaterial for best results
  • Objects between the camera and sun will create shadows in the light rays
  • Higher samples values improve quality but reduce performance
  • Adjust density and decay together for different ray lengths