Skip to Content
DocumentationScripting APILighting API

GenesisLighting

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

GenesisLighting groups the toon and stylized lighting controls of a Genesis material — cel banding, Fresnel rim, specular models, MatCap, and Gooch warm/cool shading. You never construct it directly; reach it through GenesisMaterial.Lighting.

using Genesis.Runtime; var gm = new GenesisMaterial(GetComponent<Renderer>()); gm.Lighting.SetCelMode(GenesisCelMode.Stepped); gm.Lighting.SetCelSteps(4); gm.Lighting.EnableRim(Color.cyan, 1.5f); gm.Apply();

Setters here buffer into the same MaterialPropertyBlock as the owning GenesisMaterial. Mutate as many properties as you like, then call gm.Apply() once per frame to commit them.

Properties

CelThreshold
property
public float CelThreshold { get; set; }

Position of the shadow edge along NdotL, 01. Used by Cel Shading in Single mode. Maps to _CelThreshold.

Returns float

ShadowColor
property
public Color ShadowColor { get; set; }

Tint multiplied into the cel shadow band. Maps to _CelShadowColor.

Returns Color

RimPower
property
public float RimPower { get; set; }

Fresnel exponent for Rim Lighting, 0.116. Higher values give a thinner rim. Maps to _RimPower.

Returns float

MatCapIntensity
property
public float MatCapIntensity { get; set; }

Overall blend strength of the MatCap layer, 01. Maps to _MatCapIntensity.

Returns float

Methods

SetCelMode(GenesisCelMode)
method
public void SetCelMode(GenesisCelMode mode)

Selects the cel band model — Single, Stepped, or Ramp. Enables the GENESIS_CEL_SHADING keyword if needed. See Cel Shading.

Parameters

NameTypeDescription
modeGenesisCelModeSingle (one hard edge), Stepped (N even bands), or Ramp (1D ramp texture).

Returns void

SetCelSteps(int)
method
public void SetCelSteps(int steps)

Sets the number of light bands used in Stepped mode. Maps to _CelSteps.

Parameters

NameTypeDescription
stepsintNumber of bands, clamped to 1–8. Three is the most common.

Returns void

SetCelRamp(Texture2D)
method
public void SetCelRamp(Texture2D ramp)

Assigns the 1D ramp sampled by NdotL in Ramp mode and switches the cel mode to Ramp. Maps to _CelRamp.

Parameters

NameTypeDescription
rampTexture2DHorizontal 1D ramp authored with the Ramp Creator. Use clamp wrap.

Returns void

EnableRim(Color, float)
method
public void EnableRim(Color color, float intensity = 1f)

Enables Fresnel rim lighting and sets its color and intensity in one call. Turns on the GENESIS_RIM keyword. See Rim Lighting.

Parameters

NameTypeDescription
colorColorRim tint. Pass an HDR color (intensity > 1) for bloom-driven edges.
intensityfloatOverall multiplier, 0–8. Defaults to 1.

Returns void

SetSpecularModel(GenesisSpecularModel)
method
public void SetSpecularModel(GenesisSpecularModel model)

Chooses the specular lobe model — GGX, BlinnPhong, Stylized, or Anisotropic. Maps to _SpecularModel. See Specular.

Parameters

NameTypeDescription
modelGenesisSpecularModelThe highlight model to evaluate.

Returns void

SetMatCap(Texture2D, GenesisBlendMode)
method
public void SetMatCap(Texture2D matcap, GenesisBlendMode blend = GenesisBlendMode.Multiply)

Assigns a MatCap sphere texture and its blend mode, enabling the GENESIS_MATCAP keyword. See MatCap.

Parameters

NameTypeDescription
matcapTexture2DPre-shaded sphere image. Use clamp wrap; mips are unnecessary.
blendGenesisBlendModeMultiply, Add, Replace, or Screen. Defaults to Multiply.

Returns void

SetGooch(Color, Color, float)
method
public void SetGooch(Color warm, Color cool, float blend = 1f)

Enables Gooch Shading and sets the warm/cool tints and overall blend against the base diffuse model.

Parameters

NameTypeDescription
warmColorTint applied to lit surfaces. Maps to _GoochWarm.
coolColorTint applied to shaded surfaces. Maps to _GoochCool.
blendfloatMix between Gooch and the base diffuse model, 0–1. Defaults to 1.

Returns void

Examples

Build a full toon lighting stack

using Genesis.Runtime; using UnityEngine; public class ToonSetup : MonoBehaviour { [SerializeField] Renderer target; GenesisMaterial gm; void Start() { gm = new GenesisMaterial(target); gm.Lighting.SetCelMode(GenesisCelMode.Stepped); gm.Lighting.SetCelSteps(3); gm.Lighting.ShadowColor = new Color(0.18f, 0.20f, 0.28f); gm.Lighting.EnableRim(Color.white, 1.2f); gm.Lighting.SetSpecularModel(GenesisSpecularModel.Stylized); gm.Apply(); } void OnDestroy() => gm.Dispose(); }

SetCelMode, EnableRim, and SetMatCap toggle shader keywords, which can stall the first time an uncompiled variant renders. Prewarm the variants you switch into at runtime — see Runtime Keywords.

See also

Last updated on