Accommodate for changes to default sRGB textures and targets
This commit is contained in:
@@ -14,17 +14,17 @@ class Post : Extension {
|
||||
/**
|
||||
* The color type to use for the intermediate color buffers
|
||||
*/
|
||||
var intermediateType = ColorType.UINT8
|
||||
var intermediateType = ColorType.UINT8_SRGB
|
||||
|
||||
/**
|
||||
* The color type to use for the output color buffer
|
||||
*/
|
||||
var outputType = ColorType.UINT8
|
||||
var outputType = ColorType.UINT8_SRGB
|
||||
|
||||
/**
|
||||
* The color type to use for the input buffer
|
||||
*/
|
||||
var inputType = ColorType.UINT8
|
||||
var inputType = ColorType.UINT8_SRGB
|
||||
|
||||
/**
|
||||
* The depth format to use for the input buffer
|
||||
|
||||
@@ -16,29 +16,9 @@ in vec2 v_texCoord0;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
uniform bool linearizeInputA;
|
||||
uniform bool linearizeInputB;
|
||||
uniform bool delinearizeOutput;
|
||||
uniform float fill;
|
||||
uniform bool clip;
|
||||
|
||||
vec3 srgb_to_linear(vec3 c) {
|
||||
const float t = 0.00313066844250063;
|
||||
return vec3(
|
||||
c.r <= t ? c.r / 12.92 : pow((c.r + 0.055) / 1.055, 2.4),
|
||||
c.g <= t ? c.g / 12.92 : pow((c.g + 0.055) / 1.055, 2.4),
|
||||
c.b <= t ? c.b / 12.92 : pow((c.b + 0.055) / 1.055, 2.4));
|
||||
}
|
||||
|
||||
vec3 linear_to_srgb(vec3 c) {
|
||||
const float t = 0.00313066844250063;
|
||||
return vec3(
|
||||
c.r <= t ? c.r * 12.92 : 1.055 * pow(c.r, 1.0 / 2.4) - 0.055,
|
||||
c.g <= t ? c.g * 12.92 : 1.055 * pow(c.g, 1.0 / 2.4) - 0.055,
|
||||
c.b <= t ? c.b * 12.92 : 1.055 * pow(c.b, 1.0 / 2.4) - 0.055
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
@@ -48,13 +28,6 @@ void main() {
|
||||
vec4 nb = b.a == 0.0 ? vec4(0.0): vec4(b.rgb / b.a,b.a);
|
||||
|
||||
|
||||
if (linearizeInputA) {
|
||||
na.rgb = srgb_to_linear(na.rgb);
|
||||
}
|
||||
|
||||
if (linearizeInputB) {
|
||||
nb.rgb = srgb_to_linear(nb.rgb);
|
||||
}
|
||||
|
||||
vec4 mixed = vec4(spectral_mix(na.rgb, nb.rgb, min(1.0, fill)), 1.0);
|
||||
|
||||
@@ -68,9 +41,6 @@ void main() {
|
||||
|
||||
mixed.rgb = mixed.a == 0.0 ? vec3(0.0): mixed.rgb / mixed.a;
|
||||
|
||||
if (delinearizeOutput) {
|
||||
mixed.rgb = linear_to_srgb(mixed.rgb);
|
||||
}
|
||||
|
||||
// premultiply alpha
|
||||
mixed.rgb *= mixed.a;
|
||||
|
||||
@@ -18,8 +18,6 @@ private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur"
|
||||
var vignette: Double by parameters
|
||||
var vignetteSize: Double by parameters
|
||||
var aberration: Double by parameters
|
||||
var linearInput: Boolean by parameters
|
||||
var linearOutput: Boolean by parameters
|
||||
|
||||
init {
|
||||
radius = 0.0
|
||||
@@ -29,8 +27,6 @@ private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur"
|
||||
vignette = 0.0
|
||||
vignetteSize = 1.0
|
||||
aberration = 0.0
|
||||
linearInput = false
|
||||
linearOutput = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +56,6 @@ class LaserBlur : Filter1to1() {
|
||||
@DoubleParameter("exp", -1.0, 1.0, order = 7)
|
||||
var exp = 0.739
|
||||
|
||||
@BooleanParameter("linear input", order = 8)
|
||||
var linearInput = false
|
||||
|
||||
@BooleanParameter("linear output", order = 9)
|
||||
var linearOutput = false
|
||||
|
||||
@DoubleParameter("phase", -1.0, 1.0, order = 7)
|
||||
var phase = 0.0
|
||||
|
||||
@@ -99,19 +89,13 @@ class LaserBlur : Filter1to1() {
|
||||
|
||||
pass.radius = 1.0 + pow(exp, 0.0) * radius
|
||||
|
||||
pass.linearInput = linearInput
|
||||
pass.linearOutput = true
|
||||
pass.apply(source[0], intermediates[0], clip)
|
||||
for (i in 0 until passes - 1) {
|
||||
pass.linearInput = true
|
||||
pass.linearOutput = true
|
||||
|
||||
pass.radius = 1.0 + pow(exp, i + 1.0) * radius //(1.0 + simplex(0, phase + i)) / 2.0
|
||||
pass.apply(intermediates[i % 2], intermediates[(i + 1) % 2], clip)
|
||||
}
|
||||
pass.radius = 1.0 + pow(exp, (passes) * 1.0) * radius
|
||||
pass.linearInput = true
|
||||
pass.linearOutput = linearOutput
|
||||
pass.apply(intermediates[(passes + 1) % 2], target[0], clip)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,6 @@ class VideoGlitch : Filter1to1(mppFilterShader(fx_video_glitch, "video-glitch"))
|
||||
@DoubleParameter("scroll offset 1", 0.0, 1.0)
|
||||
var scrollOffset1: Double by parameters
|
||||
|
||||
@BooleanParameter("linear input")
|
||||
var linearInput: Boolean by parameters
|
||||
|
||||
@BooleanParameter("linear output")
|
||||
var linearOutput: Boolean by parameters
|
||||
|
||||
init {
|
||||
amplitude = 1.0
|
||||
vfreq = 4.0
|
||||
@@ -52,7 +46,5 @@ class VideoGlitch : Filter1to1(mppFilterShader(fx_video_glitch, "video-glitch"))
|
||||
scrollOffset0 = 0.0
|
||||
scrollOffset1 = 0.0
|
||||
borderHeight = 0.05
|
||||
linearInput = false
|
||||
linearOutput = false
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,9 @@ uniform vec2 center;
|
||||
uniform float vignette;
|
||||
uniform float vignetteSize;
|
||||
uniform float aberration;
|
||||
uniform bool linearInput;
|
||||
uniform bool linearOutput;
|
||||
|
||||
void main() {
|
||||
vec4 i0 = texture(tex0, v_texCoord0);
|
||||
if (!linearInput) {
|
||||
i0.rgb = pow(i0.rgb, vec3(2.2));
|
||||
}
|
||||
vec2 vt = (v_texCoord0 - vec2(0.5, 0.5) + center) * radius + vec2(0.5, 0.5) - center;
|
||||
|
||||
vec2 size = vec2(textureSize(tex0, 0));
|
||||
@@ -32,16 +27,10 @@ void main() {
|
||||
i1b.rgb = i1b.a > 0.0 ? i1b.rgb / i1b.a : vec3(0.0);
|
||||
|
||||
vec4 i1 = vec4(i1r.r, i1g.g, i1b.b, 1.0) * (i1r.a + i1g.a + i1b.a) / 3.0;
|
||||
if (!linearInput) {
|
||||
i1.rgb = pow(i1.rgb, vec3(2.2));
|
||||
}
|
||||
o_output = i0 * amp0 + i1 * amp1;
|
||||
} else {
|
||||
o_output = i0 * 0.5;
|
||||
}
|
||||
|
||||
o_output.rgb *= mix(1.0, smoothstep(vignetteSize, 0.0, d), vignette);
|
||||
if (!linearOutput) {
|
||||
o_output.rgb = pow(o_output.rgb, vec3(1.0 / 2.2));
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,12 @@ void main() {
|
||||
if (!labInterpolation) {
|
||||
o_color = mix(bg, fg, c.r) * c.a;
|
||||
} else {
|
||||
bg = srgb_to_linear_rgb(bg);
|
||||
bg = linear_rgb_to_oklab(bg);
|
||||
fg = srgb_to_linear_rgb(fg);
|
||||
fg = linear_rgb_to_oklab(fg);
|
||||
|
||||
vec4 m = mix(bg, fg, c.r);
|
||||
m = oklab_to_linear_rgb(m);
|
||||
m *= c.a;
|
||||
m = linear_rgb_to_srgb(m);
|
||||
o_color = m;
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,6 @@ uniform float scrollOffset1;
|
||||
|
||||
uniform float borderHeight;
|
||||
|
||||
uniform bool linearInput;
|
||||
uniform bool linearOutput;
|
||||
|
||||
#define HASHSCALE 443.8975
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
|
||||
@@ -49,20 +46,11 @@ void main() {
|
||||
if (aa > 0.0 || ds > 0.0) {
|
||||
for (int i = 1; i < 16; ++i) {
|
||||
vec4 lc = getVideo(v_texCoord0 + vec2(0.0, scrollOffset0+ds*float(i)), aa, time-float(i)/(16.0*60.0));
|
||||
if (!linearInput) {
|
||||
lc.rgb = pow(lc.rgb, vec3(2.2));
|
||||
}
|
||||
c += lc * (3.0/16.0) * aberrationColor(float(i)/16.0);
|
||||
}
|
||||
o_output = c;
|
||||
} else {
|
||||
vec4 lc = texture(tex0, mod(v_texCoord0 + vec2(0.0, scrollOffset1), vec2(1.0)));
|
||||
if (!linearInput) {
|
||||
lc.rgb = pow(lc.rgb, vec3(2.2));
|
||||
}
|
||||
o_output = lc;
|
||||
}
|
||||
if (!linearOutput) {
|
||||
o_output.rgb = pow(o_output.rgb, vec3(1.0/2.2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ vec3 ACESFilm(vec3 x) {
|
||||
void main() {
|
||||
vec3 texColor = texture(tex0,v_texCoord0).rgb;
|
||||
vec3 color = ACESFilm(texColor * exposureBias);
|
||||
vec3 retColor = pow(color, vec3(1.0/2.2));
|
||||
o_output = vec4(retColor, 1.0);
|
||||
|
||||
o_output = vec4(color, 1.0);
|
||||
}
|
||||
@@ -22,6 +22,5 @@ void main() {
|
||||
vec3 whiteScale = 1.0f/Uncharted2Tonemap(vec3(W));
|
||||
vec3 color = curr*whiteScale;
|
||||
|
||||
vec3 retColor = pow(color, vec3(1.0/2.2));
|
||||
o_output = vec4(retColor, 1);
|
||||
o_output = vec4(color, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user