Class SSRRenderingPipeline
Hierarchy
- PostProcessRenderPipeline
- SSRRenderingPipeline
Index
Constructors
Properties
Accessors
- attenuate
Backface Reflection - attenuate
Facing Camera - attenuate
Intersection Distance - attenuate
Intersection Iterations - attenuate
Screen Borders - backface
Depth Renderer - backface
Depth Texture Downsample - backface
Force Depth Write Transparent Meshes - blur
Dispersion Strength - blur
Downsample - cameras
- clip
To Frustum - debug
- enable
Automatic Thickness Computation - enable
Smooth Reflections - environment
Texture - environment
Texture Is Probe - generate
Output In Gamma Space - input
Texture Color Is In Gamma Space - is
Enabled - is
Supported - name
- samples
- scene
- ssr
Downsample
Methods
Constructors
constructor
Constructor of the SSR rendering pipeline
Parameters
name: string
The rendering pipeline name
scene: Scene
The scene linked to this pipeline
Optional cameras: Camera[]
The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
Optional forceGeometryBuffer: boolean
Set to true if you want to use the legacy geometry buffer renderer (default: false)
Optional textureType: number
The texture type used by the different post processes created by SSR (default: Constants.TEXTURETYPE_UNSIGNED_BYTE)
Returns SSRRenderingPipeline
Properties
SSRBlur Render EffectSearch playground for SSRBlurRenderEffect
The blur PostProcess effect id in the pipeline
SSRCombine Render EffectSearch playground for SSRCombineRenderEffect
The PostProcess effect id in the pipeline that combines the SSR-Blur output with the original scene color
SSRRender EffectSearch playground for SSRRenderEffect
The SSR PostProcess effect id in the pipeline
inspectable Custom PropertiesSearch playground for inspectableCustomProperties
List of inspectable custom properties (used by the Inspector)
max DistanceSearch playground for maxDistance
Gets or sets the maxDistance used to define how far we look for reflection during the ray-marching on the reflected ray (default: 1000). Note that this value is a view (camera) space distance (not pixels!).
max StepsSearch playground for maxSteps
Maximum number of steps during the ray marching process after which we consider an intersection could not be found (default: 1000). Should be an integer value.
reflection Specular Falloff ExponentSearch playground for reflectionSpecularFalloffExponent
Gets or sets the falloff exponent used to compute the reflection strength. Higher values lead to fainter reflections (default: 1).
reflectivity ThresholdSearch playground for reflectivityThreshold
Gets or sets the minimum value for one of the reflectivity component of the material to consider it for SSR (default: 0.04). If all r/g/b components of the reflectivity is below or equal this value, the pixel will not be considered reflective and SSR won't be applied.
roughness FactorSearch playground for roughnessFactor
Gets or sets the factor applied when computing roughness. Default value is 0.2. When blurring based on roughness is enabled (meaning blurDispersionStrength > 0), roughnessFactor is used as a global roughness factor applied on all objects. If you want to disable this global roughness set it to 0.
self Collision Num SkipSearch playground for selfCollisionNumSkip
Number of steps to skip at start when marching the ray to avoid self collisions (default: 1) 1 should normally be a good value, depending on the scene you may need to use a higher value (2 or 3)
stepSearch playground for step
Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Should be an integer >= 1 as it is the number of pixels we advance at each step (default: 1). Use higher values to improve performances (but at the expense of quality).
strengthSearch playground for strength
Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results (default: 1).
thicknessSearch playground for thickness
Gets or sets the thickness value used as tolerance when computing the intersection between the reflected ray and the scene (default: 0.5). If setting "enableAutomaticThicknessComputation" to true, you can use lower values for "thickness" (even 0), as the geometry thickness is automatically computed thank to the regular depth buffer + the backface depth buffer
Accessors
attenuate Backface Reflection
Gets or sets a boolean indicating if the backface reflections should be attenuated (default: false).
Returns boolean
Gets or sets a boolean indicating if the backface reflections should be attenuated (default: false).
Parameters
attenuate: boolean
Returns void
attenuate Facing Camera
Gets or sets a boolean indicating if the reflections should be attenuated when the reflection ray is facing the camera (the view direction) (default: false).
Returns boolean
Gets or sets a boolean indicating if the reflections should be attenuated when the reflection ray is facing the camera (the view direction) (default: false).
Parameters
attenuate: boolean
Returns void
attenuate Intersection Distance
Gets or sets a boolean indicating if the reflections should be attenuated according to the distance of the intersection (default: true).
Returns boolean
Gets or sets a boolean indicating if the reflections should be attenuated according to the distance of the intersection (default: true).
Parameters
attenuate: boolean
Returns void
attenuate Intersection Iterations
Gets or sets a boolean indicating if the reflections should be attenuated according to the number of iterations performed to find the intersection (default: true).
Returns boolean
Gets or sets a boolean indicating if the reflections should be attenuated according to the number of iterations performed to find the intersection (default: true).
Parameters
attenuate: boolean
Returns void
attenuate Screen Borders
Gets or sets a boolean indicating if the reflections should be attenuated at the screen borders (default: true).
Returns boolean
Gets or sets a boolean indicating if the reflections should be attenuated at the screen borders (default: true).
Parameters
attenuate: boolean
Returns void
backface Depth Renderer
Gets the depth renderer used to render the back faces of the scene to a depth texture.
Returns Nullable<DepthRenderer>
backface Depth Texture Downsample
Gets or sets the downsample factor (default: 0) used to create the backface depth texture - used only if enableAutomaticThicknessComputation = true. Use 0 to render the depth at full resolution, 1 to render at half resolution, 2 to render at 1/4 resolution, etc. Note that you will get rendering artefacts when using a value different from 0: it's a tradeoff between image quality and performances.
Returns number
Gets or sets the downsample factor (default: 0) used to create the backface depth texture - used only if enableAutomaticThicknessComputation = true. Use 0 to render the depth at full resolution, 1 to render at half resolution, 2 to render at 1/4 resolution, etc. Note that you will get rendering artefacts when using a value different from 0: it's a tradeoff between image quality and performances.
Parameters
factor: number
Returns void
backface Force Depth Write Transparent Meshes
Gets or sets a boolean (default: true) indicating if the depth of transparent meshes should be written to the backface depth texture (when automatic thickness computation is enabled).
Returns boolean
Gets or sets a boolean (default: true) indicating if the depth of transparent meshes should be written to the backface depth texture (when automatic thickness computation is enabled).
Parameters
force: boolean
Returns void
blur Dispersion Strength
Gets or sets the blur dispersion strength. Set this value to 0 to disable blurring (default: 0.05) The reflections are blurred based on the roughness of the surface and the distance between the pixel shaded and the reflected pixel: the higher the distance the more blurry the reflection is. blurDispersionStrength allows to increase or decrease this effect.
Returns number
Gets or sets the blur dispersion strength. Set this value to 0 to disable blurring (default: 0.05) The reflections are blurred based on the roughness of the surface and the distance between the pixel shaded and the reflected pixel: the higher the distance the more blurry the reflection is. blurDispersionStrength allows to increase or decrease this effect.
Parameters
strength: number
Returns void
blur Downsample
Gets or sets the downsample factor used to reduce the size of the textures used to blur the reflection effect (default: 0). Use 0 to blur at full resolution, 1 to render at half resolution, 2 to render at 1/3 resolution, etc.
Returns number
Gets or sets the downsample factor used to reduce the size of the textures used to blur the reflection effect (default: 0). Use 0 to blur at full resolution, 1 to render at half resolution, 2 to render at 1/3 resolution, etc.
Parameters
downsample: number
Returns void
cameras
Gets the list of attached cameras
Returns Camera[]
clip To Frustum
Gets or sets a boolean indicating if the ray should be clipped to the frustum (default: true). You can try to set this parameter to false to save some performances: it may produce some artefacts in some cases, but generally they won't really be visible
Returns boolean
Gets or sets a boolean indicating if the ray should be clipped to the frustum (default: true). You can try to set this parameter to false to save some performances: it may produce some artefacts in some cases, but generally they won't really be visible
Parameters
clip: boolean
Returns void
debug
Gets or sets a boolean indicating if the effect should be rendered in debug mode (default: false). In this mode, colors have this meaning:
- blue: the ray hit the max distance (we reached maxDistance)
- red: the ray ran out of steps (we reached maxSteps)
- yellow: the ray went off screen
- green: the ray hit a surface. The brightness of the green color is proportional to the distance between the ray origin and the intersection point: A brighter green means more computation than a darker green. In the first 3 cases, the final color is calculated by mixing the skybox color with the pixel color (if environmentTexture is defined), otherwise the pixel color is not modified You should try to get as few blue/red/yellow pixels as possible, as this means that the ray has gone further than if it had hit a surface.
Returns boolean
Gets or sets a boolean indicating if the effect should be rendered in debug mode (default: false). In this mode, colors have this meaning:
- blue: the ray hit the max distance (we reached maxDistance)
- red: the ray ran out of steps (we reached maxSteps)
- yellow: the ray went off screen
- green: the ray hit a surface. The brightness of the green color is proportional to the distance between the ray origin and the intersection point: A brighter green means more computation than a darker green. In the first 3 cases, the final color is calculated by mixing the skybox color with the pixel color (if environmentTexture is defined), otherwise the pixel color is not modified You should try to get as few blue/red/yellow pixels as possible, as this means that the ray has gone further than if it had hit a surface.
Parameters
value: boolean
Returns void
enable Automatic Thickness Computation
Gets or sets a boolean defining if geometry thickness should be computed automatically (default: false). When enabled, a depth renderer is created which will render the back faces of the scene to a depth texture (meaning additional work for the GPU). In that mode, the "thickness" property is still used as an offset to compute the ray intersection, but you can typically use a much lower value than when enableAutomaticThicknessComputation is false (it's even possible to use a value of 0 when using low values for "step") Note that for performance reasons, this option will only apply to the first camera to which the the rendering pipeline is attached!
Returns boolean
Gets or sets a boolean defining if geometry thickness should be computed automatically (default: false). When enabled, a depth renderer is created which will render the back faces of the scene to a depth texture (meaning additional work for the GPU). In that mode, the "thickness" property is still used as an offset to compute the ray intersection, but you can typically use a much lower value than when enableAutomaticThicknessComputation is false (it's even possible to use a value of 0 when using low values for "step") Note that for performance reasons, this option will only apply to the first camera to which the the rendering pipeline is attached!
Parameters
automatic: boolean
Returns void
enable Smooth Reflections
Gets or sets whether or not smoothing reflections is enabled (default: false) Enabling smoothing will require more GPU power. Note that this setting has no effect if step = 1: it's only used if step > 1.
Returns boolean
Gets or sets whether or not smoothing reflections is enabled (default: false) Enabling smoothing will require more GPU power. Note that this setting has no effect if step = 1: it's only used if step > 1.
Parameters
enabled: boolean
Returns void
environment Texture
Gets or sets the environment cube texture used to define the reflection when the reflected rays of SSR leave the view space or when the maxDistance/maxSteps is reached.
Returns Nullable<CubeTexture>
Gets or sets the environment cube texture used to define the reflection when the reflected rays of SSR leave the view space or when the maxDistance/maxSteps is reached.
Parameters
texture: Nullable<CubeTexture>
Returns void
environment Texture Is Probe
Gets or sets the boolean defining if the environment texture is a standard cubemap (false) or a probe (true). Default value is false. Note: a probe cube texture is treated differently than an ordinary cube texture because the Y axis is reversed.
Returns boolean
Gets or sets the boolean defining if the environment texture is a standard cubemap (false) or a probe (true). Default value is false. Note: a probe cube texture is treated differently than an ordinary cube texture because the Y axis is reversed.
Parameters
isProbe: boolean
Returns void
generate Output In Gamma Space
Gets or sets a boolean defining if the output color texture generated by the SSR pipeline should be in gamma space (default: true) If you have a post-process that comes after the SSR and that post-process needs the input to be in a linear space, you must disable generateOutputInGammaSpace
Returns boolean
Gets or sets a boolean defining if the output color texture generated by the SSR pipeline should be in gamma space (default: true) If you have a post-process that comes after the SSR and that post-process needs the input to be in a linear space, you must disable generateOutputInGammaSpace
Parameters
gammaSpace: boolean
Returns void
input Texture Color Is In Gamma Space
Gets or sets a boolean defining if the input color texture is in gamma space (default: true) The SSR effect works in linear space, so if the input texture is in gamma space, we must convert the texture to linear space before applying the effect
Returns boolean
Gets or sets a boolean defining if the input color texture is in gamma space (default: true) The SSR effect works in linear space, so if the input texture is in gamma space, we must convert the texture to linear space before applying the effect
Parameters
gammaSpace: boolean
Returns void
is Enabled
Gets or sets a boolean indicating if the effect is enabled (default: true).
Returns boolean
Gets or sets a boolean indicating if the effect is enabled (default: true).
Parameters
value: boolean
Returns void
is Supported
Returns true if SSR is supported by the running hardware
Returns boolean
name
Gets pipeline name
Returns string
samples
MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
Returns number
MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
Parameters
sampleCount: number
Returns void
scene
Gets active scene
Returns Scene
ssr Downsample
Gets or sets the downsample factor used to reduce the size of the texture used to compute the SSR contribution (default: 0). Use 0 to render the SSR contribution at full resolution, 1 to render at half resolution, 2 to render at 1/3 resolution, etc. Note that it is used only when blurring is enabled (blurDispersionStrength > 0), because in that mode the SSR contribution is generated in a separate texture.
Returns number
Gets or sets the downsample factor used to reduce the size of the texture used to compute the SSR contribution (default: 0). Use 0 to render the SSR contribution at full resolution, 1 to render at half resolution, 2 to render at 1/3 resolution, etc. Note that it is used only when blurring is enabled (blurDispersionStrength > 0), because in that mode the SSR contribution is generated in a separate texture.
Parameters
downsample: number
Returns void
Methods
add CameraSearch playground for addCamera
Adds a camera to the pipeline
Parameters
camera: Camera
the camera to be added
Returns void
add EffectSearch playground for addEffect
Adds an effect to the pipeline
Parameters
renderEffect: PostProcessRenderEffect
the effect to add
Returns void
disposeSearch playground for dispose
Removes the internal pipeline assets and detaches the pipeline from the scene cameras
Parameters
Optional disableGeometryBufferRenderer: boolean
Returns void
get Class NameSearch playground for getClassName
Get the class name
Returns string
"SSRRenderingPipeline"
get SceneSearch playground for getScene
Gets the scene the effect belongs to.
Returns Scene
the scene the effect belongs to.
remove CameraSearch playground for removeCamera
Removes a camera from the pipeline
Parameters
camera: Camera
the camera to remove
Returns void
serializeSearch playground for serialize
Serializes the rendering pipeline (Used when exporting)
Returns any
the serialized object
set Pre Pass RendererSearch playground for setPrePassRenderer
Sets the required values to the prepass renderer.
Parameters
prePassRenderer: PrePassRenderer
defines the prepass renderer to setup.
Returns boolean
true if the pre pass is needed.
Static ParseSearch playground for Parse
Parse the serialized pipeline
Parameters
source: any
Source pipeline.
scene: Scene
The scene to load the pipeline to.
rootUrl: string
The URL of the serialized pipeline.
Returns SSRRenderingPipeline
An instantiated pipeline from the serialized object.
Render pipeline to produce Screen Space Reflections (SSR) effect
References: Screen Space Ray Tracing: - http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html - https://sourceforge.net/p/g3d/code/HEAD/tree/G3D10/data-files/shader/screenSpaceRayTrace.glsl - https://github.com/kode80/kode80SSR SSR: - general tips: https://sakibsaikia.github.io/graphics/2016/12/26/Screen-Space-Reflection-in-Killing-Floor-2.html - computation of blur radius from roughness and distance: https://github.com/godotengine/godot/blob/master/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl - blur and usage of back depth buffer: https://github.com/kode80/kode80SSR