~martijnbraam/megapixels

7a3e470b296f10a109b985f8053e627e16c49bc2 — Martijn Braam 1 year, 2 months ago b29f04c
Reverse the matrix and srgb conversion for the preview

The sRGB curve should be applied after the color matrices
1 files changed, 3 insertions(+), 2 deletions(-)

M data/debayer.frag
M data/debayer.frag => data/debayer.frag +3 -2
@@ 23,12 23,13 @@ void main() {
	// Assume BGGR for now. Currently this just takes 3 of the four samples
	// for each pixel, there's room here to do some better debayering.
	vec3 color = vec3(samples.w, (samples.y + samples.z) / 2.0, samples.x);
	vec3 corrected = color * color_matrix;

	// Fast SRGB estimate. See https://mimosa-pudica.net/fast-gamma/
	vec3 srgb_color = (vec3(1.138) * inversesqrt(color) - vec3(0.138)) * color;
	vec3 srgb_color = (vec3(1.138) * inversesqrt(corrected) - vec3(0.138)) * corrected;

	// Slow SRGB estimate
	// vec3 srgb_color = pow(color, vec3(1.0 / 2.2));

	gl_FragColor = vec4(color_matrix * srgb_color, 1);
	gl_FragColor = vec4(srgb_color, 1);
}