Cauldron3D.Paint.Rgba (Cauldron3D v0.2.2)

Copy Markdown View Source

The paints of Cauldron3D.Paint in RGBA, four bytes a pixel, for a picture drawn in full colour (Cauldron3D.Render.draw/3 with :palette).

An indexed texture's colours come from its own palette, or the picture's. Light 128 is a texture's own colours; light scales red, green and blue alike, or each by its own amount where a paint gives {r, g, b} light. A texel of the setup's clear index is alpha 0, which the overlays leave out. A surface is an RGBA texture already lit.

A setup with a tint has each pixel's colour and alpha multiplied by it; where it also has an alpha_test, a pixel whose own alpha is below the test is alpha 0 first.

{:warp, ...}'s :amplitude and :wavelength may each be {s, t}: the move along s (by the sine of t) and the move along t (by the sine of s).

Besides Cauldron3D.Paint's paints:

  • {:skybox, faces} — a sky at no distance from six RGBA textures, faces a map with :front (looking along +x), :back, :left (+y), :right, :up (+z) and :down, each seen from inside the box with up toward +z (:up and :down with their top toward +x)
  • {:lit, paint, lighting} — paint (with the setup's tint) and, added to it, the light of each of lighting.lights (%{origin:, radius:, colour: {r, g, b}}, and for a spot light fov: in degrees with axes: {forward, right, up}) on a flat surface of normal lighting.normal: at the pixel's place p in a perspective view, with l the light's origin less p, each channel of the texel of lighting.texture at the paint's place plus lighting.offset (alpha 0 where it is colour lighting.clear) times max(normal · l / |l|, 0) * max(1 - |l|² / radius², 0) (times 1 - x² - y² for a spot, x and y being p's place across and up the light's view over its distance along forward times tan(fov / 2), and nothing behind it) times the colour times the texel's alpha, each light's share held at 0 or above

Summary

Functions

A colour, a palette index or {r, g, b}, as RGBA bytes in context's palette.

The RGBA bytes of pixels first up to stop of row y, each multiplied by the setup's tint there when it has one.

Functions

flat(index, context)

@spec flat(byte() | {byte(), byte(), byte()}, map()) :: binary()

A colour, a palette index or {r, g, b}, as RGBA bytes in context's palette.

span(paint, setup, first, stop, y, context)

@spec span(term(), Cauldron3D.Setup.t(), integer(), integer(), integer(), map()) ::
  binary()

The RGBA bytes of pixels first up to stop of row y, each multiplied by the setup's tint there when it has one.