Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-06-04 23:38:33 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-06-04 23:38:33 +0400
commit4e338e894f9fb0fa18e5594c2648b05c8f92d4c5 (patch)
treed5a6c1897d9697fc2599316c54c2b53d3b7d6b21 /source/blender
parentd9589bf0dd7a5bbaa0560704c8fbf1b11ec0166d (diff)
Cycles: support for image sequences in image/environment texture node.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c38
-rw-r--r--source/blender/blenloader/intern/readfile.c23
-rw-r--r--source/blender/editors/space_node/drawnode.c84
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c4
9 files changed, 155 insertions, 66 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 24386730ddb..6fccf819d05 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
-#define BLENDER_SUBVERSION 8
+#define BLENDER_SUBVERSION 9
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index ac3daef77f7..279ec272fe8 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -157,6 +157,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf);
void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr);
+void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, int cfra, char *path);
/* sets index offset for multilayer files */
struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 3748a474ddd..9dc5463edab 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2084,8 +2084,7 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
{
struct ImBuf *ibuf;
- unsigned short numlen;
- char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX];
+ char name[FILE_MAX];
int flag;
/* XXX temp stuff? */
@@ -2093,11 +2092,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
ima->tpageflag |= IMA_TPAGE_REFRESH;
ima->lastframe = frame;
- BLI_strncpy(name, ima->name, sizeof(name));
- BLI_stringdec(name, head, tail, &numlen);
- BLI_stringenc(name, head, tail, numlen, frame);
-
- BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id));
+ BKE_image_user_file_path(iuser, ima, frame, name);
flag = IB_rect | IB_multilayer;
if (ima->flag & IMA_DO_PREMUL)
@@ -2209,8 +2204,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
if (ima->anim == NULL) {
char str[FILE_MAX];
- BLI_strncpy(str, ima->name, FILE_MAX);
- BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
+ BKE_image_user_file_path(iuser, ima, frame, str);
/* FIXME: make several stream accessible in image editor, too*/
ima->anim = openanim(str, IB_rect, 0);
@@ -2273,8 +2267,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
flag |= IB_premul;
/* get the right string */
- BLI_strncpy(str, ima->name, sizeof(str));
- BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
+ BKE_image_user_file_path(iuser, ima, cfra, str);
/* read ibuf */
ibuf = IMB_loadiffname(str, flag);
@@ -2748,6 +2741,29 @@ void BKE_image_user_check_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
}
}
+void BKE_image_user_file_path(ImageUser *iuser, Image *ima, int cfra, char *filepath)
+{
+ BLI_strncpy(filepath, ima->name, FILE_MAX);
+
+ if (ima->source == IMA_SRC_SEQUENCE) {
+ char head[FILE_MAX], tail[FILE_MAX];
+ unsigned short numlen;
+ int frame;
+
+ if(iuser) {
+ BKE_image_user_frame_calc(iuser, cfra, 0);
+ frame = iuser->framenr;
+ }
+ else {
+ }
+
+ BLI_stringdec(filepath, head, tail, &numlen);
+ BLI_stringenc(filepath, head, tail, numlen, frame);
+ }
+
+ BLI_path_abs(filepath, ID_BLEND_PATH(G.main, &ima->id));
+}
+
int BKE_image_has_alpha(struct Image *image)
{
ImBuf *ibuf;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 826d9d196b8..a4d8457bd2d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6897,6 +6897,22 @@ static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
}
}
+static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+ bNode *node;
+
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
+ NodeTexImage *tex = node->storage;
+
+ tex->iuser.frames= 1;
+ tex->iuser.sfra= 1;
+ tex->iuser.fie_ima= 2;
+ tex->iuser.ok= 1;
+ }
+ }
+}
+
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -7608,6 +7624,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) {
+ bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER);
+
+ if (ntreetype && ntreetype->foreach_nodetree)
+ ntreetype->foreach_nodetree(main, NULL, do_version_ntree_image_user_264);
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
{
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 5a8bc5da324..aa8a68677c0 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1188,6 +1188,47 @@ static void node_common_set_butfunc(bNodeType *ntype)
}
/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
+
+static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imaptr, PointerRNA *iuserptr)
+{
+ uiLayout *col;
+ int source;
+
+ if(!imaptr->data)
+ return;
+
+ col = uiLayoutColumn(layout, 0);
+
+ uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
+
+ source = RNA_enum_get(imaptr, "source");
+
+ if (source == IMA_SRC_SEQUENCE) {
+ /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
+ Scene *scene = CTX_data_scene(C);
+ ImageUser *iuser = iuserptr->data;
+ char numstr[32];
+ const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
+ BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
+ uiItemL(layout, numstr, ICON_NONE);
+ }
+
+ if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
+ col = uiLayoutColumn(layout, 1);
+ uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE);
+ uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE);
+ uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE);
+ uiItemR(col, iuserptr, "use_cyclic", 0, NULL, ICON_NONE);
+ uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
+ }
+
+ col = uiLayoutColumn(layout, 0);
+
+ if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
+ uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE);
+
+}
+
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
bNode *node = ptr->data;
@@ -1259,16 +1300,25 @@ static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), Po
static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
+ PointerRNA imaptr = RNA_pointer_get(ptr, "image");
+ PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
+
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
-}
+ node_buts_image_user(layout, C, &imaptr, &iuserptr);
+}
static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
+ PointerRNA imaptr = RNA_pointer_get(ptr, "image");
+ PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
+
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
+
+ node_buts_image_user(layout, C, &imaptr, &iuserptr);
}
static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1391,11 +1441,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
- uiLayout *col;
bNode *node = ptr->data;
PointerRNA imaptr;
PropertyRNA *prop;
- int source;
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
@@ -1405,35 +1453,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
if (!prop || RNA_property_type(prop) != PROP_POINTER) return;
imaptr = RNA_property_pointer_get(ptr, prop);
- col = uiLayoutColumn(layout, 0);
-
- uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
-
- source = RNA_enum_get(&imaptr, "source");
-
- if (source == IMA_SRC_SEQUENCE) {
- /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
- Scene *scene = CTX_data_scene(C);
- ImageUser *iuser = node->storage;
- char numstr[32];
- const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
- BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
- uiItemL(layout, numstr, ICON_NONE);
- }
-
- if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
- col = uiLayoutColumn(layout, 1);
- uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
- }
-
- col = uiLayoutColumn(layout, 0);
-
- if (RNA_enum_get(&imaptr, "type") == IMA_TYPE_MULTILAYER)
- uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
+ node_buts_image_user(layout, C, &imaptr, ptr);
}
static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 5b87ecc44ae..59506f31b60 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -563,6 +563,7 @@ typedef struct NodeTexSky {
typedef struct NodeTexImage {
NodeTexBase base;
+ ImageUser iuser;
int color_space, pad;
} NodeTexImage;
@@ -572,6 +573,7 @@ typedef struct NodeTexChecker {
typedef struct NodeTexEnvironment {
NodeTexBase base;
+ ImageUser iuser;
int color_space, projection;
} NodeTexEnvironment;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 30c705fb7fa..562684799b4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1429,6 +1429,12 @@ static void def_sh_tex_environment(StructRNA *srna)
RNA_def_property_ui_text(prop, "Projection", "Projection of the input image");
RNA_def_property_update(prop, 0, "rna_Node_update");
+ prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "iuser");
+ RNA_def_property_ui_text(prop, "Image User",
+ "Parameters defining which layer, pass and frame of the image is displayed");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_image(StructRNA *srna)
@@ -1458,6 +1464,13 @@ static void def_sh_tex_image(StructRNA *srna)
RNA_def_property_enum_items(prop, prop_color_space_items);
RNA_def_property_ui_text(prop, "Color Space", "Image file color space");
RNA_def_property_update(prop, 0, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "iuser");
+ RNA_def_property_ui_text(prop, "Image User",
+ "Parameters defining which layer, pass and frame of the image is displayed");
+ RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_gradient(StructRNA *srna)
@@ -1830,29 +1843,10 @@ static void def_cmp_levels(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
-static void def_cmp_image(StructRNA *srna)
+static void def_node_image_user(StructRNA *srna)
{
PropertyRNA *prop;
-
-#if 0
- static EnumPropertyItem type_items[] = {
- {IMA_SRC_FILE, "IMAGE", 0, "Image", ""},
- {IMA_SRC_MOVIE, "MOVIE", "Movie", ""},
- {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""},
- {IMA_SRC_GENERATED, "GENERATED", "Generated", ""},
- {0, NULL, 0, NULL, NULL}
- };
-#endif
-
- prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "id");
- RNA_def_property_struct_type(prop, "Image");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Image", "");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
- RNA_def_struct_sdna_from(srna, "ImageUser", "storage");
-
+
prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "frames");
RNA_def_property_range(prop, 0, MAXFRAMEF);
@@ -1893,6 +1887,31 @@ static void def_cmp_image(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_image_layer_update");
}
+static void def_cmp_image(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+#if 0
+ static EnumPropertyItem type_items[] = {
+ {IMA_SRC_FILE, "IMAGE", 0, "Image", ""},
+ {IMA_SRC_MOVIE, "MOVIE", "Movie", ""},
+ {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""},
+ {IMA_SRC_GENERATED, "GENERATED", "Generated", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+#endif
+
+ prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "id");
+ RNA_def_property_struct_type(prop, "Image");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Image", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "ImageUser", "storage");
+ def_node_image_user(srna);
+}
+
static void def_cmp_render_layers(StructRNA *srna)
{
PropertyRNA *prop;
@@ -3454,7 +3473,7 @@ static void def_tex_image(StructRNA *srna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Image", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
-
+
/* is this supposed to be exposed? not sure.. */
#if 0
prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index e5dc64aca05..e3300c89a01 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -46,6 +46,10 @@ static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* no
default_color_mapping(&tex->base.color_mapping);
tex->color_space = SHD_COLORSPACE_COLOR;
tex->projection = SHD_PROJ_EQUIRECTANGULAR;
+ tex->iuser.frames= 1;
+ tex->iuser.sfra= 1;
+ tex->iuser.fie_ima= 2;
+ tex->iuser.ok= 1;
node->storage = tex;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index db1c9081471..d4d43c1430c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -46,6 +46,10 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bN
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->color_space = SHD_COLORSPACE_COLOR;
+ tex->iuser.frames= 1;
+ tex->iuser.sfra= 1;
+ tex->iuser.fie_ima= 2;
+ tex->iuser.ok= 1;
node->storage = tex;
}