Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

texture.from_shader (procNode)

A texture an author's .computeShader draws on the device, one invocation per texel. The shader writes texel i (row-major from the top left, x = i % width, y = i / width) of the one buffer it declares read_write with element vec4<f32>, and the texels stay on the device. Use it for any image a formula of its own draws.

The shader declares exactly one buffer it writes (access: read_write or write, with no count or capacity); the node allocates it under the binding's own name, and a shader declaring none or several is refused, naming how many it declares. width, height, count (the texel count), time and frame are filled into its params: when it declares them.

Inputs

  • shader (AssetRef<computeShader>): the shader that draws the texels, written asset.resolve("<identity>", "computeShader").
  • width (Float, default 256, min 1): texels across. A fraction is rounded down.
  • height (Float, default 256, min 1): texels down. A fraction is rounded down.
  • uniforms (Record, optional): values of the shader's params: block, by name: constant, animated or wired.

Outputs

  • texture (Texture): { width, height, format = "rgba32f", texels }.

Example

The built-in test fixture texture_gradient declares texels (access: read_write, element: vec4<f32>) and the params width, height and count, and draws red rising left to right and green top to bottom:

local texture = g.texture.from_shader({
    shader = asset.resolve("@builtin::tests.fixtures.texture_gradient", "computeShader"),
    width = 32,
    height = 32,
})