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/draw/modes/shaders/object_empty_image_frag.glsl
Clément Foucault c5fc861172 Fix T58550 Dragged in images dont overlap properly
This patch adds a new "Use Alpha" option on image empties to avoid ordering
issue of reference images.

If ordering is not important, "Use Alpha" can be enabled to provide
transparency and alpha blending support.
2019-03-20 16:33:49 +01:00

47 lines
767 B
GLSL

flat in vec4 finalColor;
#ifndef USE_WIRE
in vec2 texCoord_interp;
#endif
out vec4 fragColor;
#ifndef USE_WIRE
uniform sampler2D image;
#endif
uniform int depthMode;
uniform bool useAlphaTest;
void main()
{
#ifdef USE_WIRE
fragColor = finalColor;
#else
vec4 tex_col = texture(image, texCoord_interp);
fragColor = finalColor * tex_col;
if (useAlphaTest) {
/* Arbitrary discard anything below 5% opacity.
* Note that this could be exposed to the User. */
if (tex_col.a < 0.05) {
discard;
}
else {
fragColor.a = 1.0;
}
}
#endif
if (depthMode == DEPTH_BACK) {
gl_FragDepth = 0.999999;
}
else if (depthMode == DEPTH_FRONT) {
gl_FragDepth = 0.000001;
}
else if (depthMode == DEPTH_UNCHANGED) {
gl_FragDepth = gl_FragCoord.z;
}
}