Expand description
Texture painting: blend several surface textures with a painted mask, so dirt can be brushed along a road edge and fade into grass without a hard seam.
A TexturePaint component names four layer textures and a mask. The mask is an RGBA image:
red, green and blue are the weights of layers 2, 3 and 4; whatever is left is layer 1. The
editor’s brush edits the mask in memory (PaintMaps) and saves it to assets/paint/<name>.png.
use kvas_engine::paint::{PaintMaps, BrushMode};
let maps = PaintMaps::global();
maps.create("doc-example", 32, 32);
maps.brush("doc-example", [0.5, 0.5], 0.2, 1.0, 0.5, BrushMode::Layer(1));
let (_, rgba, _) = maps.snapshot("doc-example").unwrap();
assert!(rgba[(16 * 32 + 16) * 4] > 200); // the red channel (layer 2) at the centreStructs§
- Paint
Map - One painted mask kept in memory.
- Paint
Maps - All painted masks of the running editor / game, by name.
- Texture
Paint - Four textures blended by a painted mask. Put it on an object with a mesh (a plane, a terrain chunk, a road strip). The component takes over the object’s material.
Enums§
- Brush
Mode - What the brush does.
Constants§
- PAINT_
PREFIX - Prefix of the mask texture keys the renderer understands (
paint:<name>#<version>). - SPLAT_
PREFIX - Prefix of the layer atlas keys (
splat:<a>|<b>|<c>|<d>).