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/gpencil/shaders/gpencil_point_frag.glsl')
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl27
1 files changed, 24 insertions, 3 deletions
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index cc47e12b303..98c47b1f1f0 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
@@ -47,6 +47,27 @@ vec2 check_box_point(vec2 pt, vec2 radius)
return rtn;
}
+float linearrgb_to_srgb(float c)
+{
+ if (c < 0.0031308) {
+ return (c < 0.0) ? 0.0 : c * 12.92;
+ }
+ else {
+ return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
+ }
+}
+
+vec4 texture_read_as_srgb(sampler2D tex, vec2 co)
+{
+ /* By convention image textures return scene linear colors, but
+ * grease pencil still works in srgb. */
+ vec4 color = texture2D(tex, co);
+ color.r = linearrgb_to_srgb(color.r);
+ color.g = linearrgb_to_srgb(color.g);
+ color.b = linearrgb_to_srgb(color.b);
+ return color;
+}
+
void main()
{
vec2 centered = mTexCoord - vec2(0.5);
@@ -65,7 +86,7 @@ void main()
}
}
- vec4 tmp_color = texture2D(myTexture, mTexCoord);
+ vec4 tmp_color = texture_read_as_srgb(myTexture, mTexCoord);
/* Solid */
if ((color_type == GPENCIL_COLOR_SOLID) || (no_texture)) {
@@ -73,7 +94,7 @@ void main()
}
/* texture */
if ((color_type == GPENCIL_COLOR_TEXTURE) && (!no_texture)) {
- vec4 text_color = texture2D(myTexture, mTexCoord);
+ vec4 text_color = texture_read_as_srgb(myTexture, mTexCoord);
if (mix_stroke_factor > 0.0) {
fragColor.rgb = mix(text_color.rgb, colormix.rgb, mix_stroke_factor);
fragColor.a = text_color.a;
@@ -87,7 +108,7 @@ void main()
}
/* pattern */
if ((color_type == GPENCIL_COLOR_PATTERN) && (!no_texture)) {
- vec4 text_color = texture2D(myTexture, mTexCoord);
+ vec4 text_color = texture_read_as_srgb(myTexture, mTexCoord);
fragColor = mColor;
/* mult both alpha factor to use strength factor with color alpha limit */
fragColor.a = min(text_color.a * mColor.a, mColor.a);