Separated cursor and glint intensities from their colors, which can now safely reside in their color spaces.

This commit is contained in:
Rezmason
2022-11-01 08:05:48 -07:00
parent c7fafcdb13
commit acc21ef1f4
10 changed files with 76 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ uniform sampler2D paletteTex;
uniform float ditherMagnitude;
uniform float time;
uniform vec3 backgroundColor, cursorColor, glintColor;
uniform float cursorIntensity, glintIntensity;
varying vec2 vUV;
highp float rand( const in vec2 uv, const in float t ) {
@@ -30,8 +31,8 @@ void main() {
// Map the brightness to a position in the palette texture
gl_FragColor = vec4(
texture2D( paletteTex, vec2(brightness.r, 0.0)).rgb
+ min(cursorColor * brightness.g, vec3(1.0))
+ min(glintColor * brightness.b, vec3(1.0))
+ min(cursorColor * cursorIntensity * brightness.g, vec3(1.0))
+ min(glintColor * glintIntensity * brightness.b, vec3(1.0))
+ backgroundColor,
1.0
);

View File

@@ -7,6 +7,7 @@ uniform sampler2D stripeTex;
uniform float ditherMagnitude;
uniform float time;
uniform vec3 backgroundColor, cursorColor, glintColor;
uniform float cursorIntensity, glintIntensity;
varying vec2 vUV;
highp float rand( const in vec2 uv, const in float t ) {
@@ -31,8 +32,8 @@ void main() {
gl_FragColor = vec4(
color * brightness.r
+ min(cursorColor * brightness.g, vec3(1.0))
+ min(glintColor * brightness.b, vec3(1.0))
+ min(cursorColor * cursorIntensity * brightness.g, vec3(1.0))
+ min(glintColor * glintIntensity * brightness.b, vec3(1.0))
+ backgroundColor,
1.0
);

View File

@@ -3,6 +3,8 @@ struct Config {
backgroundColor : vec3<f32>,
cursorColor : vec3<f32>,
glintColor : vec3<f32>,
cursorIntensity : f32,
glintIntensity : f32,
};
struct Palette {
@@ -65,8 +67,8 @@ fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
textureStore(outputTex, coord, vec4<f32>(
palette.colors[paletteIndex]
+ min(config.cursorColor * brightness.g, vec3<f32>(1.0))
+ min(config.glintColor * brightness.b, vec3<f32>(1.0))
+ min(config.cursorColor * config.cursorIntensity * brightness.g, vec3<f32>(1.0))
+ min(config.glintColor * config.glintIntensity * brightness.b, vec3<f32>(1.0))
+ config.backgroundColor,
1.0
));

View File

@@ -3,6 +3,8 @@ struct Config {
backgroundColor : vec3<f32>,
cursorColor : vec3<f32>,
glintColor : vec3<f32>,
cursorIntensity : f32,
glintIntensity : f32,
};
struct Time {
@@ -60,8 +62,8 @@ fn getBrightness(uv : vec2<f32>) -> vec4<f32> {
textureStore(outputTex, coord, vec4<f32>(
color * brightness.r
+ min(config.cursorColor * brightness.g, vec3<f32>(1.0))
+ min(config.glintColor * brightness.b, vec3<f32>(1.0))
+ min(config.cursorColor * config.cursorIntensity * brightness.g, vec3<f32>(1.0))
+ min(config.glintColor * config.glintIntensity * brightness.b, vec3<f32>(1.0))
+ config.backgroundColor,
1.0
));