mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Freeing up a rain pass channel
This commit is contained in:
@@ -3,7 +3,7 @@ precision highp float;
|
||||
// This shader is the star of the show. For each glyph, it determines its:
|
||||
// R: brightness
|
||||
// G: progress through the glyph sequence
|
||||
// B: depth, aka distance from the screen
|
||||
// B: unused!
|
||||
// A: additional brightness for effects
|
||||
|
||||
// Listen.
|
||||
@@ -24,7 +24,7 @@ uniform bool hasSun, hasThunder, loops;
|
||||
uniform bool showComputationTexture;
|
||||
uniform float brightnessOverride, brightnessThreshold, brightnessDecay;
|
||||
uniform float baseContrast, baseBrightness;
|
||||
uniform float raindropLength, glyphHeightToWidth;
|
||||
uniform float raindropLength, glyphHeightToWidth, glyphSequenceLength;
|
||||
uniform int cycleStyle, rippleType;
|
||||
uniform float rippleScale, rippleSpeed, rippleThickness;
|
||||
uniform float cursorEffectThreshold;
|
||||
@@ -188,10 +188,7 @@ vec4 computeResult(bool isFirstFrame, vec4 previousResult, vec2 glyphPos, vec2 s
|
||||
brightness = mix(previousBrightness, brightness, brightnessDecay);
|
||||
}
|
||||
|
||||
// Determine the glyph depth. This is a static value for each column.
|
||||
float depth = randomFloat(vec2(screenPos.x, 0.));
|
||||
|
||||
vec4 result = vec4(brightness, cycle, depth, effect);
|
||||
vec4 result = vec4(brightness, cycle, 0.0, effect);
|
||||
|
||||
// Better use of the alpha channel, for demonstrating how the glyph cycle works
|
||||
if (showComputationTexture) {
|
||||
|
||||
@@ -18,15 +18,21 @@ uniform bool volumetric;
|
||||
varying vec2 vUV;
|
||||
varying vec3 vChannel;
|
||||
varying vec4 vGlyph;
|
||||
varying float vDepth;
|
||||
|
||||
float median3(vec3 i) {
|
||||
return max(min(i.r, i.g), min(max(i.r, i.g), i.b));
|
||||
}
|
||||
|
||||
float modI(float a, float b) {
|
||||
float m = a - floor((a + 0.5) / b) * b;
|
||||
return floor(m + 0.5);
|
||||
}
|
||||
|
||||
vec2 getSymbolUV(float glyphCycle) {
|
||||
float symbol = floor((glyphSequenceLength) * glyphCycle) + 1.0;
|
||||
float symbolX = mod(symbol, glyphTextureGridSize.x);
|
||||
float symbolY = mod(floor(symbol / glyphTextureGridSize.x), glyphTextureGridSize.y);
|
||||
float symbol = floor((glyphSequenceLength) * glyphCycle);
|
||||
float symbolX = modI(symbol, glyphTextureGridSize.x);
|
||||
float symbolY = (symbol - symbolX) / glyphTextureGridSize.x;
|
||||
symbolY = glyphTextureGridSize.y - symbolY - 1.0;
|
||||
return vec2(symbolX, symbolY);
|
||||
}
|
||||
@@ -59,13 +65,12 @@ void main() {
|
||||
vec4 glyph = volumetric ? vGlyph : texture2D(state, uv);
|
||||
float brightness = glyph.r;
|
||||
vec2 symbolUV = getSymbolUV(glyph.g);
|
||||
float quadDepth = glyph.b;
|
||||
float effect = glyph.a;
|
||||
|
||||
brightness = max(effect, brightness);
|
||||
// In volumetric mode, distant glyphs are dimmer
|
||||
if (volumetric) {
|
||||
brightness = brightness * min(1.0, quadDepth);
|
||||
brightness = brightness * min(1.0, vDepth);
|
||||
}
|
||||
|
||||
// resolve UV to cropped position of glyph in MSDF texture
|
||||
|
||||
@@ -12,6 +12,7 @@ uniform bool volumetric;
|
||||
varying vec2 vUV;
|
||||
varying vec3 vChannel;
|
||||
varying vec4 vGlyph;
|
||||
varying float vDepth;
|
||||
|
||||
highp float rand( const in vec2 uv ) {
|
||||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||||
@@ -27,8 +28,9 @@ void main() {
|
||||
// Calculate the world space position
|
||||
float quadDepth = 0.0;
|
||||
if (volumetric) {
|
||||
quadDepth = fract(vGlyph.b + time * animationSpeed * forwardSpeed);
|
||||
vGlyph.b = quadDepth;
|
||||
float startDepth = rand(vec2(aPosition.x, 0.));
|
||||
quadDepth = fract(startDepth + time * animationSpeed * forwardSpeed);
|
||||
vDepth = quadDepth;
|
||||
}
|
||||
vec2 position = (aPosition * vec2(1., glyphVerticalSpacing) + aCorner * vec2(density, 1.)) * quadSize;
|
||||
vec4 pos = vec4((position - 0.5) * 2.0, quadDepth, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user