GenesisMaterial
GenesisMaterial is the C# wrapper around any Material that uses a Genesis shader. It exposes typed accessors for every shader property, keyword-aware feature toggles, and an internal MaterialPropertyBlock path that preserves SRP Batcher compatibility when you drive properties per-renderer.
using Genesis.Runtime;
// Wrap a renderer so writes route through a MaterialPropertyBlock
var gm = new GenesisMaterial(GetComponent<Renderer>());
gm.EnableFeature(GenesisFeature.Dissolve);
gm.SetFloat("_DissolveAmount", 0.5f);
gm.Apply();Construct from a Renderer whenever possible. Writes are buffered into a MaterialPropertyBlock, so the shared material is never instanced and the SRP Batcher keeps batching the renderer with its peers.
Constructors
Properties
Methods
Sub-APIs
GenesisMaterial exposes grouped helpers that wrap related properties with discoverable, typed methods:
| Property | Type | Covers |
|---|---|---|
Lighting | GenesisLighting | Cel, rim, specular, MatCap, Gooch. |
Stylization | GenesisStylization | Hue shift, posterize, color adjustments. |
Effects | GenesisEffects | Dissolve, hologram, hit flash, intersection glow. |
Animation | GenesisAnimation | Vertex and UV animation. |
Maps | GenesisMaps | Albedo, normal, detail, layer textures and UV. |
Examples
Color-flash a hit on a per-instance material
using Genesis.Runtime;
using UnityEngine;
public class HitFlash : MonoBehaviour
{
[SerializeField] Renderer target;
GenesisMaterial gm;
void Awake() => gm = new GenesisMaterial(target);
void OnDestroy() => gm.Dispose();
public void Flash(Color tint, float seconds = 0.15f)
=> gm.Effects.PlayHitFlash(tint, seconds);
}Fade dissolve over one second
public IEnumerator DissolveOut(GenesisMaterial gm, float duration = 1f)
{
gm.EnableFeature(GenesisFeature.Dissolve);
for (float t = 0f; t < duration; t += Time.deltaTime)
{
gm.SetFloat("_DissolveAmount", Mathf.Clamp01(t / duration));
gm.Apply();
yield return null;
}
gm.SetFloat("_DissolveAmount", 1f);
gm.Apply();
}Reading renderer.material anywhere instantiates the material and breaks batching for that renderer. GenesisMaterial avoids this — but watch other scripts on the same GameObject that may touch .material.
See also
- Lighting API
- Effects API
- Runtime Keywords
- Scripting Materials — task-oriented guide.