mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 05:49:30 -07:00
Migrated changes to WebGPU
This commit is contained in:
@@ -23,18 +23,15 @@ vec4 getBrightness(vec2 uv) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 brightnessRGB = getBrightness(vUV);
|
||||
|
||||
// Combine the texture and bloom
|
||||
vec2 brightness = brightnessRGB.rg;
|
||||
vec4 brightness = getBrightness(vUV);
|
||||
|
||||
// Dither: subtract a random value from the brightness
|
||||
brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
|
||||
// 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, 1.0)
|
||||
+ min(cursorColor * brightness.g, vec3(1.0))
|
||||
+ backgroundColor,
|
||||
1.0
|
||||
);
|
||||
|
||||
@@ -35,10 +35,10 @@ float getThunder(float simTime, vec2 screenPos) {
|
||||
return 0.;
|
||||
}
|
||||
|
||||
simTime *= 0.5;
|
||||
float thunder = 1. - fract(wobble(simTime));
|
||||
float thunderTime = simTime * 0.5;
|
||||
float thunder = 1. - fract(wobble(thunderTime));
|
||||
if (loops) {
|
||||
thunder = 1. - fract(simTime + 0.3);
|
||||
thunder = 1. - fract(thunderTime + 0.3);
|
||||
}
|
||||
|
||||
thunder = log(thunder * 1.5) * 4.;
|
||||
@@ -82,7 +82,7 @@ float getRipple(float simTime, vec2 screenPos) {
|
||||
|
||||
vec4 computeResult(float simTime, bool isFirstFrame, vec2 glyphPos, vec2 screenPos, vec4 previous) {
|
||||
|
||||
float multipliedEffects = 1.0 + getThunder(simTime, screenPos);
|
||||
float multipliedEffects = 1. + getThunder(simTime, screenPos);
|
||||
float addedEffects = getRipple(simTime, screenPos); // Round or square ripples across the grid
|
||||
|
||||
vec4 result = vec4(multipliedEffects, addedEffects, 0., 0.);
|
||||
|
||||
@@ -19,7 +19,7 @@ uniform bool volumetric;
|
||||
uniform bool isolateCursor;
|
||||
|
||||
varying vec2 vUV;
|
||||
varying vec4 vShine, vSymbol, vEffect;
|
||||
varying vec4 vRaindrop, vSymbol, vEffect;
|
||||
varying float vDepth;
|
||||
|
||||
float median3(vec3 i) {
|
||||
@@ -62,7 +62,7 @@ vec2 getBrightness(float brightness, float cursor, float multipliedEffects, floa
|
||||
if (!isolateCursor) {
|
||||
cursor = 0.;
|
||||
}
|
||||
brightness = (1.0 - brightness) * baseContrast + baseBrightness;
|
||||
brightness = (1. - brightness) * baseContrast + baseBrightness;
|
||||
|
||||
// Modes that don't fade glyphs set their actual brightness here
|
||||
if (brightnessOverride > 0. && brightness > brightnessThreshold && cursor == 0.) {
|
||||
@@ -98,7 +98,7 @@ float getSymbol(vec2 uv, float index) {
|
||||
// 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.);
|
||||
return clamp(sigDist / fwidth(sigDist) + 0.5, 0., 1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -106,9 +106,9 @@ void main() {
|
||||
vec2 uv = getUV(vUV);
|
||||
|
||||
// Unpack the values from the data textures
|
||||
vec4 raindropData = volumetric ? vShine : texture2D( raindropState, uv);
|
||||
vec4 symbolData = volumetric ? vSymbol : texture2D(symbolState, uv);
|
||||
vec4 effectData = volumetric ? vEffect : texture2D(effectState, uv);
|
||||
vec4 raindropData = volumetric ? vRaindrop : texture2D(raindropState, uv);
|
||||
vec4 symbolData = volumetric ? vSymbol : texture2D( symbolState, uv);
|
||||
vec4 effectData = volumetric ? vEffect : texture2D( effectState, uv);
|
||||
|
||||
vec2 brightness = getBrightness(raindropData.r, raindropData.g, effectData.r, effectData.g);
|
||||
float symbol = getSymbol(uv, symbolData.r);
|
||||
@@ -118,9 +118,9 @@ void main() {
|
||||
vec3(
|
||||
raindropData.g,
|
||||
vec2(
|
||||
1.0 - (raindropData.r * 3.0),
|
||||
1.0 - (raindropData.r * 8.0)
|
||||
) * (1.0 - raindropData.g)
|
||||
1. - (raindropData.r * 3.),
|
||||
1. - (raindropData.r * 8.)
|
||||
) * (1. - raindropData.g)
|
||||
) * symbol,
|
||||
1.
|
||||
);
|
||||
|
||||
@@ -2,9 +2,9 @@ precision highp float;
|
||||
|
||||
// This shader is the star of the show.
|
||||
// It writes falling rain to the channels of a data texture:
|
||||
// R: brightness
|
||||
// G: unused
|
||||
// B: whether the cell is a "cursor"
|
||||
// R: raindrop brightness
|
||||
// G: whether the cell is a "cursor"
|
||||
// B: unused
|
||||
// A: unused
|
||||
|
||||
// Listen.
|
||||
|
||||
@@ -10,7 +10,7 @@ uniform vec2 screenSize;
|
||||
uniform float time, animationSpeed, forwardSpeed;
|
||||
uniform bool volumetric;
|
||||
varying vec2 vUV;
|
||||
varying vec4 vShine, vSymbol, vEffect;
|
||||
varying vec4 vRaindrop, vSymbol, vEffect;
|
||||
varying float vDepth;
|
||||
|
||||
highp float rand( const in vec2 uv ) {
|
||||
@@ -22,9 +22,9 @@ highp float rand( const in vec2 uv ) {
|
||||
void main() {
|
||||
|
||||
vUV = (aPosition + aCorner) * quadSize;
|
||||
vShine = texture2D(raindropState, aPosition * quadSize);
|
||||
vSymbol = texture2D(symbolState, aPosition * quadSize);
|
||||
vEffect = texture2D(effectState, aPosition * quadSize);
|
||||
vRaindrop = texture2D(raindropState, aPosition * quadSize);
|
||||
vSymbol = texture2D( symbolState, aPosition * quadSize);
|
||||
vEffect = texture2D( effectState, aPosition * quadSize);
|
||||
|
||||
// Calculate the world space position
|
||||
float quadDepth = 0.0;
|
||||
|
||||
@@ -24,11 +24,11 @@ vec4 getBrightness(vec2 uv) {
|
||||
|
||||
void main() {
|
||||
vec3 color = texture2D(stripes, vUV).rgb;
|
||||
// Combine the texture and bloom
|
||||
|
||||
vec4 brightness = getBrightness(vUV);
|
||||
|
||||
// Dither: subtract a random value from the brightness
|
||||
brightness = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
brightness -= rand( gl_FragCoord.xy, time ) * ditherMagnitude;
|
||||
|
||||
gl_FragColor = vec4(
|
||||
color * brightness.r
|
||||
|
||||
Reference in New Issue
Block a user