Circle Image

Pixaflux

Sprite It

Sprite It is a development platform for PixaFlux. It features a Lua SDK that allows developers to write scripts that generate sprites. These sprites are later rendered by the Sprite It node in Pixaflux.

  1. Introduction
  2. Context
  3. Sprite
  4. Attributes
  5. Node Graph
  6. Lua Modules
  7. Materials
  8. Sprite It Executable
  9. Samples
  10. Troubleshooting
  11. Tutorial
  12. C++ SDK

Lua

The Sprite It node executes the Lua scripts in LuaJIT, A Just-In-Time Compiler (JIT) for the Lua programming language. Lua is a powerful, dynamic and light-weight programming language.

Sample script:

Sprite

One_Sprite.lua

-- Load required Sprite It libraries.

vector2 = require("vector2")
matrix2 = require("matrix2")
box2 = require("box2")
rgbo = require("rgbo")
spriteIt = require("spriteIt")

-- Define Parameters

offset = vector2(0.25, 0.2)
rotation = 15
scale = vector2(0.4, 0.2)

tm = matrix2()
tm:set(offset, math.rad(rotation), scale)

shape = "brick"
index = 4
parameters = {0.5, 0.5, 0.0, 0.0}
modifiers = {0.0, 0.0, 0.0, 0.0}
values = {1.0}
mask = {0.0, 0.0, 0.0, 0.0}
hsloVariation = {0.0, 0.0, 0.0, 0.0}

-- Define Sprite Context

spriteContext = spriteIt.newContext()
spriteContext.images = {"image"}
spriteContext.channels = {image = {1}}
spriteContext.values = {0.0}
spriteContext.blend = "add"
spriteContext.seamless = false

-- Push new sprite

shapeIndex = spriteIt.getShapeIndex(shape)

spriteContext:pushSprite(0, 0, tm, shapeIndex, index, parameters, modifiers, values, mask, hsloVariation)

Sprite It node

The Lua scripts are evaluated by the Sprite It node in PixaFlux in two passes. First to collect all outputs and attributes that the script defines, and then to evaluate the script that generates the sprites, and to collect the sprites to be rendered.

The sprites are later sorted and arranged by the Sprite It node, and rendered in the GPU by a Vulkan program.

Image Area

This is the area that is rendered by the Sprite It node. The lower left corner is (-0.5, -0.5), and the upper right corner is (0.5, 0.5).

Sprite

The sprites are positioned and sized in this space.

Sprite

A sprite is a quad that is rendered in the image area. It has the following properties:

All these properties define the position, texture and colors of the sprite.

See Sprite for more information about sprites.

Sprite Context

The Context is a structure that defines the properties of how the sprites are rendered to the final image.

Sprite It programs can be configured to render multiple images with the same sprites to generate material type files. It can also be configured to generate material outputs from material inputs.

Node Graph

The Sprite It module defines a set of nodes that can be instanced and connected into graphs. These nodes have a set of parameters that define how they behave when the graph is evaluated. These parameters can be functions that evaluate the value of the parameters at runtime using the state of the graph.

Executable

PixaFlux includes a command line executable that can be used to debug the Lua scripts when developing new texture generators, or to render new images from an existing script.