Home Reference Source
import {GodRaysPass} from 'postprocessing/src/passes/GodRaysPass.js'
public class | source

GodRaysPass

Extends:

Pass → GodRaysPass

Indirect Implements:

A crepuscular rays pass.

Constructor Summary

Public Constructor
public

constructor(scene: Scene, camera: Camera, lightSource: Object3D, options: Object)

Constructs a new god rays pass.

Member Summary

Public Members
public set

If disabled, the input buffer will remain unaffected.

public get

Indicates whether the effect should be applied to the input buffer.

public get

Indicates whether dithering is enabled.

public set

If enabled, the result will be dithered to remove banding artifacts.

public get

The overall intensity of the effect.

public set
public set
public get

The blur kernel size.

public

lightSource: Object3D

The light source.

public
public get

overlay: Texture

The effect overlay texture.

public get
this get was deprecated. Use getResolutionScale() instead.

The resolution scale.

public set
this set was deprecated. Use setResolutionScale(Number) instead.
public set

This value must be carefully chosen.

public get

The number of samples per pixel.

Private Members
private

A blur pass.

private

A combine shader material.

private

A god rays shader material.

private

lightScene: Scene

A scene that only contains the light source.

private

mainCamera: Camera

The main camera.

private

mainScene: Scene

The main scene.

private

A pass that only renders the light source.

private

A pass that renders the masked scene over the light.

private

renderTargetMask: WebGLRenderTarget

A render target for the masked light scene.

private

renderTargetX: WebGLRenderTarget

A render target.

private

renderTargetY: WebGLRenderTarget

A second render target.

private

resolution: Vector2

The original resolution.

private

screenPosition: Vector3

The light position in screen space.

Method Summary

Public Methods
public

Returns the current resolution scale.

public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, delta: Number, stencilTest: Boolean)

Renders the effect.

public

Sets the resolution scale.

public

setSize(width: Number, height: Number)

Updates the size of this pass.

Inherited Summary

From class Pass
public get

material: Material

this get was deprecated. Use getFullscreenMaterial() instead.

The fullscreen material.

protected set

material: Material

this set was deprecated. Use setFullscreenMaterial(Material) instead.
public

[key]: *

public

Indicates whether this pass should be executed.

public

The name of this pass.

public

Indicates whether the EffectComposer should swap the frame buffers after this pass has finished rendering.

public

Indicates whether this pass should render to screen.

protected

camera: Camera

The camera.

protected

scene: Scene

The scene to render.

private

quad: Mesh

A quad mesh that fills the screen.

public

Performs a shallow search for disposable properties and deletes them.

public

getFullscreenMaterial(): Material

Returns the current fullscreen material.

public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public abstract

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, delta: Number, stencilTest: Boolean)

Renders the effect.

public

setSize(width: Number, height: Number)

Updates this pass with the renderer's size.

You may override this method in case you want to be informed about the main render size.

The EffectComposer calls this method before this pass is initialized and every time its own size is updated.

protected

setFullscreenMaterial(material: Material)

Sets the fullscreen material.

Public Constructors

public constructor(scene: Scene, camera: Camera, lightSource: Object3D, options: Object) source

Constructs a new god rays pass.

Override:

Pass#constructor

Params:

NameTypeAttributeDescription
scene Scene

The main scene.

camera Camera

The main camera.

lightSource Object3D

The main light source.

options Object
  • optional

The options.

options.density Number
  • optional
  • default: 0.96

The density of the light rays.

options.decay Number
  • optional
  • default: 0.93

An illumination decay factor.

options.weight Number
  • optional
  • default: 0.4

A light ray weight factor.

options.exposure Number
  • optional
  • default: 0.6

A constant attenuation coefficient.

options.clampMax Number
  • optional
  • default: 1.0

An upper bound for the saturation of the overall effect.

options.intensity Number
  • optional
  • default: 1.0

A constant factor for additive blending.

options.resolutionScale Number
  • optional
  • default: 0.5

The render texture resolution scale, relative to the screen render size.

options.kernelSize Number
  • optional
  • default: KernelSize.LARGE

The blur kernel size.

options.samples Number
  • optional
  • default: 60

The number of samples per pixel.

options.screenMode Number
  • optional
  • default: true

Whether the screen blend mode should be used for combining the god rays texture with the scene colors.

Public Members

public set blend: Boolean source

If disabled, the input buffer will remain unaffected.

You may use the BloomPass#overlay texture to apply the effect to your scene.

public get blend: Boolean source

Indicates whether the effect should be applied to the input buffer.

public get dithering: Boolean source

Indicates whether dithering is enabled.

public set dithering: Boolean source

If enabled, the result will be dithered to remove banding artifacts.

public get intensity: Number source

The overall intensity of the effect.

public set intensity: Number source

public set kernelSize: KernelSize source

public get kernelSize: KernelSize source

The blur kernel size.

public lightSource: Object3D source

The light source.

public needsSwap: * source

Indicates whether the EffectComposer should swap the frame buffers after this pass has finished rendering.

Set this to false if this pass doesn't render to the output buffer or the screen. Otherwise, the contents of the input buffer will be lost.

Override:

Pass#needsSwap

public get overlay: Texture source

The effect overlay texture.

public get resolutionScale: Number source

this get was deprecated. Use getResolutionScale() instead.

The resolution scale.

public set resolutionScale: Number source

this set was deprecated. Use setResolutionScale(Number) instead.

public set samples: Number source

This value must be carefully chosen. A higher value directly increases the GPU load.

public get samples: Number source

The number of samples per pixel.

Private Members

private blurPass: BlurPass source

A blur pass.

private combineMaterial: CombineMaterial source

A combine shader material.

private godRaysMaterial: GodRaysMaterial source

A god rays shader material.

private lightScene: Scene source

A scene that only contains the light source.

private mainCamera: Camera source

The main camera.

private mainScene: Scene source

The main scene.

private renderPassLight: RenderPass source

A pass that only renders the light source.

private renderPassMask: RenderPass source

A pass that renders the masked scene over the light.

private renderTargetMask: WebGLRenderTarget source

A render target for the masked light scene.

private renderTargetX: WebGLRenderTarget source

A render target.

private renderTargetY: WebGLRenderTarget source

A second render target.

private resolution: Vector2 source

The original resolution.

private screenPosition: Vector3 source

The light position in screen space.

Public Methods

public getResolutionScale(): Number source

Returns the current resolution scale.

Return:

Number

The resolution scale.

public initialize(renderer: WebGLRenderer, alpha: Boolean) source

Performs initialization tasks.

Override:

Pass#initialize

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

alpha Boolean

Whether the renderer uses the alpha channel or not.

public render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, delta: Number, stencilTest: Boolean) source

Renders the effect.

Override:

Pass#render

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

inputBuffer WebGLRenderTarget

A frame buffer that contains the result of the previous pass.

outputBuffer WebGLRenderTarget

A frame buffer that serves as the output render target unless this pass renders to screen.

delta Number
  • optional

The time between the last frame and the current one in seconds.

stencilTest Boolean
  • optional

Indicates whether a stencil mask is active.

public setResolutionScale(scale: Number) source

Sets the resolution scale.

Params:

NameTypeAttributeDescription
scale Number

The new resolution scale.

public setSize(width: Number, height: Number) source

Updates the size of this pass.

Override:

Pass#setSize

Params:

NameTypeAttributeDescription
width Number

The width.

height Number

The height.