# SPostFX

**成员** 17

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

## 函数

### CreateCommandBuffer

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

Return a new CommandBuffer.

返回值

`SCommandBuffer`

示例

**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/zh-Hans/scripting/client-scripting-api-reference/types/scommandbuffer.md) commandbuffer, int cameraEvent = 19)

Add the CommandBuffer to the Main Camera.

参数

| 名称          | 类型                                                                                             | 默认值 |
| ------------- | ------------------------------------------------------------------------------------------------ | ------ |
| commandbuffer | [SCommandBuffer](/docs/zh-Hans/scripting/client-scripting-api-reference/types/scommandbuffer.md) | –      |
| cameraEvent   | int                                                                                              | 19     |

返回值

`void`

示例

**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/zh-Hans/scripting/client-scripting-api-reference/types/scommandbuffer.md) commandbuffer, int cameraEvent = 19)

Remove the CommandBuffer from the Main Camera.

参数

| 名称          | 类型                                                                                             | 默认值 |
| ------------- | ------------------------------------------------------------------------------------------------ | ------ |
| commandbuffer | [SCommandBuffer](/docs/zh-Hans/scripting/client-scripting-api-reference/types/scommandbuffer.md) | –      |
| cameraEvent   | int                                                                                              | 19     |

返回值

`void`

示例

**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/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) customProfile)

Set a custom Space Post-Processing Profile.

参数

| 名称          | 类型                                                                                   | 默认值 |
| ------------- | -------------------------------------------------------------------------------------- | ------ |
| customProfile | [SResource](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) | –      |

返回值

`void`

示例

**Lua**

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

```

### ClearPostProfile

void ClearPostProfile()

Clear current Post-Processing profile and restore default one.

返回值

`void`

示例

**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)

参数

| 名称           | 类型  | 默认值 |
| -------------- | ----- | ------ |
| on             | bool  | –      |
| thresR         | float | –      |
| thresG         | float | –      |
| thresB         | float | –      |
| colorR         | float | –      |
| colorG         | float | –      |
| colorB         | float | –      |
| falloff        | float | –      |
| blurSize       | float | –      |
| blurIterations | int   | –      |
| intensity      | float | –      |

返回值

`void`

示例

**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)

参数

| 名称      | 类型  | 默认值 |
| --------- | ----- | ------ |
| on        | bool  | –      |
| intensity | float | –      |
| aoOnly    | bool  | –      |

返回值

`void`

示例

**Lua**

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

```

### SetMotionBlur

void SetMotionBlur(bool on, float shutterAngle)

参数

| 名称         | 类型  | 默认值 |
| ------------ | ----- | ------ |
| on           | bool  | –      |
| shutterAngle | float | –      |

返回值

`void`

示例

**Lua**

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

```

### SetBloom

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

参数

| 名称      | 类型  | 默认值 |
| --------- | ----- | ------ |
| on        | bool  | –      |
| threshold | float | –      |
| intensity | float | –      |

返回值

`void`

示例

**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)

参数

| 名称      | 类型  | 默认值 |
| --------- | ----- | ------ |
| on        | bool  | –      |
| r         | float | –      |
| g         | float | –      |
| b         | float | –      |
| intensity | float | –      |
| threshold | float | –      |
| spread    | float | –      |
| vertical  | bool  | –      |

返回值

`void`

示例

**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)

参数

| 名称      | 类型  | 默认值 |
| --------- | ----- | ------ |
| on        | bool  | –      |
| r         | float | –      |
| g         | float | –      |
| b         | float | –      |
| intensity | float | –      |

返回值

`void`

示例

**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)

参数

| 名称      | 类型      | 默认值 |
| --------- | --------- | ------ |
| on        | bool      | –      |
| threshold | float     | –      |
| texture   | SResource | –      |
| intensity | float     | –      |

返回值

`void`

示例

**Lua**

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

```

### SetChromaticAberrationPost

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

参数

| 名称       | 类型  | 默认值 |
| ---------- | ----- | ------ |
| on         | bool  | –      |
| strength   | float | –      |
| cornerBlur | float | –      |

返回值

`void`

示例

**Lua**

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

```

### SetFocus

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

参数

| 名称   | 类型                                                                                       | 默认值 |
| ------ | ------------------------------------------------------------------------------------------ | ------ |
| target | [SGameObject](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sgameobject.md) | –      |

返回值

`void`

示例

**Lua**

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

```

### SupressFocus

void SupressFocus()

返回值

`void`

示例

**Lua**

```lua
Space.PostFX.SupressFocus()

```

### RestoreFocus

void RestoreFocus()

返回值

`void`

示例

**Lua**

```lua
Space.PostFX.RestoreFocus()

```

### SetLookUpTable

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

参数

| 名称 | 类型                                                                                   | 默认值 |
| ---- | -------------------------------------------------------------------------------------- | ------ |
| lut  | [SResource](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) | –      |

返回值

`void`

示例

**Lua**

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

```
