forked from bartvdbraak/blender
Cycles: add support for "Use Alpha" option on image datablocks.
Reviewed By: brecht Differential Revision: https://developer.blender.org/D486
This commit is contained in:
parent
1d03a8b309
commit
8b8d5a441f
@ -222,7 +222,7 @@ static void create_mesh_volume_attribute(BL::Object b_ob, Mesh *mesh, ImageManag
|
|||||||
|
|
||||||
volume_data->manager = image_manager;
|
volume_data->manager = image_manager;
|
||||||
volume_data->slot = image_manager->add_image(Attribute::standard_name(std),
|
volume_data->slot = image_manager->add_image(Attribute::standard_name(std),
|
||||||
b_ob.ptr.data, animated, is_float, is_linear, INTERPOLATION_LINEAR);
|
b_ob.ptr.data, animated, is_float, is_linear, INTERPOLATION_LINEAR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_mesh_volume_attributes(Scene *scene, BL::Object b_ob, Mesh *mesh)
|
static void create_mesh_volume_attributes(Scene *scene, BL::Object b_ob, Mesh *mesh)
|
||||||
|
@ -548,6 +548,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
|
|||||||
image->animated = b_image_node.image_user().use_auto_refresh();
|
image->animated = b_image_node.image_user().use_auto_refresh();
|
||||||
}
|
}
|
||||||
image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
|
image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
|
||||||
|
image->use_alpha = b_image.use_alpha();
|
||||||
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
|
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
|
||||||
image->interpolation = (InterpolationType)b_image_node.interpolation();
|
image->interpolation = (InterpolationType)b_image_node.interpolation();
|
||||||
image->projection_blend = b_image_node.projection_blend();
|
image->projection_blend = b_image_node.projection_blend();
|
||||||
@ -576,6 +577,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
|
env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
|
||||||
|
env->use_alpha = b_image.use_alpha();
|
||||||
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
|
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
|
||||||
get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
|
get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
|
||||||
node = env;
|
node = env;
|
||||||
|
@ -152,7 +152,7 @@ static bool image_equals(ImageManager::Image *image, const string& filename, voi
|
|||||||
image->interpolation == interpolation;
|
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;
|
Image *img;
|
||||||
size_t slot;
|
size_t slot;
|
||||||
@ -194,6 +194,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani
|
|||||||
img->animated = animated;
|
img->animated = animated;
|
||||||
img->interpolation = interpolation;
|
img->interpolation = interpolation;
|
||||||
img->users = 1;
|
img->users = 1;
|
||||||
|
img->use_alpha = use_alpha;
|
||||||
|
|
||||||
float_images[slot] = img;
|
float_images[slot] = img;
|
||||||
}
|
}
|
||||||
@ -230,6 +231,7 @@ int ImageManager::add_image(const string& filename, void *builtin_data, bool ani
|
|||||||
img->animated = animated;
|
img->animated = animated;
|
||||||
img->interpolation = interpolation;
|
img->interpolation = interpolation;
|
||||||
img->users = 1;
|
img->users = 1;
|
||||||
|
img->use_alpha = use_alpha;
|
||||||
|
|
||||||
images[slot] = img;
|
images[slot] = img;
|
||||||
|
|
||||||
@ -307,9 +309,13 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img)
|
|||||||
if(!in)
|
if(!in)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ImageSpec spec;
|
ImageSpec spec = ImageSpec();
|
||||||
|
ImageSpec config = ImageSpec();
|
||||||
|
|
||||||
if(!in->open(img->filename, spec)) {
|
if(img->use_alpha == false)
|
||||||
|
config.attribute("oiio:UnassociatedAlpha", 1);
|
||||||
|
|
||||||
|
if(!in->open(img->filename, spec, config)) {
|
||||||
delete in;
|
delete in;
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,9 +417,13 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_
|
|||||||
if(!in)
|
if(!in)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ImageSpec spec;
|
ImageSpec spec = ImageSpec();
|
||||||
|
ImageSpec config = ImageSpec();
|
||||||
|
|
||||||
if(!in->open(img->filename, spec)) {
|
if(img->use_alpha == false)
|
||||||
|
config.attribute("oiio:UnassociatedAlpha",1);
|
||||||
|
|
||||||
|
if(!in->open(img->filename, spec, config)) {
|
||||||
delete in;
|
delete in;
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
ImageManager();
|
ImageManager();
|
||||||
~ImageManager();
|
~ImageManager();
|
||||||
|
|
||||||
int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation);
|
int add_image(const string& filename, void *builtin_data, bool animated, bool& is_float, bool& is_linear, InterpolationType interpolation, bool use_alpha);
|
||||||
void remove_image(int slot);
|
void remove_image(int slot);
|
||||||
void remove_image(const string& filename, void *builtin_data, InterpolationType interpolation);
|
void remove_image(const string& filename, void *builtin_data, InterpolationType interpolation);
|
||||||
bool is_float_image(const string& filename, void *builtin_data, bool& is_linear);
|
bool is_float_image(const string& filename, void *builtin_data, bool& is_linear);
|
||||||
@ -72,6 +72,7 @@ public:
|
|||||||
string filename;
|
string filename;
|
||||||
void *builtin_data;
|
void *builtin_data;
|
||||||
|
|
||||||
|
bool use_alpha;
|
||||||
bool need_load;
|
bool need_load;
|
||||||
bool animated;
|
bool animated;
|
||||||
InterpolationType interpolation;
|
InterpolationType interpolation;
|
||||||
|
@ -189,6 +189,7 @@ ImageTextureNode::ImageTextureNode()
|
|||||||
slot = -1;
|
slot = -1;
|
||||||
is_float = -1;
|
is_float = -1;
|
||||||
is_linear = false;
|
is_linear = false;
|
||||||
|
use_alpha = true;
|
||||||
filename = "";
|
filename = "";
|
||||||
builtin_data = NULL;
|
builtin_data = NULL;
|
||||||
color_space = ustring("Color");
|
color_space = ustring("Color");
|
||||||
@ -242,7 +243,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
|
|||||||
image_manager = compiler.image_manager;
|
image_manager = compiler.image_manager;
|
||||||
if(is_float == -1) {
|
if(is_float == -1) {
|
||||||
bool is_float_bool;
|
bool is_float_bool;
|
||||||
slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation);
|
slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, interpolation, use_alpha);
|
||||||
is_float = (int)is_float_bool;
|
is_float = (int)is_float_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +358,7 @@ EnvironmentTextureNode::EnvironmentTextureNode()
|
|||||||
slot = -1;
|
slot = -1;
|
||||||
is_float = -1;
|
is_float = -1;
|
||||||
is_linear = false;
|
is_linear = false;
|
||||||
|
use_alpha = true;
|
||||||
filename = "";
|
filename = "";
|
||||||
builtin_data = NULL;
|
builtin_data = NULL;
|
||||||
color_space = ustring("Color");
|
color_space = ustring("Color");
|
||||||
@ -406,7 +408,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
|
|||||||
image_manager = compiler.image_manager;
|
image_manager = compiler.image_manager;
|
||||||
if(slot == -1) {
|
if(slot == -1) {
|
||||||
bool is_float_bool;
|
bool is_float_bool;
|
||||||
slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR);
|
slot = image_manager->add_image(filename, builtin_data, animated, is_float_bool, is_linear, INTERPOLATION_LINEAR, use_alpha);
|
||||||
is_float = (int)is_float_bool;
|
is_float = (int)is_float_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
int slot;
|
int slot;
|
||||||
int is_float;
|
int is_float;
|
||||||
bool is_linear;
|
bool is_linear;
|
||||||
|
bool use_alpha;
|
||||||
string filename;
|
string filename;
|
||||||
void *builtin_data;
|
void *builtin_data;
|
||||||
ustring color_space;
|
ustring color_space;
|
||||||
@ -95,6 +96,7 @@ public:
|
|||||||
int slot;
|
int slot;
|
||||||
int is_float;
|
int is_float;
|
||||||
bool is_linear;
|
bool is_linear;
|
||||||
|
bool use_alpha;
|
||||||
string filename;
|
string filename;
|
||||||
void *builtin_data;
|
void *builtin_data;
|
||||||
ustring color_space;
|
ustring color_space;
|
||||||
|
Loading…
Reference in New Issue
Block a user