Skip to content

@orillusion/core


Class: FluidRenderer ​

Defined in: src/components/renderer/FluidRenderer.ts:76

Renders a particle set as a continuous liquid surface (screen-space fluid rendering). Particles are drawn as sphere impostors into a depth buffer which is then smoothed and shaded in screen space.

Requires setting.render.fluid = true so ForwardRendererJob adds FluidPass. The fluid is drawn after opaque geometry and before transparent geometry.

Particle positions are in the local space of the owning Object3D (world space when it sits at the origin unscaled); particleSize is in world units. They come from either:

  • setDataBuffer: a CPU Float32Array, uploaded when set.
  • setDataBufferGPU: an existing storage buffer (e.g. written by a simulation compute shader), read directly without a copy.

Extends ​

Constructors ​

Constructor ​

new FluidRenderer(): FluidRenderer

Returns ​

FluidRenderer

Inherited from ​

ComponentBase.constructor

Properties ​

object3D ​

object3D: Object3D = null

Defined in: src/components/ComponentBase.ts:29

owner object3D

Inherited from ​

ComponentBase.object3D


isDestroyed ​

isDestroyed: boolean = false

Defined in: src/components/ComponentBase.ts:77

Inherited from ​

ComponentBase.isDestroyed


particleSize ​

particleSize: number = 0.1

Defined in: src/components/renderer/FluidRenderer.ts:78

Particle diameter in world units.


particleThicknessAlpha ​

particleThicknessAlpha: number = 0.05

Defined in: src/components/renderer/FluidRenderer.ts:80

Thickness one particle adds at its center; the fluid gets more opaque as it grows.


depthMapSize ​

depthMapSize: number = null

Defined in: src/components/renderer/FluidRenderer.ts:83

Width of the depth map in pixels; height follows the screen aspect. null = screen size.


thicknessMapSize ​

thicknessMapSize: number = null

Defined in: src/components/renderer/FluidRenderer.ts:85

Width of the thickness map in pixels; height follows the screen aspect. null = screen size.


fluidColor ​

fluidColor: Color

Defined in: src/components/renderer/FluidRenderer.ts:88

Absorption color: light passing through the fluid is tinted toward it.


density ​

density: number = 2

Defined in: src/components/renderer/FluidRenderer.ts:90

Absorption strength; higher makes the fluid more opaque. With FluidThicknessMode.Geometric it is per world unit of thickness.


refractionStrength ​

refractionStrength: number = 1

Defined in: src/components/renderer/FluidRenderer.ts:92

Scale of the refraction offset: 1 follows the refracted ray to the scene behind, 0 disables refraction.


fresnelClamp ​

fresnelClamp: number = 1

Defined in: src/components/renderer/FluidRenderer.ts:94

Upper bound of the fresnel reflection weight (0 to 1).


specularPower ​

specularPower: number = 250

Defined in: src/components/renderer/FluidRenderer.ts:96

Specular exponent; higher gives a smaller, sharper highlight.


minimumThickness ​

minimumThickness: number = 0

Defined in: src/components/renderer/FluidRenderer.ts:98

Pixels with less thickness show the background. With useFixedThickness, the thickness used everywhere.


edgeSoftness ​

edgeSoftness: number = 0

Defined in: src/components/renderer/FluidRenderer.ts:104

Fade the fluid into the background where it is thinner than this many particles (particleThicknessAlpha each when accumulated, particleSize each when geometric); softens free edges. 0 disables.


useFixedThickness ​

useFixedThickness: boolean = false

Defined in: src/components/renderer/FluidRenderer.ts:116

Skip the thickness pass and use minimumThickness as a constant thickness.


dirLight ​

dirLight: Vector3 = null

Defined in: src/components/renderer/FluidRenderer.ts:118

World-space direction the light travels, for the specular highlight. null uses the scene's first DirectLight, or (-2, -1, 1) without one.


environmentMap ​

environmentMap: Texture = undefined

Defined in: src/components/renderer/FluidRenderer.ts:120

Cube map reflected by the fluid. undefined uses the scene's envMap; null disables reflection.


useAnisotropy ​

useAnisotropy: boolean = false

Defined in: src/components/renderer/FluidRenderer.ts:126

Stretch each particle into an ellipsoid along its neighbor distribution, so flat regions stay flat and thin sheets stay thin. Adds a neighbor search on the GPU each frame.


anisotropyRadius ​

anisotropyRadius: number = null

Defined in: src/components/renderer/FluidRenderer.ts:128

Neighbor search radius in world units. null uses 1.5 × particleSize.


anisotropyMaxRatio ​

anisotropyMaxRatio: number = 4

Defined in: src/components/renderer/FluidRenderer.ts:130

Largest ratio between the longest and shortest ellipsoid axis.


anisotropyMinNeighbors ​

anisotropyMinNeighbors: number = 10

Defined in: src/components/renderer/FluidRenderer.ts:132

Particles with fewer neighbors stay spheres (spray, droplets).


anisotropySmoothing ​

