crackRefractUV

Where to sample one color channel so the crack bends the light and splits it like a prism.

crackRefractUV(
  displacedUV: v2f,
  edgeNormal: v2f,
  crackIntensity: number,
  refractionStrength: number,
  chromaticSplit: number,
  channel: number,
): v2f

Import effects from shaders/std and use effects.fracture.crackRefractUV.

channel is 1 for red, 0 for green and -1 for blue; the three samples land slightly apart. refractionStrength (0 to 10) bends the sample across the crack and chromaticSplit (0 to 5) spreads the channels. Both fade with crackIntensity, so unbroken glass is untouched.

Parameters

NameTypeNotes
args[displacedUV: v2f, edgeNormal: v2f, crackIntensity: number, refractionStrength: number, chromaticSplit: number, channel: number]

Example

const red = child.sample(call(crackRefractUV, 'crackRefractUV', [geom.member('displacedUV'), geom.member('edgeNormal'), geom.member('crackIntensity'), uniforms.refractionStrength, uniforms.chromaticSplit, floatE(1)]))

See also

  • crackGeom — How much crack there is at a pixel, and which way the shard under it has moved.
  • crackShardCompose — The finished glass: the three refracted channels blended into the crack, with a hint of light on tilted shards.

Used by

Shatter