diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-01-09 19:58:13 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-01-09 19:58:13 +0300 |
commit | 5ed5ed59c36695882ea2b6880abd5cd996fe2416 (patch) | |
tree | 60f230d54bc85d491bd1b8af6a4cfeb75bb09ff2 /source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl | |
parent | e42e1769b36fddf9b0c161bcb2f7c7f2aeb613eb (diff) |
Fix T49861: Interlace stereo drawing
This does not address stapling shader in 2.8, though the solution can be
similar (own shader, not polutting interlace shader).
part of T49043
Reviewers: merwin
Differential Revision: https://developer.blender.org/D2440
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl new file mode 100644 index 00000000000..8b303104bb3 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl @@ -0,0 +1,52 @@ + +/* Keep these in sync with GPU_shader.h */ +#define INTERLACE_ROW 0 +#define INTERLACE_COLUMN 1 +#define INTERLACE_CHECKERBOARD 2 + +#if __VERSION__ == 120 + varying vec2 texCoord_interp; + #define fragColor gl_FragColor +#else + in vec2 texCoord_interp; + out vec4 fragColor; + #define texture2DRect texture +#endif + +uniform int interlace_id; +uniform sampler2DRect image_a; +uniform sampler2DRect image_b; + +bool interlace() +{ +#if __VERSION__ == 120 + if (interlace_id == INTERLACE_CHECKERBOARD) { + return int(mod(gl_FragCoord.x + gl_FragCoord.y, 2)) != 0; + } + else if (interlace_id == INTERLACE_ROW) { + return int(mod(gl_FragCoord.y, 2)) != 0; + } + else if (interlace_id == INTERLACE_COLUMN) { + return int(mod(gl_FragCoord.x, 2)) != 0; + } +#else + if (interlace_id == INTERLACE_CHECKERBOARD) { + return (int(gl_FragCoord.x + gl_FragCoord.y) & 1) != 0; + } + else if (interlace_id == INTERLACE_ROW) { + return (int(gl_FragCoord.y) & 1) != 0; + } + else if (interlace_id == INTERLACE_COLUMN) { + return (int(gl_FragCoord.x) & 1) != 0; + } +#endif +} + +void main() +{ + if (interlace()) { + fragColor = texture2DRect(image_a, texCoord_interp); + } else { + fragColor = texture2DRect(image_b, texCoord_interp); + } +} |