GPU Particles

self:set_layer

Client

Draws this emitter only into a rendertarget instead of the main view

Syntax

local status = self:set_layer(
    rendertarget = nil
)

Only the rendertarget sees the emitter.

  • Rendertarget — the emitter is drawn into its own 3D view, which mirrors the main camera.
  • Main view — nil draws the emitter into the main view again.
  • Destroying — call self:set_layer() before destroying the rendertarget.

Parameters

TypeNameDescription
rendertargetrendertargetRendertarget that draws this emitter
Omitting this argument restores the main view

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Draw an emitter into a rendertarget only
local ring = particle.gpu.create()
local shader = core.shader.create("ring.gdshader", core.shader.shader_mode.SPATIAL)
local buffer = core.rendertarget.create({960, 540}, true, true)

ring:set_material(shader)
ring:set_layer(buffer) -- nothing is seen on screen, the ring pixels end up in `buffer`

On this page