Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/overlay/shaders/image_frag.glsl')
-rw-r--r--source/blender/draw/engines/overlay/shaders/image_frag.glsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/draw/engines/overlay/shaders/image_frag.glsl b/source/blender/draw/engines/overlay/shaders/image_frag.glsl
new file mode 100644
index 00000000000..0da7067851d
--- /dev/null
+++ b/source/blender/draw/engines/overlay/shaders/image_frag.glsl
@@ -0,0 +1,34 @@
+
+uniform sampler2D imgTexture;
+uniform bool imgPremultiplied;
+uniform bool imgAlphaBlend;
+uniform bool imgLinear;
+uniform vec4 color;
+
+in vec2 uvs;
+
+out vec4 fragColor;
+
+void main()
+{
+ vec2 uvs_clamped = clamp(uvs, 0.0, 1.0);
+ vec4 tex_color;
+ if (imgLinear) {
+ tex_color = texture_read_as_linearrgb(imgTexture, imgPremultiplied, uvs_clamped);
+ }
+ else {
+ tex_color = texture_read_as_srgb(imgTexture, imgPremultiplied, uvs_clamped);
+ }
+ fragColor = tex_color * color;
+
+ if (!imgAlphaBlend) {
+ /* Arbitrary discard anything below 5% opacity.
+ * Note that this could be exposed to the User. */
+ if (tex_color.a < 0.05) {
+ discard;
+ }
+ else {
+ fragColor.a = 1.0;
+ }
+ }
+}