Skip to Content
DocumentationScripting APIAnimation API

GenesisAnimation

Namespace: Genesis.Runtime · Assembly: Genesis.Runtime.dll · Inherits: System.Object

GenesisAnimation controls the shader-driven motion of a Genesis material — vertex animation modes (wind, wave, jelly, …) and UV animation (scroll, wave, distortion). It is accessed through GenesisMaterial.Animation; all motion runs on the GPU from _Time, so there is no per-frame CPU cost once configured.

using Genesis.Runtime; var gm = new GenesisMaterial(GetComponent<Renderer>()); gm.Animation.SetVertexAnimation(GenesisVertexAnim.Wind); gm.Animation.SetUVScroll(new Vector2(0.1f, 0f)); gm.Apply();

Because animation is time-based on the GPU, you typically configure it once and never touch it again. Use VertexAnimPhase from a per-instance MaterialPropertyBlock to de-sync a crowd of identical meshes without breaking batching.

Properties

VertexAnimSpeed
property
public float VertexAnimSpeed { get; set; }

Playback speed of the active vertex animation mode. Maps to _VertexAnimSpeed.

Returns float

VertexAnimStrength
property
public float VertexAnimStrength { get; set; }

Displacement amplitude of the vertex animation. Maps to _VertexAnimStrength.

Returns float

VertexAnimPhase
property
public float VertexAnimPhase { get; set; }

Per-instance phase offset, 01. Randomize per renderer to de-sync identical meshes. Maps to _VertexAnimPhase.

Returns float

UVScrollSpeed
property
public Vector2 UVScrollSpeed { get; set; }

Scroll velocity in UV space; x = U, y = V. Maps to the xy of _UVScrollSpeed. See UV Animation.

Returns Vector2

Methods

SetVertexAnimation(GenesisVertexAnim)
method
public void SetVertexAnimation(GenesisVertexAnim mode)

Selects the vertex animation mode and enables the GENESIS_VERTEX_ANIMATION keyword. Pass Off to disable. See Vertex Animation.

Parameters

NameTypeDescription
modeGenesisVertexAnimOff, Wind, Pulse, Wave, Bounce, Wobble, Jelly, Ripple, Twist, Squash, Bend, Sway, Vibrate, Flow, Wiggle, Breathe, or Shake.

Returns void

SetVertexAnimDirection(Vector3)
method
public void SetVertexAnimDirection(Vector3 direction)

Sets the axis or seed direction used by the active vertex mode. Maps to the xyz of _VertexAnimDirection.

Parameters

NameTypeDescription
directionVector3Mode-dependent axis or seed, e.g. (0,1,0) for upward wind.

Returns void

SetUVMode(GenesisUVAnim)
method
public void SetUVMode(GenesisUVAnim mode)

Selects the UV animation mode and enables the GENESIS_UV_ANIMATION keyword. See UV Animation.

Parameters

NameTypeDescription
modeGenesisUVAnimOff, Scroll, Wave, Distortion, Pixelate, Stutter, or HandDrawn.

Returns void

SetUVScroll(Vector2)
method
public void SetUVScroll(Vector2 speed)

Switches to Scroll mode and sets the UV scroll velocity. Maps to _UVScrollSpeed.

Parameters

NameTypeDescription
speedVector2Scroll velocity per second; x = U, y = V.

Returns void

SetUVWave(float, float)
method
public void SetUVWave(float amplitude, float frequency)

Switches to Wave mode and sets the sine displacement of the UVs.

Parameters

NameTypeDescription
amplitudefloatWave displacement strength, 0–1. Maps to _UVWaveAmplitude.
frequencyfloatWave density, 0–32. Maps to _UVWaveFrequency.

Returns void

SetUVDistortion(Texture2D, float)
method
public void SetUVDistortion(Texture2D map, float strength)

Switches to Distortion mode, using the RG channels of a map as a per-pixel UV offset.

Parameters

NameTypeDescription
mapTexture2DDistortion map; RG channels drive the offset. Maps to _UVDistortionMap.
strengthfloatMultiplier on the distortion offset, 0–1. Maps to _UVDistortionStrength.

Returns void

Examples

Animate foliage with de-synced wind

using Genesis.Runtime; using UnityEngine; public class Foliage : MonoBehaviour { [SerializeField] Renderer target; void Start() { var gm = new GenesisMaterial(target); gm.Animation.SetVertexAnimation(GenesisVertexAnim.Wind); gm.Animation.SetVertexAnimDirection(Vector3.up); gm.Animation.VertexAnimStrength = 0.3f; gm.Animation.VertexAnimPhase = Random.value; // de-sync this instance gm.Apply(); gm.Dispose(); } }

Scroll a conveyor belt texture

public void StartBelt(GenesisMaterial gm, float speed) { gm.Animation.SetUVScroll(new Vector2(speed, 0f)); gm.Apply(); }

Setting VertexAnimPhase (or any per-instance property) directly on a shared material instances it and breaks the SRP Batcher. Always drive per-instance offsets through a GenesisMaterial(Renderer), which routes them through a MaterialPropertyBlock.

See also

Last updated on