mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-26 11:00:06 +00:00
host_shaders: Improve anaglyph quality
* Use matrices optimized for LCD displays
This commit is contained in:
parent
ea928374a6
commit
96c375229b
@ -4,17 +4,16 @@
|
||||
|
||||
//? #version 430 core
|
||||
|
||||
// Anaglyph Red-Cyan shader based on Dubois algorithm
|
||||
// Constants taken from the paper:
|
||||
// "Conversion of a Stereo Pair to Anaglyph with
|
||||
// the Least-Squares Projection Method"
|
||||
// Eric Dubois, March 2009
|
||||
const mat3 l = mat3( 0.437, 0.449, 0.164,
|
||||
-0.062,-0.062,-0.024,
|
||||
-0.048,-0.050,-0.017);
|
||||
const mat3 r = mat3(-0.011,-0.032,-0.007,
|
||||
0.377, 0.761, 0.009,
|
||||
-0.026,-0.093, 1.234);
|
||||
// https://cybereality.com/rendepth-red-cyan-anaglyph-filter-optimized-for-stereoscopic-3d-on-lcd-monitors/
|
||||
const mat3 left_filter = mat3(
|
||||
vec3(0.4561, 0.500484, 0.176381),
|
||||
vec3(-0.400822, -0.0378246, -0.0157589),
|
||||
vec3(-0.0152161, -0.0205971, -0.00546856));
|
||||
|
||||
const mat3 right_filter = mat3(
|
||||
vec3(-0.0434706, -0.0879388, -0.00155529),
|
||||
vec3(0.378476, 0.73364, -0.0184503),
|
||||
vec3(-0.0721527, -0.112961, 1.2264));
|
||||
|
||||
layout(location = 0) in vec2 frag_tex_coord;
|
||||
layout(location = 0) out vec4 color;
|
||||
@ -25,8 +24,20 @@ layout(binding = 1) uniform sampler2D color_texture_r;
|
||||
uniform vec4 resolution;
|
||||
uniform int layer;
|
||||
|
||||
void main() {
|
||||
vec4 color_tex_l = texture(color_texture, frag_tex_coord);
|
||||
vec4 color_tex_r = texture(color_texture_r, frag_tex_coord);
|
||||
color = vec4(color_tex_l.rgb*l+color_tex_r.rgb*r, color_tex_l.a);
|
||||
const vec3 gamma_map = vec3(1.6, 0.8, 1.0);
|
||||
|
||||
vec3 correct_color(vec3 original) {
|
||||
vec3 corrected;
|
||||
corrected.r = pow(original.r, 1.0 / gamma_map.r);
|
||||
corrected.g = pow(original.g, 1.0 / gamma_map.g);
|
||||
corrected.b = pow(original.b, 1.0 / gamma_map.b);
|
||||
return corrected;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color_left = texture(color_texture, frag_tex_coord);
|
||||
vec4 color_right = texture(color_texture_r, frag_tex_coord);
|
||||
vec3 optimized_color = clamp(color_left.rgb * left_filter, vec3(0.0), vec3(1.0)) +
|
||||
clamp(color_right.rgb * right_filter, vec3(0.0), vec3(1.0));
|
||||
color = vec4(correct_color(optimized_color), color_left.a);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user