diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-14 18:24:20 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-14 19:01:48 +0400 |
commit | cccd06ea447f8418b03b5bec79f6f0230d793952 (patch) | |
tree | 794e04dee8dfde6b1ae36dc6890012ad13e45917 /intern/opencolorio/gpu_shader_display_transform.glsl | |
parent | 05fe9a435af75239439c853906425b54eea42fb5 (diff) |
Fix T37810: GLSL dither shader not working on OS X.
The GLSL function textureSize() is not supported here, only when we start using
OpenGL core profile will this work. For now check the supported GLSL version and
use a somewhat slower replacement.
Diffstat (limited to 'intern/opencolorio/gpu_shader_display_transform.glsl')
-rw-r--r-- | intern/opencolorio/gpu_shader_display_transform.glsl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/intern/opencolorio/gpu_shader_display_transform.glsl b/intern/opencolorio/gpu_shader_display_transform.glsl index 8a85d6cbffe..5921d6d9c73 100644 --- a/intern/opencolorio/gpu_shader_display_transform.glsl +++ b/intern/opencolorio/gpu_shader_display_transform.glsl @@ -1,11 +1,15 @@ uniform sampler2D image_texture; uniform sampler3D lut3d_texture; -uniform bool predivide; #ifdef USE_DITHER uniform float dither; #endif +#ifdef USE_TEXTURE_SIZE +uniform float image_texture_width; +uniform float image_texture_height; +#endif + #ifdef USE_CURVE_MAPPING /* Curve mapping parameters * @@ -115,7 +119,11 @@ float dither_random_value(vec2 co) vec2 round_to_pixel(vec2 st) { vec2 result; +#ifdef USE_TEXTURE_SIZE + vec2 size = vec2(image_texture_width, image_texture_height); +#else vec2 size = textureSize(image_texture, 0); +#endif result.x = float(int(st.x * size.x)) / size.x; result.y = float(int(st.y * size.y)) / size.y; return result; @@ -139,12 +147,15 @@ void main() #ifdef USE_CURVE_MAPPING col = curvemapping_evaluate_premulRGBF(col); #endif - if (predivide && col[3] > 0.0 && col[3] < 1.0) { + +#ifdef USE_PREDIVIDE + if (col[3] > 0.0 && col[3] < 1.0) { float inv_alpha = 1.0 / col[3]; col[0] *= inv_alpha; col[1] *= inv_alpha; col[2] *= inv_alpha; } +#endif /* NOTE: This is true we only do de-premul here and NO premul * and the reason is simple -- opengl is always configured |