anisotropySmoothing: number = 0.5

Defined in: src/components/renderer/FluidRenderer.ts:134

How far (0 to 1) each particle moves toward the weighted mean of its neighbors, which smooths the surface.


enableBlurDepth ​

enableBlurDepth: boolean = true

Defined in: src/components/renderer/FluidRenderer.ts:137

Smooth the depth map so the spheres merge into one surface.


blurDepthSizeDivisor ​

blurDepthSizeDivisor: number = 1

Defined in: src/components/renderer/FluidRenderer.ts:148

Depth blur runs at the depth map size divided by this.


blurDepthFilterSize ​

blurDepthFilterSize: number = 7

Defined in: src/components/renderer/FluidRenderer.ts:150

Depth blur radius, relative to the projected particle size.


blurDepthNumIterations ​

blurDepthNumIterations: number = 3

Defined in: src/components/renderer/FluidRenderer.ts:152

Depth blur passes (each is one horizontal + one vertical pass).


blurDepthMaxFilterSize ​

blurDepthMaxFilterSize: number = 100

Defined in: src/components/renderer/FluidRenderer.ts:154

Upper bound of the depth blur radius in pixels.


blurDepthDepthScale ​

blurDepthDepthScale: number = 10

Defined in: src/components/renderer/FluidRenderer.ts:156

Depth range, in particle radii, across which samples are still blended; larger merges more.


enableBlurThickness ​

enableBlurThickness: boolean = true

Defined in: src/components/renderer/FluidRenderer.ts:159

Smooth the thickness map.


blurThicknessSizeDivisor ​

blurThicknessSizeDivisor: number = 1

Defined in: src/components/renderer/FluidRenderer.ts:161

Thickness blur runs at the thickness map size divided by this.


blurThicknessFilterSize ​

blurThicknessFilterSize: number = 5

Defined in: src/components/renderer/FluidRenderer.ts:163

Thickness blur radius in pixels.


blurThicknessNumIterations ​

blurThicknessNumIterations: number = 1

Defined in: src/components/renderer/FluidRenderer.ts:165

Thickness blur passes (each is one horizontal + one vertical pass).


debug ​

debug: boolean = false

Defined in: src/components/renderer/FluidRenderer.ts:168

Show the image selected by debugFeature instead of the fluid.

Accessors ​

visibleLayer ​

Get Signature ​

get visibleLayer(): number

Defined in: src/components/ComponentBase.ts:46

Composition-layer membership bitmask. The pass / camera / collector filters via

(component.visibleLayer & pass.layerMask & camera.cullingMask) !== 0

Defaults to VisibleLayer.Default (bit 0) so a fresh subclass is visible to passes whose layerMask is VisibleLayer.All (which includes bit 0). Application code can assign project-specific bits (1..31) to organise the scene into composition layers.

Returns ​

number

Set Signature ​

set visibleLayer(value): void

Defined in: src/components/ComponentBase.ts:50

Parameters ​
value ​

number

Returns ​

void

Inherited from ​

ComponentBase.visibleLayer


eventDispatcher ​

Get Signature ​

get eventDispatcher(): CEventDispatcher

Defined in: src/components/ComponentBase.ts:63

Returns ​

CEventDispatcher

Set Signature ​

set eventDispatcher(value): void

Defined in: src/components/ComponentBase.ts:68

Parameters ​
value ​

CEventDispatcher

Returns ​

void

Inherited from ​

ComponentBase.eventDispatcher


isStart ​

Get Signature ​

get isStart(): boolean

Defined in: src/components/ComponentBase.ts:79

Returns ​

boolean

Inherited from ​

ComponentBase.isStart


transform ​

Get Signature ​

get transform(): Transform

Defined in: src/components/ComponentBase.ts:89

Return the Transform component attached to the Object3D. Null before the component is attached — addComponent assigns object3D only after construction — so constructor-time callers can probe safely via this.transform?..

Returns ​

Transform

Inherited from ​

ComponentBase.transform


enable ​

Get Signature ​

get enable(): boolean

Defined in: src/components/ComponentBase.ts:113

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Returns ​

boolean

Set Signature ​

set enable(value): void

Defined in: src/components/ComponentBase.ts:96

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Parameters ​
value ​

boolean

Returns ​

void

Inherited from ​

ComponentBase.enable


thicknessMode ​

Get Signature ​

get thicknessMode(): FluidThicknessMode

Defined in: src/components/renderer/FluidRenderer.ts:108

How thickness is measured for absorption.

Returns ​

FluidThicknessMode

Set Signature ​

set thicknessMode(value): void

Defined in: src/components/renderer/FluidRenderer.ts:111

Parameters ​
value ​

FluidThicknessMode

Returns ​

void


depthFilter ​

Get Signature ​

get depthFilter(): FluidDepthFilter

Defined in: src/components/renderer/FluidRenderer.ts:140

Filter used to smooth the depth map.

Returns ​

FluidDepthFilter

Set Signature ​

set depthFilter(value): void

