forked from bartvdbraak/blender
Cleanup: add ImageKey to avoid longer argument lists and duplicated code
This commit is contained in:
parent
78391def6e
commit
d675cf20a1
@ -640,6 +640,14 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
BL::Image b_image(b_image_node.image());
|
BL::Image b_image(b_image_node.image());
|
||||||
BL::ImageUser b_image_user(b_image_node.image_user());
|
BL::ImageUser b_image_user(b_image_node.image_user());
|
||||||
ImageTextureNode *image = new ImageTextureNode();
|
ImageTextureNode *image = new ImageTextureNode();
|
||||||
|
|
||||||
|
image->interpolation = get_image_interpolation(b_image_node);
|
||||||
|
image->extension = get_image_extension(b_image_node);
|
||||||
|
image->projection = (NodeImageProjection)b_image_node.projection();
|
||||||
|
image->projection_blend = b_image_node.projection_blend();
|
||||||
|
BL::TexMapping b_texture_mapping(b_image_node.texture_mapping());
|
||||||
|
get_tex_mapping(&image->tex_mapping, b_texture_mapping);
|
||||||
|
|
||||||
if (b_image) {
|
if (b_image) {
|
||||||
/* builtin images will use callback-based reading because
|
/* builtin images will use callback-based reading because
|
||||||
* they could only be loaded correct from blender side
|
* they could only be loaded correct from blender side
|
||||||
@ -682,21 +690,10 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
/* TODO(sergey): Does not work properly when we change builtin type. */
|
/* TODO(sergey): Does not work properly when we change builtin type. */
|
||||||
#if 0
|
#if 0
|
||||||
if (b_image.is_updated()) {
|
if (b_image.is_updated()) {
|
||||||
scene->image_manager->tag_reload_image(image->filename.string(),
|
scene->image_manager->tag_reload_image(image->image_key());
|
||||||
image->builtin_data,
|
|
||||||
get_image_interpolation(b_image_node),
|
|
||||||
get_image_extension(b_image_node),
|
|
||||||
image->use_alpha,
|
|
||||||
image->colorspace);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
image->projection = (NodeImageProjection)b_image_node.projection();
|
|
||||||
image->interpolation = get_image_interpolation(b_image_node);
|
|
||||||
image->extension = get_image_extension(b_image_node);
|
|
||||||
image->projection_blend = b_image_node.projection_blend();
|
|
||||||
BL::TexMapping b_texture_mapping(b_image_node.texture_mapping());
|
|
||||||
get_tex_mapping(&image->tex_mapping, b_texture_mapping);
|
|
||||||
node = image;
|
node = image;
|
||||||
}
|
}
|
||||||
else if (b_node.is_a(&RNA_ShaderNodeTexEnvironment)) {
|
else if (b_node.is_a(&RNA_ShaderNodeTexEnvironment)) {
|
||||||
@ -704,6 +701,12 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
BL::Image b_image(b_env_node.image());
|
BL::Image b_image(b_env_node.image());
|
||||||
BL::ImageUser b_image_user(b_env_node.image_user());
|
BL::ImageUser b_image_user(b_env_node.image_user());
|
||||||
EnvironmentTextureNode *env = new EnvironmentTextureNode();
|
EnvironmentTextureNode *env = new EnvironmentTextureNode();
|
||||||
|
|
||||||
|
env->interpolation = get_image_interpolation(b_env_node);
|
||||||
|
env->projection = (NodeEnvironmentProjection)b_env_node.projection();
|
||||||
|
BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
|
||||||
|
get_tex_mapping(&env->tex_mapping, b_texture_mapping);
|
||||||
|
|
||||||
if (b_image) {
|
if (b_image) {
|
||||||
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
|
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
|
||||||
b_image.source() == BL::Image::source_MOVIE ||
|
b_image.source() == BL::Image::source_MOVIE ||
|
||||||
@ -731,19 +734,10 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
/* TODO(sergey): Does not work properly when we change builtin type. */
|
/* TODO(sergey): Does not work properly when we change builtin type. */
|
||||||
#if 0
|
#if 0
|
||||||
if (b_image.is_updated()) {
|
if (b_image.is_updated()) {
|
||||||
scene->image_manager->tag_reload_image(env->filename.string(),
|
scene->image_manager->tag_reload_image(env->image_key());
|
||||||
env->builtin_data,
|
|
||||||
get_image_interpolation(b_env_node),
|
|
||||||
EXTENSION_REPEAT,
|
|
||||||
env->use_alpha,
|
|
||||||
env->colorspace);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
env->interpolation = get_image_interpolation(b_env_node);
|
|
||||||
env->projection = (NodeEnvironmentProjection)b_env_node.projection();
|
|
||||||
BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
|
|
||||||
get_tex_mapping(&env->tex_mapping, b_texture_mapping);
|
|
||||||
node = env;
|
node = env;
|
||||||
}
|
}
|
||||||
else if (b_node.is_a(&RNA_ShaderNodeTexGradient)) {
|
else if (b_node.is_a(&RNA_ShaderNodeTexGradient)) {
|
||||||
@ -896,12 +890,7 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
if (true) {
|
if (true) {
|
||||||
point_density->add_image();
|
point_density->add_image();
|
||||||
b_point_density_node.cache_point_density(b_depsgraph);
|
b_point_density_node.cache_point_density(b_depsgraph);
|
||||||
scene->image_manager->tag_reload_image(point_density->filename.string(),
|
scene->image_manager->tag_reload_image(point_density->image_key());
|
||||||
point_density->builtin_data,
|
|
||||||
point_density->interpolation,
|
|
||||||
EXTENSION_CLIP,
|
|
||||||
IMAGE_ALPHA_AUTO,
|
|
||||||
u_colorspace_raw);
|
|
||||||
}
|
}
|
||||||
node = point_density;
|
node = point_density;
|
||||||
|
|
||||||
|
@ -51,18 +51,13 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
|
|||||||
Attribute *attr = mesh->attributes.add(std);
|
Attribute *attr = mesh->attributes.add(std);
|
||||||
VoxelAttribute *volume_data = attr->data_voxel();
|
VoxelAttribute *volume_data = attr->data_voxel();
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
bool animated = false;
|
|
||||||
|
ImageKey key;
|
||||||
|
key.filename = Attribute::standard_name(std);
|
||||||
|
key.builtin_data = b_ob.ptr.data;
|
||||||
|
|
||||||
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(key, frame, metadata);
|
||||||
b_ob.ptr.data,
|
|
||||||
animated,
|
|
||||||
frame,
|
|
||||||
INTERPOLATION_LINEAR,
|
|
||||||
EXTENSION_CLIP,
|
|
||||||
IMAGE_ALPHA_AUTO,
|
|
||||||
u_colorspace_raw,
|
|
||||||
metadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a matrix to transform from object space to mesh texture space.
|
/* Create a matrix to transform from object space to mesh texture space.
|
||||||
|
@ -129,7 +129,7 @@ bool ImageManager::set_animation_frame_update(int frame)
|
|||||||
|
|
||||||
for (size_t type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
for (size_t type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
||||||
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
||||||
if (images[type][slot] && images[type][slot]->animated)
|
if (images[type][slot] && images[type][slot]->key.animated)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,17 +198,14 @@ void ImageManager::metadata_detect_colorspace(ImageMetaData &metadata, const cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageManager::get_image_metadata(const string &filename,
|
bool ImageManager::get_image_metadata(const ImageKey &key, ImageMetaData &metadata)
|
||||||
void *builtin_data,
|
|
||||||
ustring colorspace,
|
|
||||||
ImageMetaData &metadata)
|
|
||||||
{
|
{
|
||||||
metadata = ImageMetaData();
|
metadata = ImageMetaData();
|
||||||
metadata.colorspace = colorspace;
|
metadata.colorspace = key.colorspace;
|
||||||
|
|
||||||
if (builtin_data) {
|
if (key.builtin_data) {
|
||||||
if (builtin_image_info_cb) {
|
if (builtin_image_info_cb) {
|
||||||
builtin_image_info_cb(filename, builtin_data, metadata);
|
builtin_image_info_cb(key.filename, key.builtin_data, metadata);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
@ -227,23 +224,23 @@ bool ImageManager::get_image_metadata(const string &filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform preliminary checks, with meaningful logging. */
|
/* Perform preliminary checks, with meaningful logging. */
|
||||||
if (!path_exists(filename)) {
|
if (!path_exists(key.filename)) {
|
||||||
VLOG(1) << "File '" << filename << "' does not exist.";
|
VLOG(1) << "File '" << key.filename << "' does not exist.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (path_is_directory(filename)) {
|
if (path_is_directory(key.filename)) {
|
||||||
VLOG(1) << "File '" << filename << "' is a directory, can't use as image.";
|
VLOG(1) << "File '" << key.filename << "' is a directory, can't use as image.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<ImageInput> in(ImageInput::create(filename));
|
unique_ptr<ImageInput> in(ImageInput::create(key.filename));
|
||||||
|
|
||||||
if (!in) {
|
if (!in) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSpec spec;
|
ImageSpec spec;
|
||||||
if (!in->open(filename, spec)) {
|
if (!in->open(key.filename, spec)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,33 +291,12 @@ bool ImageManager::get_image_metadata(const string &filename,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool image_equals(ImageManager::Image *image,
|
int ImageManager::add_image(const ImageKey &key, float frame, ImageMetaData &metadata)
|
||||||
const string &filename,
|
|
||||||
void *builtin_data,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace)
|
|
||||||
{
|
|
||||||
return image->filename == filename && image->builtin_data == builtin_data &&
|
|
||||||
image->interpolation == interpolation && image->extension == extension &&
|
|
||||||
image->alpha_type == alpha_type && image->colorspace == colorspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ImageManager::add_image(const string &filename,
|
|
||||||
void *builtin_data,
|
|
||||||
bool animated,
|
|
||||||
float frame,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace,
|
|
||||||
ImageMetaData &metadata)
|
|
||||||
{
|
{
|
||||||
Image *img;
|
Image *img;
|
||||||
size_t slot;
|
size_t slot;
|
||||||
|
|
||||||
get_image_metadata(filename, builtin_data, colorspace, metadata);
|
get_image_metadata(key, metadata);
|
||||||
ImageDataType type = metadata.type;
|
ImageDataType type = metadata.type;
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
@ -338,21 +314,11 @@ int ImageManager::add_image(const string &filename,
|
|||||||
/* Fnd existing image. */
|
/* Fnd existing image. */
|
||||||
for (slot = 0; slot < images[type].size(); slot++) {
|
for (slot = 0; slot < images[type].size(); slot++) {
|
||||||
img = images[type][slot];
|
img = images[type][slot];
|
||||||
if (img &&
|
if (img && img->key == key) {
|
||||||
image_equals(
|
|
||||||
img, filename, builtin_data, interpolation, extension, alpha_type, colorspace)) {
|
|
||||||
if (img->frame != frame) {
|
if (img->frame != frame) {
|
||||||
img->frame = frame;
|
img->frame = frame;
|
||||||
img->need_load = true;
|
img->need_load = true;
|
||||||
}
|
}
|
||||||
if (img->alpha_type != alpha_type) {
|
|
||||||
img->alpha_type = alpha_type;
|
|
||||||
img->need_load = true;
|
|
||||||
}
|
|
||||||
if (img->colorspace != colorspace) {
|
|
||||||
img->colorspace = colorspace;
|
|
||||||
img->need_load = true;
|
|
||||||
}
|
|
||||||
if (!(img->metadata == metadata)) {
|
if (!(img->metadata == metadata)) {
|
||||||
img->metadata = metadata;
|
img->metadata = metadata;
|
||||||
img->need_load = true;
|
img->need_load = true;
|
||||||
@ -381,7 +347,7 @@ int ImageManager::add_image(const string &filename,
|
|||||||
"ImageManager::add_image: Reached image limit (%d), "
|
"ImageManager::add_image: Reached image limit (%d), "
|
||||||
"skipping '%s'\n",
|
"skipping '%s'\n",
|
||||||
max_num_images,
|
max_num_images,
|
||||||
filename.c_str());
|
key.filename.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,17 +357,11 @@ int ImageManager::add_image(const string &filename,
|
|||||||
|
|
||||||
/* Add new image. */
|
/* Add new image. */
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img->filename = filename;
|
img->key = key;
|
||||||
img->builtin_data = builtin_data;
|
img->frame = frame;
|
||||||
img->metadata = metadata;
|
img->metadata = metadata;
|
||||||
img->need_load = true;
|
img->need_load = true;
|
||||||
img->animated = animated;
|
|
||||||
img->frame = frame;
|
|
||||||
img->interpolation = interpolation;
|
|
||||||
img->extension = extension;
|
|
||||||
img->users = 1;
|
img->users = 1;
|
||||||
img->alpha_type = alpha_type;
|
|
||||||
img->colorspace = colorspace;
|
|
||||||
img->mem = NULL;
|
img->mem = NULL;
|
||||||
|
|
||||||
images[type][slot] = img;
|
images[type][slot] = img;
|
||||||
@ -442,24 +402,13 @@ void ImageManager::remove_image(int flat_slot)
|
|||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageManager::remove_image(const string &filename,
|
void ImageManager::remove_image(const ImageKey &key)
|
||||||
void *builtin_data,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace)
|
|
||||||
{
|
{
|
||||||
size_t slot;
|
size_t slot;
|
||||||
|
|
||||||
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
||||||
for (slot = 0; slot < images[type].size(); slot++) {
|
for (slot = 0; slot < images[type].size(); slot++) {
|
||||||
if (images[type][slot] && image_equals(images[type][slot],
|
if (images[type][slot] && images[type][slot]->key == key) {
|
||||||
filename,
|
|
||||||
builtin_data,
|
|
||||||
interpolation,
|
|
||||||
extension,
|
|
||||||
alpha_type,
|
|
||||||
colorspace)) {
|
|
||||||
remove_image(type_index_to_flattened_slot(slot, (ImageDataType)type));
|
remove_image(type_index_to_flattened_slot(slot, (ImageDataType)type));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -471,22 +420,11 @@ void ImageManager::remove_image(const string &filename,
|
|||||||
* without bunch of arguments passing around making code readability even
|
* without bunch of arguments passing around making code readability even
|
||||||
* more cluttered.
|
* more cluttered.
|
||||||
*/
|
*/
|
||||||
void ImageManager::tag_reload_image(const string &filename,
|
void ImageManager::tag_reload_image(const ImageKey &key)
|
||||||
void *builtin_data,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace)
|
|
||||||
{
|
{
|
||||||
for (size_t type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
for (size_t type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
||||||
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
||||||
if (images[type][slot] && image_equals(images[type][slot],
|
if (images[type][slot] && images[type][slot]->key == key) {
|
||||||
filename,
|
|
||||||
builtin_data,
|
|
||||||
interpolation,
|
|
||||||
extension,
|
|
||||||
alpha_type,
|
|
||||||
colorspace)) {
|
|
||||||
images[type][slot]->need_load = true;
|
images[type][slot]->need_load = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -498,23 +436,24 @@ static bool image_associate_alpha(ImageManager::Image *img)
|
|||||||
{
|
{
|
||||||
/* For typical RGBA images we let OIIO convert to associated alpha,
|
/* For typical RGBA images we let OIIO convert to associated alpha,
|
||||||
* but some types we want to leave the RGB channels untouched. */
|
* but some types we want to leave the RGB channels untouched. */
|
||||||
return !(ColorSpaceManager::colorspace_is_data(img->colorspace) ||
|
return !(ColorSpaceManager::colorspace_is_data(img->key.colorspace) ||
|
||||||
img->alpha_type == IMAGE_ALPHA_IGNORE || img->alpha_type == IMAGE_ALPHA_CHANNEL_PACKED);
|
img->key.alpha_type == IMAGE_ALPHA_IGNORE ||
|
||||||
|
img->key.alpha_type == IMAGE_ALPHA_CHANNEL_PACKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageManager::file_load_image_generic(Image *img, unique_ptr<ImageInput> *in)
|
bool ImageManager::file_load_image_generic(Image *img, unique_ptr<ImageInput> *in)
|
||||||
{
|
{
|
||||||
if (img->filename == "")
|
if (img->key.filename == "")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!img->builtin_data) {
|
if (!img->key.builtin_data) {
|
||||||
/* NOTE: Error logging is done in meta data acquisition. */
|
/* NOTE: Error logging is done in meta data acquisition. */
|
||||||
if (!path_exists(img->filename) || path_is_directory(img->filename)) {
|
if (!path_exists(img->key.filename) || path_is_directory(img->key.filename)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load image from file through OIIO */
|
/* load image from file through OIIO */
|
||||||
*in = unique_ptr<ImageInput>(ImageInput::create(img->filename));
|
*in = unique_ptr<ImageInput>(ImageInput::create(img->key.filename));
|
||||||
|
|
||||||
if (!*in)
|
if (!*in)
|
||||||
return false;
|
return false;
|
||||||
@ -526,7 +465,7 @@ bool ImageManager::file_load_image_generic(Image *img, unique_ptr<ImageInput> *i
|
|||||||
config.attribute("oiio:UnassociatedAlpha", 1);
|
config.attribute("oiio:UnassociatedAlpha", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*in)->open(img->filename, spec, config)) {
|
if (!(*in)->open(img->key.filename, spec, config)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,8 +567,8 @@ bool ImageManager::file_load_image(Image *img,
|
|||||||
else {
|
else {
|
||||||
/* Read pixels through callback. */
|
/* Read pixels through callback. */
|
||||||
if (FileFormat == TypeDesc::FLOAT) {
|
if (FileFormat == TypeDesc::FLOAT) {
|
||||||
builtin_image_float_pixels_cb(img->filename,
|
builtin_image_float_pixels_cb(img->key.filename,
|
||||||
img->builtin_data,
|
img->key.builtin_data,
|
||||||
0, /* TODO(lukas): Support tiles here? */
|
0, /* TODO(lukas): Support tiles here? */
|
||||||
(float *)&pixels[0],
|
(float *)&pixels[0],
|
||||||
num_pixels * components,
|
num_pixels * components,
|
||||||
@ -637,8 +576,8 @@ bool ImageManager::file_load_image(Image *img,
|
|||||||
img->metadata.builtin_free_cache);
|
img->metadata.builtin_free_cache);
|
||||||
}
|
}
|
||||||
else if (FileFormat == TypeDesc::UINT8) {
|
else if (FileFormat == TypeDesc::UINT8) {
|
||||||
builtin_image_pixels_cb(img->filename,
|
builtin_image_pixels_cb(img->key.filename,
|
||||||
img->builtin_data,
|
img->key.builtin_data,
|
||||||
0, /* TODO(lukas): Support tiles here? */
|
0, /* TODO(lukas): Support tiles here? */
|
||||||
(uchar *)&pixels[0],
|
(uchar *)&pixels[0],
|
||||||
num_pixels * components,
|
num_pixels * components,
|
||||||
@ -700,7 +639,7 @@ bool ImageManager::file_load_image(Image *img,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disable alpha if requested by the user. */
|
/* Disable alpha if requested by the user. */
|
||||||
if (img->alpha_type == IMAGE_ALPHA_IGNORE) {
|
if (img->key.alpha_type == IMAGE_ALPHA_IGNORE) {
|
||||||
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
|
for (size_t i = num_pixels - 1, pixel = 0; pixel < num_pixels; pixel++, i--) {
|
||||||
pixels[i * 4 + 3] = one;
|
pixels[i * 4 + 3] = one;
|
||||||
}
|
}
|
||||||
@ -747,7 +686,7 @@ bool ImageManager::file_load_image(Image *img,
|
|||||||
while (max_size * scale_factor > texture_limit) {
|
while (max_size * scale_factor > texture_limit) {
|
||||||
scale_factor *= 0.5f;
|
scale_factor *= 0.5f;
|
||||||
}
|
}
|
||||||
VLOG(1) << "Scaling image " << img->filename << " by a factor of " << scale_factor << ".";
|
VLOG(1) << "Scaling image " << img->key.filename << " by a factor of " << scale_factor << ".";
|
||||||
vector<StorageType> scaled_pixels;
|
vector<StorageType> scaled_pixels;
|
||||||
size_t scaled_width, scaled_height, scaled_depth;
|
size_t scaled_width, scaled_height, scaled_depth;
|
||||||
util_image_resize_pixels(pixels_storage,
|
util_image_resize_pixels(pixels_storage,
|
||||||
@ -774,6 +713,13 @@ bool ImageManager::file_load_image(Image *img,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void image_set_device_memory(ImageManager::Image *img, device_memory *mem)
|
||||||
|
{
|
||||||
|
img->mem = mem;
|
||||||
|
mem->interpolation = img->key.interpolation;
|
||||||
|
mem->extension = img->key.extension;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageManager::device_load_image(
|
void ImageManager::device_load_image(
|
||||||
Device *device, Scene *scene, ImageDataType type, int slot, Progress *progress)
|
Device *device, Scene *scene, ImageDataType type, int slot, Progress *progress)
|
||||||
{
|
{
|
||||||
@ -782,10 +728,10 @@ void ImageManager::device_load_image(
|
|||||||
|
|
||||||
Image *img = images[type][slot];
|
Image *img = images[type][slot];
|
||||||
|
|
||||||
if (osl_texture_system && !img->builtin_data)
|
if (osl_texture_system && !img->key.builtin_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string filename = path_filename(images[type][slot]->filename);
|
string filename = path_filename(images[type][slot]->key.filename);
|
||||||
progress->set_status("Updating Images", "Loading " + filename);
|
progress->set_status("Updating Images", "Loading " + filename);
|
||||||
|
|
||||||
const int texture_limit = scene->params.texture_limit;
|
const int texture_limit = scene->params.texture_limit;
|
||||||
@ -817,9 +763,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[3] = TEX_IMAGE_MISSING_A;
|
pixels[3] = TEX_IMAGE_MISSING_A;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -836,9 +780,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[0] = TEX_IMAGE_MISSING_R;
|
pixels[0] = TEX_IMAGE_MISSING_R;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -858,9 +800,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[3] = (TEX_IMAGE_MISSING_A * 255);
|
pixels[3] = (TEX_IMAGE_MISSING_A * 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -877,9 +817,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[0] = (TEX_IMAGE_MISSING_R * 255);
|
pixels[0] = (TEX_IMAGE_MISSING_R * 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -899,9 +837,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[3] = TEX_IMAGE_MISSING_A;
|
pixels[3] = TEX_IMAGE_MISSING_A;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -918,9 +854,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
|
pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -940,9 +874,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[3] = (TEX_IMAGE_MISSING_A * 65535);
|
pixels[3] = (TEX_IMAGE_MISSING_A * 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -959,9 +891,7 @@ void ImageManager::device_load_image(
|
|||||||
pixels[0] = TEX_IMAGE_MISSING_R;
|
pixels[0] = TEX_IMAGE_MISSING_R;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->mem = tex_img;
|
image_set_device_memory(img, tex_img);
|
||||||
img->mem->interpolation = img->interpolation;
|
|
||||||
img->mem->extension = img->extension;
|
|
||||||
|
|
||||||
thread_scoped_lock device_lock(device_mutex);
|
thread_scoped_lock device_lock(device_mutex);
|
||||||
tex_img->copy_to_device();
|
tex_img->copy_to_device();
|
||||||
@ -974,9 +904,9 @@ void ImageManager::device_free_image(Device *, ImageDataType type, int slot)
|
|||||||
Image *img = images[type][slot];
|
Image *img = images[type][slot];
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
if (osl_texture_system && !img->builtin_data) {
|
if (osl_texture_system && !img->key.builtin_data) {
|
||||||
#ifdef WITH_OSL
|
#ifdef WITH_OSL
|
||||||
ustring filename(images[type][slot]->filename);
|
ustring filename(images[type][slot]->key.filename);
|
||||||
((OSL::TextureSystem *)osl_texture_system)->invalidate(filename);
|
((OSL::TextureSystem *)osl_texture_system)->invalidate(filename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1008,7 +938,7 @@ void ImageManager::device_update(Device *device, Scene *scene, Progress &progres
|
|||||||
device_free_image(device, (ImageDataType)type, slot);
|
device_free_image(device, (ImageDataType)type, slot);
|
||||||
}
|
}
|
||||||
else if (images[type][slot]->need_load) {
|
else if (images[type][slot]->need_load) {
|
||||||
if (!osl_texture_system || images[type][slot]->builtin_data)
|
if (!osl_texture_system || images[type][slot]->key.builtin_data)
|
||||||
pool.push(function_bind(&ImageManager::device_load_image,
|
pool.push(function_bind(&ImageManager::device_load_image,
|
||||||
this,
|
this,
|
||||||
device,
|
device,
|
||||||
@ -1040,7 +970,7 @@ void ImageManager::device_update_slot(Device *device,
|
|||||||
device_free_image(device, type, slot);
|
device_free_image(device, type, slot);
|
||||||
}
|
}
|
||||||
else if (image->need_load) {
|
else if (image->need_load) {
|
||||||
if (!osl_texture_system || image->builtin_data)
|
if (!osl_texture_system || image->key.builtin_data)
|
||||||
device_load_image(device, scene, type, slot, progress);
|
device_load_image(device, scene, type, slot, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1060,7 +990,7 @@ void ImageManager::device_load_builtin(Device *device, Scene *scene, Progress &p
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (images[type][slot]->need_load) {
|
if (images[type][slot]->need_load) {
|
||||||
if (images[type][slot]->builtin_data) {
|
if (images[type][slot]->key.builtin_data) {
|
||||||
pool.push(function_bind(&ImageManager::device_load_image,
|
pool.push(function_bind(&ImageManager::device_load_image,
|
||||||
this,
|
this,
|
||||||
device,
|
device,
|
||||||
@ -1080,7 +1010,7 @@ void ImageManager::device_free_builtin(Device *device)
|
|||||||
{
|
{
|
||||||
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
||||||
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
for (size_t slot = 0; slot < images[type].size(); slot++) {
|
||||||
if (images[type][slot] && images[type][slot]->builtin_data)
|
if (images[type][slot] && images[type][slot]->key.builtin_data)
|
||||||
device_free_image(device, (ImageDataType)type, slot);
|
device_free_image(device, (ImageDataType)type, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1101,7 +1031,7 @@ void ImageManager::collect_statistics(RenderStats *stats)
|
|||||||
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
for (int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) {
|
||||||
foreach (const Image *image, images[type]) {
|
foreach (const Image *image, images[type]) {
|
||||||
stats->image.textures.add_entry(
|
stats->image.textures.add_entry(
|
||||||
NamedSizeEntry(path_filename(image->filename), image->mem->memory_size()));
|
NamedSizeEntry(path_filename(image->key.filename), image->mem->memory_size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,38 +72,46 @@ class ImageMetaData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ImageKey {
|
||||||
|
public:
|
||||||
|
string filename;
|
||||||
|
void *builtin_data;
|
||||||
|
bool animated;
|
||||||
|
InterpolationType interpolation;
|
||||||
|
ExtensionType extension;
|
||||||
|
ImageAlphaType alpha_type;
|
||||||
|
ustring colorspace;
|
||||||
|
|
||||||
|
ImageKey()
|
||||||
|
: builtin_data(NULL),
|
||||||
|
animated(false),
|
||||||
|
interpolation(INTERPOLATION_LINEAR),
|
||||||
|
extension(EXTENSION_CLIP),
|
||||||
|
alpha_type(IMAGE_ALPHA_AUTO),
|
||||||
|
colorspace(u_colorspace_raw)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const ImageKey &other) const
|
||||||
|
{
|
||||||
|
return (filename == other.filename && builtin_data == other.builtin_data &&
|
||||||
|
animated == other.animated && interpolation == other.interpolation &&
|
||||||
|
extension == other.extension && alpha_type == other.alpha_type &&
|
||||||
|
colorspace == other.colorspace);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ImageManager {
|
class ImageManager {
|
||||||
public:
|
public:
|
||||||
explicit ImageManager(const DeviceInfo &info);
|
explicit ImageManager(const DeviceInfo &info);
|
||||||
~ImageManager();
|
~ImageManager();
|
||||||
|
|
||||||
int add_image(const string &filename,
|
int add_image(const ImageKey &key, float frame, ImageMetaData &metadata);
|
||||||
void *builtin_data,
|
|
||||||
bool animated,
|
|
||||||
float frame,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace,
|
|
||||||
ImageMetaData &metadata);
|
|
||||||
void add_image_user(int flat_slot);
|
void add_image_user(int flat_slot);
|
||||||
void remove_image(int flat_slot);
|
void remove_image(int flat_slot);
|
||||||
void remove_image(const string &filename,
|
void remove_image(const ImageKey &key);
|
||||||
void *builtin_data,
|
void tag_reload_image(const ImageKey &key);
|
||||||
InterpolationType interpolation,
|
bool get_image_metadata(const ImageKey &key, ImageMetaData &metadata);
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace);
|
|
||||||
void tag_reload_image(const string &filename,
|
|
||||||
void *builtin_data,
|
|
||||||
InterpolationType interpolation,
|
|
||||||
ExtensionType extension,
|
|
||||||
ImageAlphaType alpha_type,
|
|
||||||
ustring colorspace);
|
|
||||||
bool get_image_metadata(const string &filename,
|
|
||||||
void *builtin_data,
|
|
||||||
ustring colorspace,
|
|
||||||
ImageMetaData &metadata);
|
|
||||||
bool get_image_metadata(int flat_slot, ImageMetaData &metadata);
|
bool get_image_metadata(int flat_slot, ImageMetaData &metadata);
|
||||||
|
|
||||||
void device_update(Device *device, Scene *scene, Progress &progress);
|
void device_update(Device *device, Scene *scene, Progress &progress);
|
||||||
@ -146,17 +154,11 @@ class ImageManager {
|
|||||||
builtin_image_float_pixels_cb;
|
builtin_image_float_pixels_cb;
|
||||||
|
|
||||||
struct Image {
|
struct Image {
|
||||||
string filename;
|
ImageKey key;
|
||||||
void *builtin_data;
|
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
|
|
||||||
ustring colorspace;
|
|
||||||
ImageAlphaType alpha_type;
|
|
||||||
bool need_load;
|
|
||||||
bool animated;
|
|
||||||
float frame;
|
float frame;
|
||||||
InterpolationType interpolation;
|
bool need_load;
|
||||||
ExtensionType extension;
|
|
||||||
|
|
||||||
string mem_name;
|
string mem_name;
|
||||||
device_memory *mem;
|
device_memory *mem;
|
||||||
|
@ -289,6 +289,22 @@ ShaderNode *ImageTextureNode::clone() const
|
|||||||
return new ImageTextureNode(*this);
|
return new ImageTextureNode(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageKey ImageTextureNode::image_key(const int tile) const
|
||||||
|
{
|
||||||
|
ImageKey key;
|
||||||
|
key.filename = filename.string();
|
||||||
|
if (tile != 0) {
|
||||||
|
string_replace(key.filename, "<UDIM>", string_printf("%04d", tile));
|
||||||
|
}
|
||||||
|
key.builtin_data = builtin_data;
|
||||||
|
key.animated = animated;
|
||||||
|
key.interpolation = interpolation;
|
||||||
|
key.extension = extension;
|
||||||
|
key.alpha_type = alpha_type;
|
||||||
|
key.colorspace = colorspace;
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageTextureNode::cull_tiles(Scene *scene, ShaderGraph *graph)
|
void ImageTextureNode::cull_tiles(Scene *scene, ShaderGraph *graph)
|
||||||
{
|
{
|
||||||
/* Box projection computes its own UVs that always lie in the
|
/* Box projection computes its own UVs that always lie in the
|
||||||
@ -378,19 +394,9 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
|
|||||||
|
|
||||||
bool have_metadata = false;
|
bool have_metadata = false;
|
||||||
foreach (int tile, tiles) {
|
foreach (int tile, tiles) {
|
||||||
string tile_name = filename.string();
|
ImageKey key = image_key(tile);
|
||||||
string_replace(tile_name, "<UDIM>", string_printf("%04d", tile));
|
|
||||||
|
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
int slot = image_manager->add_image(tile_name,
|
int slot = image_manager->add_image(key, 0, metadata);
|
||||||
builtin_data,
|
|
||||||
animated,
|
|
||||||
0,
|
|
||||||
interpolation,
|
|
||||||
extension,
|
|
||||||
alpha_type,
|
|
||||||
colorspace,
|
|
||||||
metadata);
|
|
||||||
slots.push_back(slot);
|
slots.push_back(slot);
|
||||||
|
|
||||||
/* We assume that all tiles have the same metadata. */
|
/* We assume that all tiles have the same metadata. */
|
||||||
@ -500,21 +506,12 @@ void ImageTextureNode::compile(OSLCompiler &compiler)
|
|||||||
if (slots.size() == 0) {
|
if (slots.size() == 0) {
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
if (builtin_data == NULL) {
|
if (builtin_data == NULL) {
|
||||||
string tile_name = filename.string();
|
ImageKey key = image_key(1001);
|
||||||
string_replace(tile_name, "<UDIM>", "1001");
|
image_manager->get_image_metadata(key, metadata);
|
||||||
image_manager->get_image_metadata(tile_name, NULL, colorspace, metadata);
|
|
||||||
slots.push_back(-1);
|
slots.push_back(-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int slot = image_manager->add_image(filename.string(),
|
int slot = image_manager->add_image(image_key(), 0, metadata);
|
||||||
builtin_data,
|
|
||||||
animated,
|
|
||||||
0,
|
|
||||||
interpolation,
|
|
||||||
extension,
|
|
||||||
alpha_type,
|
|
||||||
colorspace,
|
|
||||||
metadata);
|
|
||||||
slots.push_back(slot);
|
slots.push_back(slot);
|
||||||
}
|
}
|
||||||
is_float = metadata.is_float;
|
is_float = metadata.is_float;
|
||||||
@ -602,6 +599,19 @@ ShaderNode *EnvironmentTextureNode::clone() const
|
|||||||
return new EnvironmentTextureNode(*this);
|
return new EnvironmentTextureNode(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageKey EnvironmentTextureNode::image_key() const
|
||||||
|
{
|
||||||
|
ImageKey key;
|
||||||
|
key.filename = filename.string();
|
||||||
|
key.builtin_data = builtin_data;
|
||||||
|
key.animated = animated;
|
||||||
|
key.interpolation = interpolation;
|
||||||
|
key.extension = EXTENSION_REPEAT;
|
||||||
|
key.alpha_type = alpha_type;
|
||||||
|
key.colorspace = colorspace;
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
||||||
{
|
{
|
||||||
#ifdef WITH_PTEX
|
#ifdef WITH_PTEX
|
||||||
@ -624,15 +634,7 @@ void EnvironmentTextureNode::compile(SVMCompiler &compiler)
|
|||||||
image_manager = compiler.scene->image_manager;
|
image_manager = compiler.scene->image_manager;
|
||||||
if (slots.empty()) {
|
if (slots.empty()) {
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
int slot = image_manager->add_image(filename.string(),
|
int slot = image_manager->add_image(image_key(), 0, metadata);
|
||||||
builtin_data,
|
|
||||||
animated,
|
|
||||||
0,
|
|
||||||
interpolation,
|
|
||||||
EXTENSION_REPEAT,
|
|
||||||
alpha_type,
|
|
||||||
colorspace,
|
|
||||||
metadata);
|
|
||||||
slots.push_back(slot);
|
slots.push_back(slot);
|
||||||
is_float = metadata.is_float;
|
is_float = metadata.is_float;
|
||||||
compress_as_srgb = metadata.compress_as_srgb;
|
compress_as_srgb = metadata.compress_as_srgb;
|
||||||
@ -682,19 +684,11 @@ void EnvironmentTextureNode::compile(OSLCompiler &compiler)
|
|||||||
if (slots.empty()) {
|
if (slots.empty()) {
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
if (builtin_data == NULL) {
|
if (builtin_data == NULL) {
|
||||||
image_manager->get_image_metadata(filename.string(), NULL, colorspace, metadata);
|
image_manager->get_image_metadata(image_key(), metadata);
|
||||||
slots.push_back(-1);
|
slots.push_back(-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int slot = image_manager->add_image(filename.string(),
|
int slot = image_manager->add_image(image_key(), 0, metadata);
|
||||||
builtin_data,
|
|
||||||
animated,
|
|
||||||
0,
|
|
||||||
interpolation,
|
|
||||||
EXTENSION_REPEAT,
|
|
||||||
alpha_type,
|
|
||||||
colorspace,
|
|
||||||
metadata);
|
|
||||||
slots.push_back(slot);
|
slots.push_back(slot);
|
||||||
}
|
}
|
||||||
is_float = metadata.is_float;
|
is_float = metadata.is_float;
|
||||||
@ -1754,12 +1748,7 @@ PointDensityTextureNode::PointDensityTextureNode() : ShaderNode(node_type)
|
|||||||
PointDensityTextureNode::~PointDensityTextureNode()
|
PointDensityTextureNode::~PointDensityTextureNode()
|
||||||
{
|
{
|
||||||
if (image_manager) {
|
if (image_manager) {
|
||||||
image_manager->remove_image(filename.string(),
|
image_manager->remove_image(image_key());
|
||||||
builtin_data,
|
|
||||||
interpolation,
|
|
||||||
EXTENSION_CLIP,
|
|
||||||
IMAGE_ALPHA_AUTO,
|
|
||||||
ustring());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1786,18 +1775,19 @@ void PointDensityTextureNode::add_image()
|
|||||||
{
|
{
|
||||||
if (slot == -1) {
|
if (slot == -1) {
|
||||||
ImageMetaData metadata;
|
ImageMetaData metadata;
|
||||||
slot = image_manager->add_image(filename.string(),
|
slot = image_manager->add_image(image_key(), 0, metadata);
|
||||||
builtin_data,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
interpolation,
|
|
||||||
EXTENSION_CLIP,
|
|
||||||
IMAGE_ALPHA_AUTO,
|
|
||||||
u_colorspace_raw,
|
|
||||||
metadata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageKey PointDensityTextureNode::image_key() const
|
||||||
|
{
|
||||||
|
ImageKey key;
|
||||||
|
key.filename = filename.string();
|
||||||
|
key.builtin_data = builtin_data;
|
||||||
|
key.interpolation = interpolation;
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
void PointDensityTextureNode::compile(SVMCompiler &compiler)
|
void PointDensityTextureNode::compile(SVMCompiler &compiler)
|
||||||
{
|
{
|
||||||
ShaderInput *vector_in = input("Vector");
|
ShaderInput *vector_in = input("Vector");
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define __NODES_H__
|
#define __NODES_H__
|
||||||
|
|
||||||
#include "render/graph.h"
|
#include "render/graph.h"
|
||||||
|
#include "render/image.h"
|
||||||
#include "graph/node.h"
|
#include "graph/node.h"
|
||||||
|
|
||||||
#include "util/util_array.h"
|
#include "util/util_array.h"
|
||||||
@ -102,6 +103,8 @@ class ImageTextureNode : public ImageSlotTextureNode {
|
|||||||
animated == image_node.animated;
|
animated == image_node.animated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageKey image_key(const int tile = 0) const;
|
||||||
|
|
||||||
/* Parameters. */
|
/* Parameters. */
|
||||||
ustring filename;
|
ustring filename;
|
||||||
void *builtin_data;
|
void *builtin_data;
|
||||||
@ -145,6 +148,8 @@ class EnvironmentTextureNode : public ImageSlotTextureNode {
|
|||||||
animated == env_node.animated;
|
animated == env_node.animated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageKey image_key() const;
|
||||||
|
|
||||||
/* Parameters. */
|
/* Parameters. */
|
||||||
ustring filename;
|
ustring filename;
|
||||||
void *builtin_data;
|
void *builtin_data;
|
||||||
@ -367,6 +372,8 @@ class PointDensityTextureNode : public ShaderNode {
|
|||||||
|
|
||||||
void add_image();
|
void add_image();
|
||||||
|
|
||||||
|
ImageKey image_key() const;
|
||||||
|
|
||||||
/* Parameters. */
|
/* Parameters. */
|
||||||
ustring filename;
|
ustring filename;
|
||||||
NodeTexVoxelSpace space;
|
NodeTexVoxelSpace space;
|
||||||
|
Loading…
Reference in New Issue
Block a user