diff options
author | Carlo Andreacchio <carlorules@gmail.com> | 2014-05-07 18:36:44 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-05-07 18:43:50 +0400 |
commit | 8b8d5a441f5815e83f83bacf8023e2cc3fbb2a04 (patch) | |
tree | 777b695333e690b56f501f9fe037f650c0e50a69 /intern/cycles/render/image.cpp | |
parent | 1d03a8b30932e6a4c4e511eef3f543590b0bcd2a (diff) |
Cycles: add support for "Use Alpha" option on image datablocks.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D486
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r-- | intern/cycles/render/image.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 6348c9e6706..8dde642f70b 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -152,7 +152,7 @@ static bool image_equals(ImageManager::Image *image, const string& filename, voi image->interpolation == interpolation; } -int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation) +int ImageManager::add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation, bool use_alpha) { Image *img; size_t slot; @@ -194,6 +194,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani img->animated = animated; img->interpolation = interpolation; img->users = 1; + img->use_alpha = use_alpha; float_images[slot] = img; } @@ -230,6 +231,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani img->animated = animated; img->interpolation = interpolation; img->users = 1; + img->use_alpha = use_alpha; images[slot] = img; @@ -307,9 +309,13 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img) if(!in) return false; - ImageSpec spec; + ImageSpec spec = ImageSpec(); + ImageSpec config = ImageSpec(); + + if(img->use_alpha == false) + config.attribute("oiio:UnassociatedAlpha", 1); - if(!in->open(img->filename, spec)) { + if(!in->open(img->filename, spec, config)) { delete in; return false; } @@ -387,6 +393,12 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img) } } + if(img->use_alpha == false) { + for(int i = width*height*depth-1; i >= 0; i--) { + pixels[i*4+3] = 255; + } + } + return true; } @@ -405,9 +417,13 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_ if(!in) return false; - ImageSpec spec; + ImageSpec spec = ImageSpec(); + ImageSpec config = ImageSpec(); + + if(img->use_alpha == false) + config.attribute("oiio:UnassociatedAlpha",1); - if(!in->open(img->filename, spec)) { + if(!in->open(img->filename, spec, config)) { delete in; return false; } @@ -484,6 +500,12 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_ } } + if(img->use_alpha == false) { + for(int i = width*height*depth-1; i >= 0; i--) { + pixels[i*4+3] = 1.0f; + } + } + return true; } |