mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-22 15:49:30 -07:00
Migrated changes to WebGPU
This commit is contained in:
@@ -2,6 +2,7 @@ struct Config {
|
||||
bloomStrength : f32,
|
||||
ditherMagnitude : f32,
|
||||
backgroundColor : vec3<f32>,
|
||||
cursorColor : vec3<f32>
|
||||
};
|
||||
|
||||
struct Palette {
|
||||
@@ -54,17 +55,19 @@ fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
|
||||
|
||||
var uv = vec2<f32>(coord) / vec2<f32>(screenSize);
|
||||
|
||||
var brightnessRGB = getBrightness(uv);
|
||||
|
||||
// Combine the texture and bloom
|
||||
var brightness = brightnessRGB.r + brightnessRGB.g + brightnessRGB.b;
|
||||
var brightness = getBrightness(uv);
|
||||
|
||||
// Dither: subtract a random value from the brightness
|
||||
brightness -= randomFloat( uv + vec2<f32>(time.seconds) ) * config.ditherMagnitude;
|
||||
|
||||
var paletteIndex = clamp(i32(brightness * 512.0), 0, 511);
|
||||
|
||||
// Map the brightness to a position in the palette texture
|
||||
textureStore(outputTex, coord, vec4<f32>(palette.colors[paletteIndex] + config.backgroundColor, 1.0));
|
||||
var paletteIndex = clamp(i32(brightness.r * 512.0), 0, 511);
|
||||
|
||||
textureStore(outputTex, coord, vec4<f32>(
|
||||
palette.colors[paletteIndex]
|
||||
+ min(config.cursorColor * brightness.g, vec3<f32>(1.0))
|
||||
+ config.backgroundColor,
|
||||
1.0
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user