GPU Particles

self:set_material

Client

Sets the material particles are drawn with

Syntax

local status = self:set_material(
    material
)

Textures keep the built-in material behavior.

  • Image, SVG, rendertarget or path — billboard, blend mode, unshaded and the particle color keep working.
  • Shader — replaces the built-in material, draw the particles however you like.

Parameters

TypeNameDescription
string | image | svg | rendertarget | shadermaterialMaterial to apply:
• string - file path to an image asset
• image - pre-loaded image instance
• svg - svg instance
• rendertarget - rendertarget instance
• shader - spatial shader instance

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Draw particles with a texture
local entity = particle.gpu.create()

entity:set_material("assets/spark.png")
Draw particles with a shader
local entity = particle.gpu.create()
local shader = core.shader.create("assets/shaders/flower.glsl", core.shader.shader_mode.SPATIAL)

entity:set_material(shader)

On this page