RollingDistortMaterial
Have you ever seen images of an old malfunctioning TV? One that was corrupted in a way that
caused the image to distort as if a wave was scrolling across it in an endless loop, shoving
the picture around as it moved? That's what our RollingDistortMaterial
effectively does to your text.
RollingDistortMaterial extends Material, and therefore has the same
properties and functions as Material.
-
construction
import { RollingDistortMaterial } from "blotter.ts/materials"; const material = new RollingDistortMaterial(); -
uniforms
material.uniformsAn object that holds the uniforms that describe how the material's effects should be rendered. Each entry is a live
UniformInterface: assign to itsvalueand the running effect updates. You should not replace this property directly.-
uSineDistortSpread
material.uniforms.uSineDistortSpreadImagine a wave rolling across your text over time. The distance between the beginning and end of this wave takes up some percent of the total amount of visible text as it moves. The
uSineDistortSpreaduniform is used to describe this distance.-
value
material.uniforms.uSineDistortSpread.valueAny floating point value is acceptable, however you will likely want to keep this value
0.5and below. This value describes the distance (from0.0(0%) to1.0(100%)) your wave spans on a line running away from the center point, as described by theuDistortPositionuniform, along the axis perpendicular to the one described by theuRotationuniform. Therefore setting this value to anything above0.5will create distortions, as your wave will not have room to complete itself before beginning anew.The default value is
0.05. -
type
material.uniforms.uSineDistortSpread.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uSineDistortCycleCount
material.uniforms.uSineDistortCycleCountA counterpart to the above
uSineDistortSpread, this uniform describes the number of wave cycles (crests and troughs) that should occur within the space defined byuSineDistortSpread.-
value
material.uniforms.uSineDistortCycleCount.valueAny floating point value is acceptable. Setting this value to
1.0would create a single arching wave: just a crest with no trough. Setting this value to2.0would create a full wave cycle: a crest and a trough. Play around, you'll get the idea.Note that you don't have to use whole numbers here; using partial numbers (e.g.
3.5) creates interesting artifacts you might enjoy.The default value is
2. -
type
material.uniforms.uSineDistortCycleCount.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uSineDistortAmplitude
material.uniforms.uSineDistortAmplitudeA counterpart to the above
uSineDistortCycleCountanduSineDistortSpread, this uniform describes the amplitude of the crests and troughs determined byuSineDistortCycleCount.-
value
material.uniforms.uSineDistortAmplitude.valueAny floating point value is acceptable. When distortion on your text rotates, imagine a virtual line running from the position described by the
uDistortPositionuniform and at the degrees described by theuRotationuniform. The wave distortion amplitude described by theuSineDistortAmplitudeuniform is relative to this distance (from0.0(0%) to1.0(100%)).The default value is
0.25. -
type
material.uniforms.uSineDistortAmplitude.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uNoiseDistortVolatility
material.uniforms.uNoiseDistortVolatilityApart from the main sine wave distortion,
RollingDistortMaterialalso provides a way to define a more consistent and noisy distortion to your text. Because this distortion lacks any specific position or spread, theuNoiseDistortVolatilityuniform is more concerned with an overall volatility your text will experience, or the rate at which variation occurs along the distortion axis (seeuRotation).-
value
material.uniforms.uNoiseDistortVolatility.valueAny floating point value is acceptable. Higher values equate to a higher volatility. As always, play with the values here until you find the effect you like.
The default value is
20. -
type
material.uniforms.uNoiseDistortVolatility.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uNoiseDistortAmplitude
material.uniforms.uNoiseDistortAmplitudeThe
uNoiseDistortAmplitudeuniform describes the amplitude of the crests and troughs of the noise based distortion determined byuNoiseDistortVolatility.-
value
material.uniforms.uNoiseDistortAmplitude.valueAny floating point value is acceptable. When distortion on your text rotates, imagine a virtual line running from the position described by the
uDistortPositionuniform and at the degrees described by theuRotationuniform. The noise distortion amplitude described by theuNoiseDistortAmplitudeuniform is relative to this distance (from0.0(0%) to1.0(100%)).The default value is
0.01. -
type
material.uniforms.uNoiseDistortAmplitude.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uDistortPosition
material.uniforms.uDistortPositionWhen imagining a wave moving across your text, you likely imagine it moving along some axis. For example, you may imagine the wave moving along a vertical line, from the top to the bottom of your text. As the wave travelled along this line, its Y position would change. The uniform
uDistortPositionis used to describe the center position of your wave and the noise distortion applied to your text.Note that when the distortion is animating, as described by the
uSpeeduniform, the animation occurs along a line running through the position described by theuDistortPositionuniform, at an angle perpendicular to the angle described by theuRotationuniform.-
value
material.uniforms.uDistortPosition.valueA pair of floating point values between
0.0(0%) and1.0(100%), relative to the width and height of your text respectively (including any padding and line height).The default value is
[0.5, 0.5]. -
type
material.uniforms.uDistortPosition.typeThe uniform type of the value being passed to the shader.
"2f"means the value is a pair of floating point values, passed in the form of an array (e.g.[0.5, 0.5]). You should not change this property.
-
-
uRotation
material.uniforms.uRotationThe
uRotationuniform describes the rotation, in degrees, of all distortion applied to your text. For example, if you apply a wave distortion to your text the amplitude of that wave, described by theuSineDistortAmplitudeuniform, would rise and fall along the angle at these degrees.Note that when the distortion is animating, as described by the
uSpeeduniform, the animation occurs along a line running through the position described by theuDistortPositionuniform, at an angle perpendicular to the angle described by theuRotationuniform.-
value
material.uniforms.uRotation.valueA floating point value between
0.0and360.0.The default value is
170. -
type
material.uniforms.uRotation.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-
uSpeed
material.uniforms.uSpeedThe
uSpeeduniform describes the speed of the animation applied to the distortion on your text.Note that when the distortion is animating, as described by the
uSpeeduniform, the animation occurs along a line running through the position described by theuDistortPositionuniform, at an angle perpendicular to the angle described by theuRotationuniform.-
value
material.uniforms.uSpeed.valueAny floating point value is acceptable, however you will likely want to keep this value below
1.0. This value acts as a multiplier against the default uniform passed to all effects,uGlobalTime, which represents the time in seconds since the effect started. Therefore, smaller values slow animation while higher values speed up animation. Play around, you'll get the idea.The default value is
0.08. -
type
material.uniforms.uSpeed.typeThe uniform type of the value being passed to the shader.
"1f"means the value is a single float (e.g.0.5). You should not change this property.
-
-