Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

texture.gradient (procNode)

A two-colour gradient texture, horizontal, vertical or radial: a Texture whose texels are drawn on the device, each one colour. Use it for a sky ramp, a fade, a vignette or a mask a material reads.

Inputs

  • width (Float, default 64, min 1): texels across. A vertical ramp repeats down every column, so 1 is enough width for one.
  • height (Float, default 64, min 1): texels down.
  • direction (String, default "vertical"): which way the ramp runs: "vertical" from the top row down to the bottom, "horizontal" from the left column across to the right, "radial" outward from the centre texel, reaching to at the corners, so the middle of each edge gets about seven tenths of the way there.
  • from (Vec4, default (0, 0, 0, 1)): the colour at the start of the ramp, as { r, g, b, a } in 0-1: the top row, the left column, or the centre. Alpha ramps with the colour, so fading it to 0 at one end gives a texture that fades out.
  • to (Vec4, default (1, 1, 1, 1)): the colour at the end of the ramp: the bottom row, the right column, or the far corners.

Outputs

  • texture (Texture): { width, height, format = "rgba32f", texels }, the texels one Vec4 per texel row by row from the top left.

g.texture.gradient(...) calls this node. In a graph built with proc.graph, g:node("<id>", "texture.gradient") names a different operation of the same name, which makes the pixels on the CPU.

Example

local sky = g.texture.gradient({ width = 1, height = 256, from = { 0.1, 0.2, 0.5, 1 }, to = { 0.8, 0.9, 1, 1 } })