Texture¶
In 3D data visualization, texture defines the mapping from a 3D element to colors or values.
Uniform texture¶
Uniform texture maps all 3D elements to the same value.
Image texture¶
Image texture maps a 3D element to color based on the UV coordinates and an image texture.
| Field | Type | Meaning |
|---|---|---|
filename |
PathLike | Path to the image file |
uv |
AttributeLike | None | UV attribute (auto-detected if None) |
raw |
bool | Treat texture as linear (no sRGB decode). Set True for normal maps and other non-color data. Default False. |
saturation |
float | Saturation multiplier. 1.0 = full color, 0.0 = grayscale. Default 1.0. |
whiteness |
float | Blend toward pure white. 0.0 = original color, 1.0 = pure white. Default 0.0. |
# Desaturate and brighten an image texture.
t = hkw.texture.Image(
filename="texture.png",
uv="uv_attr",
saturation=0.5,
whiteness=0.2,
)
Scalar field texture¶
One of the most common use case of texture is to map a scalar field to a color field.
| Field | Type | Meaning |
|---|---|---|
| data | AttributeLike | The attribute defining the scalar field |
| colormap | str | The colormap to use |
| domain | tuple | The domain of the attribute |
| range | tuple | The range of colormap |
| categories | bool | Whether the data represents categories (i.e. discrete values) |
See the Heat Method and the Components examples for application of the scalar field texture.
Checkerboard texture¶
CheckerBoard texture maps 3D elements to one of two possible sub-textures based on a checkerboard
pattern.
t = hkw.texture.CheckBoard(
uv="uv_attr_name",
texture1=hkw.texture.Uniform(color=0.2),
texture2=hkw.texture.Uniform(color=0.8),
)
Isocontour texture¶
Isocontour texture maps 3D elements to one of two possible sub-textures based on the iso-contour of
a given scalar field.
t = hkw.texture.Isocontour(
data="attr_name",
ratio=0.2,
texture1=hkw.texture.Uniform(color=0.2),
texture2=hkw.texture.Uniform(color=0.8),
)
See the Heat Method example for an application of the isocontour texture.