mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2026-02-08 00:32:27 +00:00
Fix some bloom behaviour issues and simplify effects colorization.
This commit is contained in:
22
app/app.pro
22
app/app.pro
@@ -59,18 +59,16 @@ for(raster_mode, RASTER_MODES) {
|
||||
}
|
||||
|
||||
for(rgb_shift, BINARY_FLAGS) {
|
||||
for(chroma_on, BINARY_FLAGS) {
|
||||
for(bloom_on, BINARY_FLAGS) {
|
||||
for(curve_on, BINARY_FLAGS) {
|
||||
for(shine_on, BINARY_FLAGS) {
|
||||
static_variant = terminal_static_rgb$${rgb_shift}_chroma$${chroma_on}_bloom$${bloom_on}_curve$${curve_on}_shine$${shine_on}
|
||||
static_output = $${VARIANT_SHADER_DIR}/$${static_variant}.frag.qsb
|
||||
static_target = shader_variant_$${static_variant}
|
||||
$${static_target}.target = $${static_output}
|
||||
$${static_target}.depends = $$STATIC_SHADER
|
||||
$${static_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RGB_SHIFT=$${rgb_shift} -DCRT_CHROMA=$${chroma_on} -DCRT_BLOOM=$${bloom_on} -DCRT_CURVATURE=$${curve_on} -DCRT_FRAME_SHININESS=$${shine_on} -o $${static_output} $$STATIC_SHADER
|
||||
QMAKE_EXTRA_TARGETS += $${static_target}
|
||||
}
|
||||
for(bloom_on, BINARY_FLAGS) {
|
||||
for(curve_on, BINARY_FLAGS) {
|
||||
for(shine_on, BINARY_FLAGS) {
|
||||
static_variant = terminal_static_rgb$${rgb_shift}_bloom$${bloom_on}_curve$${curve_on}_shine$${shine_on}
|
||||
static_output = $${VARIANT_SHADER_DIR}/$${static_variant}.frag.qsb
|
||||
static_target = shader_variant_$${static_variant}
|
||||
$${static_target}.target = $${static_output}
|
||||
$${static_target}.depends = $$STATIC_SHADER
|
||||
$${static_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RGB_SHIFT=$${rgb_shift} -DCRT_BLOOM=$${bloom_on} -DCRT_CURVATURE=$${curve_on} -DCRT_FRAME_SHININESS=$${shine_on} -o $${static_output} $$STATIC_SHADER
|
||||
QMAKE_EXTRA_TARGETS += $${static_target}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,10 @@ Item {
|
||||
|
||||
function staticFragmentPath() {
|
||||
var rgbShiftOn = appSettings.rbgShift > 0 ? 1 : 0;
|
||||
var chromaOn = appSettings.chromaColor > 0 ? 1 : 0;
|
||||
var bloomOn = appSettings.bloom > 0 ? 1 : 0;
|
||||
var curvatureOn = (appSettings.screenCurvature > 0 || appSettings.frameSize > 0) ? 1 : 0;
|
||||
var shineOn = appSettings.frameShininess > 0 ? 1 : 0;
|
||||
return "qrc:/shaders/terminal_static_rgb" + rgbShiftOn +
|
||||
"_chroma" + chromaOn +
|
||||
"_bloom" + bloomOn +
|
||||
"_curve" + curvatureOn +
|
||||
"_shine" + shineOn +
|
||||
@@ -112,6 +110,7 @@ Item {
|
||||
|
||||
property real frameSize: appSettings.frameSize
|
||||
property real frameShininess: appSettings.frameShininess
|
||||
property real bloom: parent.bloomSource ? appSettings.bloom * 2.5 : 0
|
||||
|
||||
anchors.fill: parent
|
||||
blending: false
|
||||
|
||||
@@ -80,38 +80,22 @@
|
||||
<file>../shaders/terminal_dynamic_raster3_burn1_frame0_chroma1.frag.qsb</file>
|
||||
<file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma0.frag.qsb</file>
|
||||
<file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma0_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_chroma1_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma0_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_chroma1_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb0_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom0_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom0_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom0_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom0_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom1_curve0_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom1_curve0_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom1_curve1_shine0.frag.qsb</file>
|
||||
<file>../shaders/terminal_static_rgb1_bloom1_curve1_shine1.frag.qsb</file>
|
||||
<file>../shaders/terminal_frame.frag.qsb</file>
|
||||
<file>../shaders/burn_in.frag.qsb</file>
|
||||
<file>fonts/unscii/unscii-8-thin.ttf</file>
|
||||
|
||||
@@ -29,8 +29,10 @@ void main() {
|
||||
|
||||
float blurDecay = clamp((burnInLastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0);
|
||||
blurDecay = max(0.0, blurDecay - prevMask);
|
||||
vec3 blurColor = accColor.rgb - vec3(blurDecay);
|
||||
vec3 color = max(blurColor, txtColor);
|
||||
float blurValue = rgb2grey(accColor.rgb) - blurDecay;
|
||||
float txtValue = rgb2grey(txtColor);
|
||||
float colorValue = max(blurValue, txtValue);
|
||||
vec3 color = vec3(colorValue);
|
||||
|
||||
fragColor = vec4(color, currMask) * qt_Opacity;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -45,6 +45,7 @@ layout(std140, binding = 0) uniform ubuf {
|
||||
vec2 scaleNoiseSize;
|
||||
float frameShininess;
|
||||
float frameSize;
|
||||
float bloom;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform sampler2D noiseSource;
|
||||
@@ -123,11 +124,12 @@ float randomPass(vec2 coords){
|
||||
|
||||
vec3 convertWithChroma(vec3 inColor) {
|
||||
#if CRT_CHROMA == 1
|
||||
vec3 outColor = fontColor.rgb * rgb2grey(inColor);
|
||||
outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);
|
||||
return outColor;
|
||||
float grey = rgb2grey(inColor);
|
||||
float denom = max(grey, 0.0001);
|
||||
vec3 foregroundColor = mix(fontColor.rgb, inColor * fontColor.rgb / denom, chromaColor);
|
||||
return mix(backgroundColor.rgb, foregroundColor, grey);
|
||||
#else
|
||||
return fontColor.rgb * rgb2grey(inColor);
|
||||
return mix(backgroundColor.rgb, fontColor.rgb, rgb2grey(inColor));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -150,18 +152,20 @@ void main() {
|
||||
color += randomPass(coords * virtualResolution) * glowingLine;
|
||||
|
||||
vec3 txt_color = texture(screenBuffer, txt_coords).rgb;
|
||||
float bloomScale = 1.0 + max(bloom, 0.0);
|
||||
txt_color *= bloomScale;
|
||||
|
||||
#if CRT_BURN_IN == 1
|
||||
vec4 txt_blur = texture(burnInSource, staticCoords);
|
||||
float blurDecay = clamp((time - burnInLastUpdate) * burnInTime, 0.0, 1.0);
|
||||
vec3 burnInColor = 0.65 * (txt_blur.rgb - vec3(blurDecay));
|
||||
txt_color = max(txt_color, convertWithChroma(burnInColor));
|
||||
txt_color = max(txt_color, burnInColor);
|
||||
#endif
|
||||
|
||||
txt_color += fontColor.rgb * vec3(color);
|
||||
txt_color += vec3(color);
|
||||
txt_color = applyRasterization(staticCoords, txt_color, virtualResolution, rasterizationIntensity);
|
||||
|
||||
vec3 finalColor = txt_color;
|
||||
vec3 finalColor = convertWithChroma(txt_color);
|
||||
float brightness = mix(1.0, vBrightness, step(0.0, flickering));
|
||||
finalColor *= brightness;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ layout(std140, binding = 0) uniform ubuf {
|
||||
vec2 scaleNoiseSize;
|
||||
float frameShininess;
|
||||
float frameSize;
|
||||
float bloom;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform sampler2D noiseSource;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,9 +3,6 @@
|
||||
#ifndef CRT_RGB_SHIFT
|
||||
#define CRT_RGB_SHIFT 1
|
||||
#endif
|
||||
#ifndef CRT_CHROMA
|
||||
#define CRT_CHROMA 1
|
||||
#endif
|
||||
#ifndef CRT_BLOOM
|
||||
#define CRT_BLOOM 1
|
||||
#endif
|
||||
@@ -22,10 +19,7 @@ layout(location = 0) out vec4 fragColor;
|
||||
layout(std140, binding = 0) uniform ubuf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec4 fontColor;
|
||||
vec4 backgroundColor;
|
||||
float screenCurvature;
|
||||
float chromaColor;
|
||||
float rbgShift;
|
||||
float frameShininess;
|
||||
float frameSize;
|
||||
@@ -38,8 +32,6 @@ layout(binding = 2) uniform sampler2D bloomSource;
|
||||
|
||||
float min2(vec2 v) { return min(v.x, v.y); }
|
||||
float max2(vec2 v) { return max(v.x, v.y); }
|
||||
float rgb2grey(vec3 v) { return dot(v, vec3(0.21, 0.72, 0.04)); }
|
||||
|
||||
vec2 distortCoordinates(vec2 coords){
|
||||
vec2 paddedCoords = coords * (vec2(1.0) + frameSize * 2.0) - frameSize;
|
||||
vec2 cc = (paddedCoords - vec2(0.5));
|
||||
@@ -47,16 +39,6 @@ vec2 distortCoordinates(vec2 coords){
|
||||
return (paddedCoords + cc * (1.0 + dist) * dist);
|
||||
}
|
||||
|
||||
vec3 convertWithChroma(vec3 inColor) {
|
||||
#if CRT_CHROMA == 1
|
||||
vec3 outColor = fontColor.rgb * rgb2grey(inColor);
|
||||
outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);
|
||||
return outColor;
|
||||
#else
|
||||
return fontColor.rgb * rgb2grey(inColor);
|
||||
#endif
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 cc = vec2(0.5) - qt_TexCoord0;
|
||||
|
||||
@@ -84,32 +66,25 @@ void main() {
|
||||
txt_color.b = leftColor.b * 0.30 + rightColor.b * 0.10 + txt_color.b * 0.60;
|
||||
#endif
|
||||
|
||||
txt_color += vec3(0.0001);
|
||||
float greyscale_color = rgb2grey(txt_color);
|
||||
vec3 finalColor = txt_color * shownDraw;
|
||||
|
||||
vec3 finalColor;
|
||||
#if CRT_CHROMA == 1
|
||||
vec3 foregroundColor = mix(fontColor.rgb, txt_color * fontColor.rgb / greyscale_color, chromaColor);
|
||||
finalColor = mix(backgroundColor.rgb, foregroundColor, greyscale_color * shownDraw);
|
||||
#else
|
||||
finalColor = mix(backgroundColor.rgb, fontColor.rgb, greyscale_color * shownDraw);
|
||||
#endif
|
||||
|
||||
vec3 bloomColor = finalColor;
|
||||
vec3 bloomColor = txt_color;
|
||||
float bloomAlpha = 0.0;
|
||||
#if CRT_BLOOM == 1 || CRT_FRAME_SHININESS == 1
|
||||
vec4 bloomFullColor = texture(bloomSource, txt_coords);
|
||||
bloomColor = convertWithChroma(bloomFullColor.rgb);
|
||||
bloomColor = bloomFullColor.rgb;
|
||||
bloomAlpha = bloomFullColor.a;
|
||||
#endif
|
||||
|
||||
#if CRT_BLOOM == 1
|
||||
vec3 bloomOnScreen = bloomColor * isScreen;
|
||||
finalColor += clamp(bloomOnScreen * bloom * bloomAlpha, 0.0, 0.5);
|
||||
float bloomScale = 1.0 + max(bloom, 0.0);
|
||||
finalColor /= bloomScale;
|
||||
#endif
|
||||
|
||||
#if CRT_FRAME_SHININESS == 1
|
||||
vec3 reflectionColor = mix(backgroundColor.rgb + bloomColor, finalColor, frameShininess * 0.5);
|
||||
vec3 reflectionColor = mix(bloomColor, finalColor, frameShininess * 0.5);
|
||||
finalColor = mix(finalColor, reflectionColor, isReflection);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@ layout(location = 1) in vec2 qt_MultiTexCoord0;
|
||||
layout(std140, binding = 0) uniform ubuf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
vec4 fontColor;
|
||||
vec4 backgroundColor;
|
||||
float screenCurvature;
|
||||
float chromaColor;
|
||||
float rbgShift;
|
||||
float frameShininess;
|
||||
float frameSize;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user