This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_image_interlace_frag.glsl
Dalai Felinto 5ed5ed59c3 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
2017-01-09 17:58:13 +01:00

53 lines
1.2 KiB
GLSL

/* 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);
}
}