Defined in: src/components/renderer/FluidRenderer.ts:143

Parameters ​
value ​

FluidDepthFilter

Returns ​

void


debugFeature ​

Get Signature ​

get debugFeature(): FluidDebug

Defined in: src/components/renderer/FluidRenderer.ts:171

Returns ​

FluidDebug

Set Signature ​

set debugFeature(value): void

Defined in: src/components/renderer/FluidRenderer.ts:174

Parameters ​
value ​

FluidDebug

Returns ​

void


particleCount ​

Get Signature ​

get particleCount(): number

Defined in: src/components/renderer/FluidRenderer.ts:218

Number of particles drawn. Can be lowered to draw a prefix of the buffer.

Returns ​

number

Set Signature ​

set particleCount(value): void

Defined in: src/components/renderer/FluidRenderer.ts:221

Parameters ​
value ​

number

Returns ​

void

Methods ​

init() ​

init(param?): void

Defined in: src/components/ComponentBase.ts:161

Parameters ​

param? ​

any

Returns ​

void

Inherited from ​

ComponentBase.init


start() ​

start(): void

Defined in: src/components/ComponentBase.ts:162

Returns ​

void

Inherited from ​

ComponentBase.start


stop() ​

stop(): void

Defined in: src/components/ComponentBase.ts:163

Returns ​

void

Inherited from ​

ComponentBase.stop


onEnable()? ​

optional onEnable(view?): any

Defined in: src/components/ComponentBase.ts:164

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onEnable


onDisable()? ​

optional onDisable(view?): any

Defined in: src/components/ComponentBase.ts:165

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onDisable


onUpdate()? ​

optional onUpdate(view?): any

Defined in: src/components/ComponentBase.ts:166

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onUpdate


onLateUpdate()? ​

optional onLateUpdate(view?): any

Defined in: src/components/ComponentBase.ts:167

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onLateUpdate


onBeforeUpdate()? ​

optional onBeforeUpdate(view?): any

Defined in: src/components/ComponentBase.ts:168

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onBeforeUpdate


onCompute()? ​

optional onCompute(view?, command?): any

Defined in: src/components/ComponentBase.ts:169

Parameters ​

view? ​

View3D

command? ​

GPUCommandEncoder

Returns ​

any

Inherited from ​

ComponentBase.onCompute


onGraphic()? ​

optional onGraphic(view?): any

Defined in: src/components/ComponentBase.ts:170

Parameters ​

view? ​

View3D

Returns ​

any

Inherited from ​

ComponentBase.onGraphic


onParentChange()? ​

optional onParentChange(lastParent?, currentParent?): any

Defined in: src/components/ComponentBase.ts:171

Parameters ​

lastParent? ​

Object3D

currentParent? ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onParentChange


onAddChild()? ​

optional onAddChild(child): any

Defined in: src/components/ComponentBase.ts:172

Parameters ​

child ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onAddChild


onRemoveChild()? ​

optional onRemoveChild(child): any

Defined in: src/components/ComponentBase.ts:173

Parameters ​

child ​

Object3D

Returns ​

any

Inherited from ​

ComponentBase.onRemoveChild


cloneTo() ​

cloneTo(obj): void

Defined in: src/components/ComponentBase.ts:180

clone component data to target object3D

Parameters ​

obj ​

Object3D

target object3D

Returns ​

void

Inherited from ​

ComponentBase.cloneTo


copyComponent() ​

copyComponent(from): this

Defined in: src/components/ComponentBase.ts:182

Parameters ​

from ​

this

Returns ​

this

Inherited from ​

ComponentBase.copyComponent


beforeDestroy() ​

beforeDestroy(force?): void

Defined in: src/components/ComponentBase.ts:249

before release this component, object refrences are not be set null now.

Parameters ​

force? ​

boolean

Returns ​

void

Inherited from ​

ComponentBase.beforeDestroy


destroy() ​

destroy(force?): void

Defined in: src/components/ComponentBase.ts:256

release this component

Parameters ​

force? ​

boolean

Returns ​

void

Inherited from ​

ComponentBase.destroy


setDataBuffer() ​

setDataBuffer(data, count?, layout?): void

Defined in: src/components/renderer/FluidRenderer.ts:193

Use CPU particle data. The array is uploaded on the next frame; call again after modifying it in place to re-upload.

Parameters ​

data ​

Float32Array

particle data, laid out as described by layout

count? ​

number

number of particles; defaults to as many as data holds

layout? ​

FluidDataLayout

particle byte layout

Returns ​

void


setDataBufferGPU() ​

setDataBufferGPU(buffer, count, layout?): void

Defined in: src/components/renderer/FluidRenderer.ts:210

Use a GPU buffer as particle data. The buffer needs STORAGE usage and is read every frame, so updates made by compute shaders show up without further calls.

Parameters ​

buffer ​

GPUBufferBase

storage buffer holding the particles

count ​

number

number of particles to draw

layout? ​

FluidDataLayout

particle byte layout

Returns ​

void