Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

texture.cells (procNode)

One point per texel of a width by height image, row by row from the top left, each carrying its column as x and its row as y. The texture nodes write a colour onto these points and hand the colour column on as the image's texels; an author building a texture of their own does the same.

The points are the cells of a grid.box one texel deep (width by height by 1 cells, centred on the origin), so point i is the texel at column i % width and row floor(i / width).

Inputs

  • width (Float, default 64, min 1): texels across. Below 1 reads as 1; a fraction is rounded down.
  • height (Float, default 64, min 1): texels down. Below 1 reads as 1; a fraction is rounded down.

Outputs

A call answers a record by output name.

  • cells (Grid): the texel points, carrying x (the column) and y (the row) as Floats.
  • width (Float): the width as read, a whole number at least 1.
  • height (Float): the height as read, a whole number at least 1.

Example

local image = g.texture.cells({ width = 32, height = 16 })
local cells = image.cells
cells.point.texel = g.math.vec4(cells.point.x / image.width, cells.point.y / image.height, 0, 1)
local texture = { width = image.width, height = image.height, format = "rgba32f", texels = cells.point.texel }