Added backgroundColor support and improved stripe colors handling in config.

This commit is contained in:
Rezmason
2021-09-12 00:50:51 -07:00
parent 51f1b6ebf5
commit 7910ca0553
3 changed files with 16 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
import { make1DTexture, makePassFBO, makePass } from "./utils.js";
import { extractEntries, make1DTexture, makePassFBO, makePass } from "./utils.js";
const makePalette = (regl, entries) => {
const PALETTE_SIZE = 2048;
@@ -63,6 +63,7 @@ export default (regl, config, inputs) => {
uniform sampler2D palette;
uniform float ditherMagnitude;
uniform float time;
uniform vec3 backgroundColor;
varying vec2 vUV;
highp float rand( const in vec2 uv, const in float t ) {
@@ -74,11 +75,14 @@ export default (regl, config, inputs) => {
void main() {
float brightness = texture2D( tex, vUV ).r + texture2D( bloomTex, vUV ).r;
float at = brightness - rand( gl_FragCoord.xy, time ) * ditherMagnitude;
gl_FragColor = texture2D( palette, vec2(at, 0.0));
gl_FragColor = texture2D( palette, vec2(at, 0.0)) + vec4(backgroundColor, 0.0);
}
`,
uniforms: {
...extractEntries(config, [
"backgroundColor",
]),
tex: inputs.primary,
bloomTex: inputs.bloom,
palette,