The cursor channel of the rain pass is now propagated in isolation to the effect passes.

This commit is contained in:
Rezmason
2022-09-15 23:33:47 -07:00
parent 17a615eec7
commit 6969514c9b
9 changed files with 48 additions and 33 deletions

View File

@@ -1,12 +1,6 @@
TODO: TODO:
Reformulate the basis Migrate recoded changes to WebGPU
Separate cursor and non-cursor parts of the code into rain pass output channels
Downstream passes can add them or color them separately
Add cursorColor to config
Switch operator/resurrections/classic to this
Tune ALL the versions!
Migrate to WebGPU
Update the README Update the README

View File

@@ -55,7 +55,8 @@ const defaults = {
font: "matrixcode", font: "matrixcode",
useCamera: false, useCamera: false,
backgroundColor: [0, 0, 0], // The color "behind" the glyphs backgroundColor: [0, 0, 0], // The color "behind" the glyphs
cursorBrightness: 0, // The brightness of the "cursor" at the bottom of a raindrop isolateCursor: true, // Whether the "cursor"— the brightest glyph at the bottom of a raindrop— has its own color
cursorColor: [1.5, 2, 0.9], // The color of the cursor
volumetric: false, // A mode where the raindrops appear in perspective volumetric: false, // A mode where the raindrops appear in perspective
animationSpeed: 1, // The global rate that all animations progress animationSpeed: 1, // The global rate that all animations progress
forwardSpeed: 0.25, // The speed volumetric rain approaches the eye forwardSpeed: 0.25, // The speed volumetric rain approaches the eye
@@ -107,7 +108,7 @@ const versions = {
width: 40, width: 40,
}, },
operator: { operator: {
cursorBrightness: 1, cursorColor: [1.0, 3, 1.5],
bloomSize: 0.6, bloomSize: 0.6,
bloomStrength: 0.75, bloomStrength: 0.75,
highPassThreshold: 0.0, highPassThreshold: 0.0,
@@ -129,6 +130,7 @@ const versions = {
}, },
nightmare: { nightmare: {
font: "gothic", font: "gothic",
isolateCursor: false,
highPassThreshold: 0.7, highPassThreshold: 0.7,
baseBrightness: -0.8, baseBrightness: -0.8,
brightnessDecay: 0.75, brightnessDecay: 0.75,
@@ -148,6 +150,7 @@ const versions = {
}, },
paradise: { paradise: {
font: "coptic", font: "coptic",
isolateCursor: false,
bloomStrength: 1, bloomStrength: 1,
highPassThreshold: 0, highPassThreshold: 0,
cycleSpeed: 0.005, cycleSpeed: 0.005,
@@ -171,7 +174,7 @@ const versions = {
resurrections: { resurrections: {
font: "resurrections", font: "resurrections",
glyphEdgeCrop: 0.1, glyphEdgeCrop: 0.1,
cursorBrightness: 1, cursorColor: [1.4, 2, 1.2],
baseBrightness: -0.7, baseBrightness: -0.7,
baseContrast: 1.17, baseContrast: 1.17,
highPassThreshold: 0, highPassThreshold: 0,
@@ -180,13 +183,14 @@ const versions = {
bloomStrength: 0.7, bloomStrength: 0.7,
fallSpeed: 0.3, fallSpeed: 0.3,
paletteEntries: [ paletteEntries: [
{ hsl: [0.38, 0.9, 0.0], at: 0.0 }, { hsl: [0.375, 0.9, 0.0], at: 0.0 },
{ hsl: [0.38, 1.0, 0.6], at: 0.92 }, { hsl: [0.375, 1.0, 0.6], at: 0.92 },
{ hsl: [0.38, 1.0, 1.0], at: 1.0 }, { hsl: [0.375, 1.0, 1.0], at: 1.0 },
], ],
}, },
palimpsest: { palimpsest: {
font: "huberfishA", font: "huberfishA",
isolateCursor: false,
bloomStrength: 0.2, bloomStrength: 0.2,
numColumns: 40, numColumns: 40,
raindropLength: 1.2, raindropLength: 1.2,
@@ -200,7 +204,8 @@ const versions = {
}, },
twilight: { twilight: {
font: "huberfishD", font: "huberfishD",
bloomStrength: 0.3, cursorColor: [1.5, 1, 0.9],
bloomStrength: 0.1,
numColumns: 50, numColumns: 50,
raindropLength: 0.9, raindropLength: 0.9,
fallSpeed: 0.1, fallSpeed: 0.1,
@@ -210,7 +215,7 @@ const versions = {
{ hsl: [0.6, 0.8, 0.1], at: 0.1 }, { hsl: [0.6, 0.8, 0.1], at: 0.1 },
{ hsl: [0.88, 0.8, 0.5], at: 0.5 }, { hsl: [0.88, 0.8, 0.5], at: 0.5 },
{ hsl: [0.15, 1.0, 0.6], at: 0.8 }, { hsl: [0.15, 1.0, 0.6], at: 0.8 },
{ hsl: [0.1, 1.0, 0.9], at: 1.0 }, // { hsl: [0.1, 1.0, 0.9], at: 1.0 },
], ],
}, },
@@ -297,6 +302,7 @@ const paramMapping = {
url: { key: "bgURL", parser: (s) => s }, url: { key: "bgURL", parser: (s) => s },
stripeColors: { key: "stripeColors", parser: (s) => s }, stripeColors: { key: "stripeColors", parser: (s) => s },
backgroundColor: { key: "backgroundColor", parser: (s) => s.split(",").map(parseFloat) }, backgroundColor: { key: "backgroundColor", parser: (s) => s.split(",").map(parseFloat) },
cursorColor: { key: "cursorColor", parser: (s) => s.split(",").map(parseFloat) },
volumetric: { key: "volumetric", parser: (s) => s.toLowerCase().includes("true") }, volumetric: { key: "volumetric", parser: (s) => s.toLowerCase().includes("true") },
loops: { key: "loops", parser: (s) => s.toLowerCase().includes("true") }, loops: { key: "loops", parser: (s) => s.toLowerCase().includes("true") },
renderer: { key: "renderer", parser: (s) => s }, renderer: { key: "renderer", parser: (s) => s },

View File

@@ -65,7 +65,7 @@ const makePalette = (regl, entries) => {
export default ({ regl, config }, inputs) => { export default ({ regl, config }, inputs) => {
const output = makePassFBO(regl, config.useHalfFloat); const output = makePassFBO(regl, config.useHalfFloat);
const palette = makePalette(regl, config.paletteEntries); const palette = makePalette(regl, config.paletteEntries);
const { backgroundColor, ditherMagnitude, bloomStrength } = config; const { backgroundColor, cursorColor, ditherMagnitude, bloomStrength } = config;
const palettePassFrag = loadText("shaders/glsl/palettePass.frag.glsl"); const palettePassFrag = loadText("shaders/glsl/palettePass.frag.glsl");
@@ -74,6 +74,7 @@ export default ({ regl, config }, inputs) => {
uniforms: { uniforms: {
backgroundColor, backgroundColor,
cursorColor,
ditherMagnitude, ditherMagnitude,
bloomStrength, bloomStrength,
tex: inputs.primary, tex: inputs.primary,

View File

@@ -130,7 +130,7 @@ export default ({ regl, config, lkg }) => {
"baseContrast", "baseContrast",
"brightnessThreshold", "brightnessThreshold",
"brightnessOverride", "brightnessOverride",
"cursorBrightness", "isolateCursor",
"glyphEdgeCrop", "glyphEdgeCrop",
"isPolar", "isPolar",
]), ]),

View File

@@ -31,7 +31,7 @@ const prideStripeColors = [
export default ({ regl, config }, inputs) => { export default ({ regl, config }, inputs) => {
const output = makePassFBO(regl, config.useHalfFloat); const output = makePassFBO(regl, config.useHalfFloat);
const { backgroundColor, ditherMagnitude, bloomStrength } = config; const { backgroundColor, cursorColor, ditherMagnitude, bloomStrength } = config;
// Expand and convert stripe colors into 1D texture data // Expand and convert stripe colors into 1D texture data
const stripeColors = const stripeColors =
@@ -49,6 +49,7 @@ export default ({ regl, config }, inputs) => {
uniforms: { uniforms: {
backgroundColor, backgroundColor,
cursorColor,
ditherMagnitude, ditherMagnitude,
bloomStrength, bloomStrength,
tex: inputs.primary, tex: inputs.primary,

View File

@@ -15,7 +15,7 @@ void main() {
vec3 bgColor = texture2D(backgroundTex, vUV).rgb; vec3 bgColor = texture2D(backgroundTex, vUV).rgb;
// Combine the texture and bloom, then blow it out to reveal more of the image // Combine the texture and bloom, then blow it out to reveal more of the image
float brightness = pow(getBrightness(vUV).r, 1.5); vec4 brightness = getBrightness(vUV);
gl_FragColor = vec4(bgColor * brightness, 1.0); gl_FragColor = vec4(bgColor * (brightness.r + brightness.g * 2.0), 1.0);
} }

View File

@@ -7,7 +7,7 @@ uniform sampler2D palette;
uniform float bloomStrength; uniform float bloomStrength;
uniform float ditherMagnitude; uniform float ditherMagnitude;
uniform float time; uniform float time;
uniform vec3 backgroundColor; uniform vec3 backgroundColor, cursorColor;
varying vec2 vUV; varying vec2 vUV;
highp float rand( const in vec2 uv, const in float t ) { highp float rand( const in vec2 uv, const in float t ) {
@@ -26,11 +26,16 @@ void main() {
vec4 brightnessRGB = getBrightness(vUV); vec4 brightnessRGB = getBrightness(vUV);
// Combine the texture and bloom // Combine the texture and bloom
float brightness = brightnessRGB.r + brightnessRGB.g + brightnessRGB.b; vec2 brightness = brightnessRGB.rg;
// Dither: subtract a random value from the brightness // Dither: subtract a random value from the brightness
brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude; brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude;
// Map the brightness to a position in the palette texture // Map the brightness to a position in the palette texture
gl_FragColor = texture2D( palette, vec2(brightness, 0.0)) + vec4(backgroundColor, 0.0); gl_FragColor = vec4(
texture2D( palette, vec2(brightness.r, 0.0)).rgb
+ min(cursorColor * brightness.g, 1.0)
+ backgroundColor,
1.0
);
} }

View File

@@ -9,13 +9,14 @@ uniform float numColumns, numRows;
uniform sampler2D glyphTex; uniform sampler2D glyphTex;
uniform float glyphHeightToWidth, glyphSequenceLength, glyphEdgeCrop; uniform float glyphHeightToWidth, glyphSequenceLength, glyphEdgeCrop;
uniform float baseContrast, baseBrightness; uniform float baseContrast, baseBrightness;
uniform float brightnessOverride, brightnessThreshold, cursorBrightness; uniform float brightnessOverride, brightnessThreshold;
uniform vec2 glyphTextureGridSize; uniform vec2 glyphTextureGridSize;
uniform vec2 slantVec; uniform vec2 slantVec;
uniform float slantScale; uniform float slantScale;
uniform bool isPolar; uniform bool isPolar;
uniform bool showDebugView; uniform bool showDebugView;
uniform bool volumetric; uniform bool volumetric;
uniform bool isolateCursor;
varying vec2 vUV; varying vec2 vUV;
varying vec4 vShine, vSymbol, vEffect; varying vec4 vShine, vSymbol, vEffect;
@@ -57,24 +58,26 @@ vec2 getUV(vec2 uv) {
return uv; return uv;
} }
float getBrightness(float brightness, float cursor, float multipliedEffects, float addedEffects) { vec2 getBrightness(float brightness, float cursor, float multipliedEffects, float addedEffects) {
if (!isolateCursor) {
cursor = 0.;
}
brightness = (1.0 - brightness) * baseContrast + baseBrightness; brightness = (1.0 - brightness) * baseContrast + baseBrightness;
// Modes that don't fade glyphs set their actual brightness here // Modes that don't fade glyphs set their actual brightness here
if (brightnessOverride > 0. && brightness > brightnessThreshold) { if (brightnessOverride > 0. && brightness > brightnessThreshold && cursor == 0.) {
brightness = brightnessOverride; brightness = brightnessOverride;
} }
brightness *= multipliedEffects; brightness *= multipliedEffects;
brightness += addedEffects; brightness += addedEffects;
brightness = max(cursor * cursorBrightness, brightness);
// In volumetric mode, distant glyphs are dimmer // In volumetric mode, distant glyphs are dimmer
if (volumetric && !showDebugView) { if (volumetric && !showDebugView) {
brightness = brightness * min(1., vDepth); brightness = brightness * min(1., vDepth);
} }
return brightness; return vec2(brightness * (1. - cursor), brightness * cursor);
} }
vec2 getSymbolUV(float index) { vec2 getSymbolUV(float index) {
@@ -107,7 +110,7 @@ void main() {
vec4 symbolData = volumetric ? vSymbol : texture2D(symbolState, uv); vec4 symbolData = volumetric ? vSymbol : texture2D(symbolState, uv);
vec4 effectData = volumetric ? vEffect : texture2D(effectState, uv); vec4 effectData = volumetric ? vEffect : texture2D(effectState, uv);
float brightness = getBrightness(shineData.r, shineData.g, effectData.r, effectData.g); vec2 brightness = getBrightness(shineData.r, shineData.g, effectData.r, effectData.g);
float symbol = getSymbol(uv, symbolData.r); float symbol = getSymbol(uv, symbolData.r);
if (showDebugView) { if (showDebugView) {
@@ -122,6 +125,6 @@ void main() {
1. 1.
); );
} else { } else {
gl_FragColor = vec4(brightness * symbol, 0., 0., 0.); gl_FragColor = vec4(brightness * symbol, 0., 0.);
} }
} }

View File

@@ -7,7 +7,7 @@ uniform float bloomStrength;
uniform sampler2D stripes; uniform sampler2D stripes;
uniform float ditherMagnitude; uniform float ditherMagnitude;
uniform float time; uniform float time;
uniform vec3 backgroundColor; uniform vec3 backgroundColor, cursorColor;
varying vec2 vUV; varying vec2 vUV;
highp float rand( const in vec2 uv, const in float t ) { highp float rand( const in vec2 uv, const in float t ) {
@@ -25,10 +25,15 @@ vec4 getBrightness(vec2 uv) {
void main() { void main() {
vec3 color = texture2D(stripes, vUV).rgb; vec3 color = texture2D(stripes, vUV).rgb;
// Combine the texture and bloom // Combine the texture and bloom
float brightness = getBrightness(vUV).r; vec4 brightness = getBrightness(vUV);
// Dither: subtract a random value from the brightness // Dither: subtract a random value from the brightness
brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude; brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude;
gl_FragColor = vec4(color * brightness + backgroundColor, 1.0); gl_FragColor = vec4(
color * brightness.r
+ min(cursorColor * brightness.g, 1.0)
+ backgroundColor,
1.0
);
} }