# SPostFX

**Members** 17

|          |                                                                 |                                                                |
| -------- | --------------------------------------------------------------- | -------------------------------------------------------------- |
| Function | [CreateCommandBuffer](#createcommandbuffer)                     | Return a new CommandBuffer.                                    |
| Function | [AddCommandBufferToCamera](#addcommandbuffertocamera)           | Add the CommandBuffer to the Main Camera.                      |
| Function | [RemoveCommandBufferFromCamera](#removecommandbufferfromcamera) | Remove the CommandBuffer from the Main Camera.                 |
| Function | [SetPostProfile](#setpostprofile)                               | Set a custom Space Post-Processing Profile.                    |
| Function | [ClearPostProfile](#clearpostprofile)                           | Clear current Post-Processing profile and restore default one. |
| Function | [SetCrepsecularRays](#setcrepsecularrays)                       | –                                                              |
| Function | [SetAmbientOcclusion](#setambientocclusion)                     | –                                                              |
| Function | [SetMotionBlur](#setmotionblur)                                 | –                                                              |
| Function | [SetBloom](#setbloom)                                           | –                                                              |
| Function | [SetAnamorphicFlares](#setanamorphicflares)                     | –                                                              |
| Function | [SetVignette](#setvignette)                                     | –                                                              |
| Function | [SetLensDirt](#setlensdirt)                                     | –                                                              |
| Function | [SetChromaticAberrationPost](#setchromaticaberrationpost)       | –                                                              |
| Function | [SetFocus](#setfocus)                                           | –                                                              |
| Function | [SupressFocus](#supressfocus)                                   | –                                                              |
| Function | [RestoreFocus](#restorefocus)                                   | –                                                              |
| Function | [SetLookUpTable](#setlookuptable)                               | –                                                              |

## Functions

### CreateCommandBuffer

[SCommandBuffer](/docs/scripting/client-scripting-api-reference/types/scommandbuffer.md) CreateCommandBuffer()

Return a new CommandBuffer.

Returns

`SCommandBuffer`

Example

**Lua**

```lua
commandBuffer = Space.PostFX.CreateCommandBuffer()

```

**Lua**

```lua
local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)

```

### AddCommandBufferToCamera

void AddCommandBufferToCamera([SCommandBuffer](/docs/scripting/client-scripting-api-reference/types/scommandbuffer.md) commandbuffer, int cameraEvent = 19)

Add the CommandBuffer to the Main Camera.

Parameters

| Name          | Type                                                                                     | Default |
| ------------- | ---------------------------------------------------------------------------------------- | ------- |
| commandbuffer | [SCommandBuffer](/docs/scripting/client-scripting-api-reference/types/scommandbuffer.md) | –       |
| cameraEvent   | int                                                                                      | 19      |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.AddCommandBufferToCamera(ACommandBuffer)
---or
Space.PostFX.AddCommandBufferToCamera(ACommandBuffer, 18)

```

**Lua**

```lua
local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)
function RemoveCommandBuffer()
--Bind this function to a button and then click it in playing.
    Space.PostFX.RemoveCommandBufferFromCamera(commandbuffer)
end

```

### RemoveCommandBufferFromCamera

void RemoveCommandBufferFromCamera([SCommandBuffer](/docs/scripting/client-scripting-api-reference/types/scommandbuffer.md) commandbuffer, int cameraEvent = 19)

Remove the CommandBuffer from the Main Camera.

Parameters

| Name          | Type                                                                                     | Default |
| ------------- | ---------------------------------------------------------------------------------------- | ------- |
| commandbuffer | [SCommandBuffer](/docs/scripting/client-scripting-api-reference/types/scommandbuffer.md) | –       |
| cameraEvent   | int                                                                                      | 19      |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.RemoveCommandBufferToCamera(ACommandBuffer)
---or
Space.PostFX.RemoveCommandBufferToCamera(ACommandBuffer, 18)

```

**Lua**

```lua
local commandbuffer=Space.PostFX.CreateCommandBuffer()
local mat=Space.Resources[1]
local cube=Space.Host.GetReference("Cube")
commandbuffer.DrawRenderer(cube.Renderer,mat.AsMaterial)
Space.PostFX.AddCommandBufferToCamera(commandbuffer)
function RemoveCommandBuffer()
--Bind this function to a button and then click it in playing.
    Space.PostFX.RemoveCommandBufferFromCamera(commandbuffer)
end

```

### SetPostProfile

void SetPostProfile([SResource](/docs/scripting/client-scripting-api-reference/types/sresource.md) customProfile)

Set a custom Space Post-Processing Profile.

Parameters

| Name          | Type                                                                           | Default |
| ------------- | ------------------------------------------------------------------------------ | ------- |
| customProfile | [SResource](/docs/scripting/client-scripting-api-reference/types/sresource.md) | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetPostProfile(Space.Resources[1])

```

### ClearPostProfile

void ClearPostProfile()

Clear current Post-Processing profile and restore default one.

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.ClearPostProfile()

```

### SetCrepsecularRays

void SetCrepsecularRays(bool on, float thresR, float thresG, float thresB, float colorR, float colorG, float colorB, float falloff, float blurSize, int blurIterations, float intensity)

Parameters

| Name           | Type  | Default |
| -------------- | ----- | ------- |
| on             | bool  | –       |
| thresR         | float | –       |
| thresG         | float | –       |
| thresB         | float | –       |
| colorR         | float | –       |
| colorG         | float | –       |
| colorB         | float | –       |
| falloff        | float | –       |
| blurSize       | float | –       |
| blurIterations | int   | –       |
| intensity      | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetCrepsecularRays(true, 255.0, 0.0, 0.0, 0.0,0.0, 255.0, 1.0, 1.0, 2, 4.0)

```

### SetAmbientOcclusion

void SetAmbientOcclusion(bool on, float intensity, bool aoOnly)

Parameters

| Name      | Type  | Default |
| --------- | ----- | ------- |
| on        | bool  | –       |
| intensity | float | –       |
| aoOnly    | bool  | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetAmbientOcclusion(true, 4.0, true)

```

### SetMotionBlur

void SetMotionBlur(bool on, float shutterAngle)

Parameters

| Name         | Type  | Default |
| ------------ | ----- | ------- |
| on           | bool  | –       |
| shutterAngle | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetMotionBlur(true, 20.0)

```

### SetBloom

void SetBloom(bool on, float threshold, float intensity)

Parameters

| Name      | Type  | Default |
| --------- | ----- | ------- |
| on        | bool  | –       |
| threshold | float | –       |
| intensity | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetBloom(true, 2.0, 4.0)

```

### SetAnamorphicFlares

void SetAnamorphicFlares(bool on, float r, float g, float b, float intensity, float threshold, float spread, bool vertical)

Parameters

| Name      | Type  | Default |
| --------- | ----- | ------- |
| on        | bool  | –       |
| r         | float | –       |
| g         | float | –       |
| b         | float | –       |
| intensity | float | –       |
| threshold | float | –       |
| spread    | float | –       |
| vertical  | bool  | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetBloom(true, 255.0, 0.0, 0.0, 4.0, 2.0, 3.0, true)

```

### SetVignette

void SetVignette(bool on, float r, float g, float b, float intensity)

Parameters

| Name      | Type  | Default |
| --------- | ----- | ------- |
| on        | bool  | –       |
| r         | float | –       |
| g         | float | –       |
| b         | float | –       |
| intensity | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetVignette(true, 255.0, 0.0, 0.0, 4.0)

```

### SetLensDirt

void SetLensDirt(bool on, float threshold, SResource texture, float intensity)

Parameters

| Name      | Type      | Default |
| --------- | --------- | ------- |
| on        | bool      | –       |
| threshold | float     | –       |
| texture   | SResource | –       |
| intensity | float     | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetLensDirt(true, 4.0, Space.Resources[1], 4.0)

```

### SetChromaticAberrationPost

void SetChromaticAberrationPost(bool on, float strength, float cornerBlur)

Parameters

| Name       | Type  | Default |
| ---------- | ----- | ------- |
| on         | bool  | –       |
| strength   | float | –       |
| cornerBlur | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetChromaticAberrationPost(true, 4.0, 1.0)

```

### SetFocus

void SetFocus([SGameObject](/docs/scripting/client-scripting-api-reference/types/sgameobject.md) target)

Parameters

| Name   | Type                                                                               | Default |
| ------ | ---------------------------------------------------------------------------------- | ------- |
| target | [SGameObject](/docs/scripting/client-scripting-api-reference/types/sgameobject.md) | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetFocus(Space.Host.ExecutingObject)

```

### SupressFocus

void SupressFocus()

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SupressFocus()

```

### RestoreFocus

void RestoreFocus()

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.RestoreFocus()

```

### SetLookUpTable

void SetLookUpTable([SResource](/docs/scripting/client-scripting-api-reference/types/sresource.md) lut)

Parameters

| Name | Type                                                                           | Default |
| ---- | ------------------------------------------------------------------------------ | ------- |
| lut  | [SResource](/docs/scripting/client-scripting-api-reference/types/sresource.md) | –       |

Returns

`void`

Example

**Lua**

```lua
Space.PostFX.SetLookUpTable(Space.Resources[1])

```
