Skip to main content

Input & Stroke Methods

Simple Painter separates input detection (which device starts a stroke) from stroke shaping (which rays become stamps), so you can mix and match any input device with any stroke method.

Input devices

All input sources share an InputConfig/InputReader pair and feed the same stamp pipeline through IPaintContext. Engagement is device-native — each reader decides for itself when a stroke begins, updates and ends.

DeviceTriggerNotes
MouseConfigurable paint button (default left click)Always reports full pressure; optional live hover-preview of the brush footprint
PenStylus tip contactReads genuine analog pressure from the hardware
TouchPrimary touch contactSingle-touch (one active pointer)
CollisionPhysics collision enter / stay / exitMin & max impact-speed thresholds, with an impact-speed → pressure response curve
ParticleParticle-system collision, or a per-frame sweepCollision mode paints where particles land; Pierce mode paints every surface a particle flies through, with per-crossing pressure falloff
ObjectNone — samples a transform every frame (or on demand)No ray cast at all: the transform's pose is the stamp, sized by its scale. Good for rollers, rubber stamps, carried decals

Mouse, Pen and Touch share a common screen-ray base with configurable camera, paint layer mask, max ray distance, and an option to ignore strokes that start over UI. Every stamp also carries an alignment — either Surface (flush against the mesh normal) or View (billboarded to face the camera) — selectable per stroke asset.

Stroke methods

An optional stroke preset decides which rays become stamps — only screen-based devices offer the slot; leave it empty and every ray simply stamps where it lands, once per frame. Every method shares raycasting, per-stroke random seeding, and a smoothed drag-speed tracker.

MethodBehaviourEmits
DirectThe default when no preset is assigned: deposits a stamp at the raw cursor position every updateContinuous trail
Drag DotRe-stamps at the live cursor position every update until releaseFollowing dab
LineRebuilds an evenly spaced straight line from the press anchor to the live cursor each frameRubber-band line
BezierFits a quadratic Bezier curve through a sliding 3-ray window and tessellates it into evenly spaced stampsSmoothed curve trail
AnchoredPins one decal at the press point and grows/rotates it as the cursor drags awayResizable decal

Line and Bezier both support additional spacing, jitter (randomised stamp position) and dash patterns. Every stamp shape also exposes Size and Rotation as dynamic parameters.

Dynamic parameters

Size, Rotation, Opacity, Jitter and other values are driven by a shared StrokeParameter evaluator. Each can be a flat constant, or vary by one of six modes — remapped through an animation curve and clamped to a min/max range:

ModeDriven by
PressurePen/mouse/collision pressure
DistanceDistance travelled along the stroke
SpeedSmoothed drag speed
TimeElapsed stroke time
DirectionThe stroke's heading — the 3D brush travel direction in the stamp plane
RandomPer-stamp random value (seeded per stroke)

This is what powers pressure-sensitive width, speed-based thinning, direction-aligned stamps, or randomised scatter brushes.

Hot-swapping at runtime

The input asset assigned to a PaintTool can be swapped live, carrying its stroke preset along with it, so a single Tool GameObject can flip devices without re-wiring components:

paintTool.SwitchInput(penInputConfig);
paintTool.SwitchPaint(fillMeshConfig);

Next: Draw Config & Ink