SelectiveBloom

A selective bloom effect.

This effect applies bloom to selected objects only.

Attention: If you don't need to limit bloom to a subset of objects, consider using the BloomEffect instead for better performance.

import { SelectiveBloom } from '@react-three/postprocessing'
import { BlendFunction, Resolution, KernelSize } from 'postprocessing'

return (
  <SelectiveBloom
    lights={[lightRef1, lightRef2]} // ⚠️ REQUIRED! all relevant lights
    selection={[meshRef1, meshRef2]} // selection of objects that will have the bloom effect
    selectionLayer={10} // selection layer
    inverted={false} // consider the selection inverted
    ignoreBackground={false} // discard the background of the selection
    luminanceThreshold={1.0} // luminance threshold. Raise this value to mask out darker elements in the scene.
    luminanceSmoothing={0.03} // smoothness of the luminance threshold. Range is [0, 1]
    mipmapBlur={true} // enables/disables mipmap blur
    intensity={1.0} // the bloom intensity
    radius={0.85} // the blur radius, only applies to mipmap blur
    levels={8} // the amount of MIP levels, only applies to mipmap blur
    kernelSize={KernelSize.LARGE} // blur kernel size, ignored if mipmapBlur is enabled
    resolutionScale={0.5} // render resolution scale, ignored if mipmapBlur is enabled
    resolutionX={Resolution.AUTO_SIZE} // render width, ignored if mipmapBlur is enabled
    resolutionY={Resolution.AUTO_SIZE} // render height, ignored if mipmapBlur is enabled
  />
)

Example

SelectiveBloom demo

Props

NameTypeDefaultDescription
selectionObjectsSelection of objects that will have the bloom effect
lightsLightsAll lights that will affect the effect - required
selectionLayerNumber10The selection layer
invertedBooleanfalseConsider the selection inverted.
ignoreBackgroundBooleanfalseDiscard the background of the selection.
blendFunctionBlendFunctionBlendFunction.SCREENThe blend function of this effect.
luminanceThresholdNumber1.0The luminance threshold. Raise this value to mask out darker elements in the scene. Range is [0, 1].
luminanceSmoothingNumber0.03Controls the smoothness of the luminance threshold. Range is [0, 1].
mipmapBlurBooleantrueEnables or disables mipmap blur.
intensityNumber1.0The bloom intensity.
radiusNumber0.85The blur radius. Only applies to mipmap blur.
levelsNumber8The amount of MIP levels. Only applies to mipmap blur.
kernelSizeKernelSizeKernelSize.LARGEThe blur kernel size. Ignored if mipmapBlur is enabled.
resolutionScaleNumber0.5The render resolution scale. Ignored if mipmapBlur is enabled.
resolutionXNumberResolution.AUTO_SIZEThe render width. Ignored if mipmapBlur is enabled.
resolutionYNumberResolution.AUTO_SIZEThe render height. Ignored if mipmapBlur is enabled.