Depth of Field
This page describes SOMA’s Depth of Field effect.
Depth of field creates a focus range and blurs outside it. The helper returns an instance ID so its focus range and falloff can be faded or the instance removed.
Contents
Before you start
- Open the map script inside your own mod. Keep its generated includes,
cScrMap : iScrMapclass and callback structure. See Add your first script if you have not edited a map script yet. - Add the helper include shown below alongside the script’s other includes.
- Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.
Follow the stock example
#include "helpers/helper_effects.hps"
Effect_DoF_Start
Starts an instance of depth of field and returns the id
| Parameter | Meaning |
|---|---|
afFocusStart |
near plane of the instance |
afFocusEnd |
far plane of the instance |
afFalloff |
how smooth the transition from sharp to blurr should be |
afTime |
time to fade to this value |
In maps/chapter02/02_02_ms_curie_inside/02_02_ms_curie_inside.hps, SOMA calls Effect_DoF_Start as follows.
Effect_DoF_Start(0, 6, 0.5, 0);
| Parameter | Value in this stock call |
|---|---|
afFocusStart |
0
|
afFocusEnd |
6
|
afFalloff |
0.5
|
afTime |
0
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
Effect_DoF_FadeFocus
Fade the start and end of the focus plane
| Parameter | Meaning |
|---|---|
alID |
id of the instance |
afFocusStart |
near plane of the instance |
afFocusEnd |
far plane of the instance |
afTime |
time to fade to this value |
In maps/chapter04/04_03_tau_escape/04_03_tau_escape.hps, SOMA calls Effect_DoF_FadeFocus as follows.
Effect_DoF_FadeFocus(mlDoFId, 0.05, 10, 2);
| Parameter | Value in this stock call |
|---|---|
alID |
mlDoFId
|
afFocusStart |
0.05
|
afFocusEnd |
10
|
afTime |
2
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
Effect_DoF_FadeOut
Fade out the instance of depth of field, the instance is removed after fading out
| Parameter | Meaning |
|---|---|
alID |
id of the instance |
afTime |
time to fade out |
Check your change
Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.