PcoWSkbVqDnWTu_dm2ix
Post-Processing Effects
Part 2 - Examples
Post-Processing Effects
Part 2 - Examples

The examples below combine different post-processing effects to create different effects that can be used in games. Unless stated, assume that all effects are parented to Lighting. For each scene, click on the effect name (Bloom, Sun Rays, etc) to see property values that will achieve the pictured effect.

Outdoor Lighting

Bloom
Intensity 0.5
Size 50
Threshold 0.8
DepthOfField
FarIntensity 0.5
FocusDistance 15
InFocusRadius 30
NearIntensity 0
ColorCorrection
Brightness 0
Contrast 0.2
Saturation 0.1
TintColor
[255, 250, 235]
SunRays
Intensity 0.035
Spread 0.4

Indoor Lighting

Bloom
Intensity 0.8
Size 40
Threshold 1.5
DepthOfField
FarIntensity 0.5
FocusDistance 12
InFocusRadius 5
NearIntensity 1
ColorCorrection
Brightness 0
Contrast 0.4
Saturation -0.4
TintColor
[220, 210, 255]

Player Damage Feedback

Post-processing effects can be scripted, often with animations using TweenService. This example shows a death effect where the screen blurs and changes color. Its script can be repurposed in different ways, such as color-shifting the screen if a player is poisoned, or blurring the screen while a menu is active.

To use the script below, copy its code into a LocalScript within StarterPlayerScripts. For more information on manipulating the fade effect, such as getting different colors or altering the delay, see the TweenService API.

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
 
local player = Players.LocalPlayer
 
-- Create effects and parent them to the player's current camera
local blurEffect = Instance.new("BlurEffect")
blurEffect.Parent = workspace.CurrentCamera
local colorCorrectionEffect = Instance.new("ColorCorrectionEffect")
colorCorrectionEffect.Parent = workspace.CurrentCamera
 
-- Effect constants
local EFFECT_DELAY = 0  -- Seconds
local EFFECT_DURATION = 6  -- Seconds
local TINT_COLOR = Color3.fromRGB(200, 45, 45)
local BLUR_INTENSITY = 56  -- From 0 to 56 (full blur)
 
-- Create a "TweenInfo" used for the duration of both the blur and color effects
local deathEffectInfo = TweenInfo.new(
	EFFECT_DURATION,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	EFFECT_DELAY)
 
-- Create tweens using specific goals for blur and color
local tweenBlurGoal = {
	Size = BLUR_INTENSITY,
	-- Other properties to customize based off the "BlurEffect" instance
}
local tweenColorGoal = {
	TintColor = TINT_COLOR
	-- Other properties to customize based off the "ColorCorrectionEffect" instance
}
local tweenBlur = TweenService:Create(blurEffect, deathEffectInfo, tweenBlurGoal)
local tweenColor = TweenService:Create(colorCorrectionEffect, deathEffectInfo, tweenColorGoal)
 
local function playDeathTween()
	blurEffect.Enabled = true
	colorCorrectionEffect.Enabled = true
	tweenBlur:Play()
	tweenColor:Play()
end
 
local function setupDeathTween(character)
	
	local humanoid = character:WaitForChild("Humanoid")
 
	if tweenBlur and tweenBlur.PlaybackState == Enum.PlaybackState.Playing then
		tweenBlur:Cancel()
		tweenColor:Cancel()
	end
 
	-- Disable the effects and set them to starting values
	blurEffect.Enabled = false
	blurEffect.Size = 0
	colorCorrectionEffect.Enabled = false
	colorCorrectionEffect.TintColor = Color3.fromRGB(255, 255, 255)
 
	-- Create the "Died" event connection for the tween
	humanoid.Died:Connect(function()
		playDeathTween()
	end)
end
 
-- Event connections
player.CharacterAdded:Connect(setupDeathTween)
 
if player.Character then
	setupDeathTween(player.Character)
end

Previous Page Getting Started