mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-18 22:29:28 -07:00
Adding "glint", the shapes that appear on top of the glyphs in the Resurrections opening titles.
This commit is contained in:
@@ -7,7 +7,7 @@ uniform sampler2D palette;
|
||||
uniform float bloomStrength;
|
||||
uniform float ditherMagnitude;
|
||||
uniform float time;
|
||||
uniform vec3 backgroundColor, cursorColor;
|
||||
uniform vec3 backgroundColor, cursorColor, glintColor;
|
||||
varying vec2 vUV;
|
||||
|
||||
highp float rand( const in vec2 uv, const in float t ) {
|
||||
@@ -26,12 +26,13 @@ void main() {
|
||||
vec4 brightness = getBrightness(vUV);
|
||||
|
||||
// Dither: subtract a random value from the brightness
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude / 3.0;
|
||||
|
||||
// Map the brightness to a position in the palette texture
|
||||
gl_FragColor = vec4(
|
||||
texture2D( palette, vec2(brightness.r, 0.0)).rgb
|
||||
+ min(cursorColor * brightness.g, vec3(1.0))
|
||||
+ min(glintColor * brightness.b, vec3(1.0))
|
||||
+ backgroundColor,
|
||||
1.0
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ precision lowp float;
|
||||
|
||||
uniform sampler2D raindropState, symbolState, effectState;
|
||||
uniform float numColumns, numRows;
|
||||
uniform sampler2D glyphTex;
|
||||
uniform sampler2D glyphTex, glintTex;
|
||||
uniform float glyphHeightToWidth, glyphSequenceLength, glyphEdgeCrop;
|
||||
uniform float baseContrast, baseBrightness;
|
||||
uniform float brightnessOverride, brightnessThreshold;
|
||||
@@ -16,7 +16,7 @@ uniform float slantScale;
|
||||
uniform bool isPolar;
|
||||
uniform bool showDebugView;
|
||||
uniform bool volumetric;
|
||||
uniform bool isolateCursor;
|
||||
uniform bool isolateCursor, isolateGlint;
|
||||
|
||||
varying vec2 vUV;
|
||||
varying vec4 vRaindrop, vSymbol, vEffect;
|
||||
@@ -87,7 +87,7 @@ vec2 getSymbolUV(float index) {
|
||||
return vec2(symbolX, symbolY);
|
||||
}
|
||||
|
||||
float getSymbol(vec2 uv, float index) {
|
||||
vec2 getSymbol(vec2 uv, float index) {
|
||||
// resolve UV to cropped position of glyph in MSDF texture
|
||||
uv = fract(uv * vec2(numColumns, numRows));
|
||||
uv -= 0.5;
|
||||
@@ -96,9 +96,20 @@ float getSymbol(vec2 uv, float index) {
|
||||
uv = (uv + getSymbolUV(index)) / glyphTextureGridSize;
|
||||
|
||||
// MSDF: calculate brightness of fragment based on distance to shape
|
||||
vec3 dist = texture2D(glyphTex, uv).rgb;
|
||||
float sigDist = median3(dist) - 0.5;
|
||||
return clamp(sigDist / fwidth(sigDist) + 0.5, 0., 1.);
|
||||
vec2 symbol;
|
||||
{
|
||||
vec3 dist = texture2D(glyphTex, uv).rgb;
|
||||
float sigDist = median3(dist) - 0.5;
|
||||
symbol.r = clamp(sigDist / fwidth(sigDist) + 0.5, 0., 1.);
|
||||
}
|
||||
|
||||
if (isolateGlint) {
|
||||
vec3 dist = texture2D(glintTex, uv).rgb;
|
||||
float sigDist = median3(dist) - 0.5;
|
||||
symbol.g = clamp(sigDist / fwidth(sigDist) + 0.5, 0., 1.);
|
||||
}
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -111,7 +122,7 @@ void main() {
|
||||
vec4 effectData = volumetric ? vEffect : texture2D( effectState, uv);
|
||||
|
||||
vec2 brightness = getBrightness(raindropData.r, raindropData.g, effectData.r, effectData.g);
|
||||
float symbol = getSymbol(uv, symbolData.r);
|
||||
vec2 symbol = getSymbol(uv, symbolData.r);
|
||||
|
||||
if (showDebugView) {
|
||||
gl_FragColor = vec4(
|
||||
@@ -121,10 +132,10 @@ void main() {
|
||||
1. - (raindropData.r * 3.),
|
||||
1. - (raindropData.r * 8.)
|
||||
) * (1. - raindropData.g)
|
||||
) * symbol,
|
||||
) * symbol.r,
|
||||
1.
|
||||
);
|
||||
} else {
|
||||
gl_FragColor = vec4(brightness * symbol, 0., 0.);
|
||||
gl_FragColor = vec4(brightness * symbol.r, brightness.r * symbol.g, 0.);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ uniform float bloomStrength;
|
||||
uniform sampler2D stripes;
|
||||
uniform float ditherMagnitude;
|
||||
uniform float time;
|
||||
uniform vec3 backgroundColor, cursorColor;
|
||||
uniform vec3 backgroundColor, cursorColor, glintColor;
|
||||
varying vec2 vUV;
|
||||
|
||||
highp float rand( const in vec2 uv, const in float t ) {
|
||||
@@ -28,11 +28,12 @@ void main() {
|
||||
vec4 brightness = getBrightness(vUV);
|
||||
|
||||
// Dither: subtract a random value from the brightness
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude / 3.0;
|
||||
|
||||
gl_FragColor = vec4(
|
||||
color * brightness.r
|
||||
+ min(cursorColor * brightness.g, 1.0)
|
||||
+ min(cursorColor * brightness.g, vec3(1.0))
|
||||
+ min(glintColor * brightness.b, vec3(1.0))
|
||||
+ backgroundColor,
|
||||
1.0
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user