diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-17 18:47:58 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-17 18:47:58 +0400 |
commit | cf0e457e524cfc9f496705de6cbf1e41c5118828 (patch) | |
tree | 55008245844f7c617ee5fe6e113a775778acb4b0 /intern/cycles/kernel/shaders | |
parent | 0fc4f4b7916aaec09228a54fac16b9618c192f6a (diff) |
Fix #35004: fireflies with .tif image in cycles, try to avoid extreme values when
openimageio can't detect premul/straight alpha correct.
Diffstat (limited to 'intern/cycles/kernel/shaders')
-rw-r--r-- | intern/cycles/kernel/shaders/node_environment_texture.osl | 7 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/node_image_texture.osl | 17 |
2 files changed, 17 insertions, 7 deletions
diff --git a/intern/cycles/kernel/shaders/node_environment_texture.osl b/intern/cycles/kernel/shaders/node_environment_texture.osl index 36b2f755c20..bddef418c3d 100644 --- a/intern/cycles/kernel/shaders/node_environment_texture.osl +++ b/intern/cycles/kernel/shaders/node_environment_texture.osl @@ -48,6 +48,7 @@ shader node_environment_texture( string filename = "", string projection = "Equirectangular", string color_space = "sRGB", + int is_float = 1, output color Color = 0.0, output float Alpha = 1.0) { @@ -66,9 +67,13 @@ shader node_environment_texture( /* todo: use environment for better texture filtering of equirectangular */ Color = (color)texture(filename, p[0], 1.0 - p[1], "wrap", "periodic", "alpha", Alpha); - if (isconnected(Alpha)) + if (isconnected(Alpha)) { Color = color_unpremultiply(Color, Alpha); + if (!is_float) + Color = min(Color, 1.0); + } + if (color_space == "sRGB") Color = color_srgb_to_scene_linear(Color); } diff --git a/intern/cycles/kernel/shaders/node_image_texture.osl b/intern/cycles/kernel/shaders/node_image_texture.osl index c7ec8726ae2..6ccc7ebc651 100644 --- a/intern/cycles/kernel/shaders/node_image_texture.osl +++ b/intern/cycles/kernel/shaders/node_image_texture.osl @@ -19,12 +19,16 @@ #include "stdosl.h" #include "node_color.h" -color image_texture_lookup(string filename, string color_space, float u, float v, output float Alpha, int use_alpha) +color image_texture_lookup(string filename, string color_space, float u, float v, output float Alpha, int use_alpha, int is_float) { color rgb = (color)texture(filename, u, 1.0 - v, "wrap", "periodic", "alpha", Alpha); - if (use_alpha) + if (use_alpha) { rgb = color_unpremultiply(rgb, Alpha); + + if (!is_float) + rgb = min(rgb, 1.0); + } if (color_space == "sRGB") rgb = color_srgb_to_scene_linear(rgb); @@ -40,6 +44,7 @@ shader node_image_texture( string color_space = "sRGB", string projection = "Flat", float projection_blend = 0.0, + int is_float = 1, output color Color = 0.0, output float Alpha = 1.0) { @@ -51,7 +56,7 @@ shader node_image_texture( int use_alpha = isconnected(Alpha); if (projection == "Flat") { - Color = image_texture_lookup(filename, color_space, p[0], p[1], Alpha, use_alpha); + Color = image_texture_lookup(filename, color_space, p[0], p[1], Alpha, use_alpha, is_float); } else if (projection == "Box") { /* object space normal */ @@ -116,15 +121,15 @@ shader node_image_texture( float tmp_alpha; if (weight[0] > 0.0) { - Color += weight[0] * image_texture_lookup(filename, color_space, p[1], p[2], tmp_alpha, use_alpha); + Color += weight[0] * image_texture_lookup(filename, color_space, p[1], p[2], tmp_alpha, use_alpha, is_float); Alpha += weight[0] * tmp_alpha; } if (weight[1] > 0.0) { - Color += weight[1] * image_texture_lookup(filename, color_space, p[0], p[2], tmp_alpha, use_alpha); + Color += weight[1] * image_texture_lookup(filename, color_space, p[0], p[2], tmp_alpha, use_alpha, is_float); Alpha += weight[1] * tmp_alpha; } if (weight[2] > 0.0) { - Color += weight[2] * image_texture_lookup(filename, color_space, p[1], p[0], tmp_alpha, use_alpha); + Color += weight[2] * image_texture_lookup(filename, color_space, p[1], p[0], tmp_alpha, use_alpha, is_float); Alpha += weight[2] * tmp_alpha; } } |