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:
authorRobert Holcomb <bob_holcomb@hotmail.com>2007-03-24 21:41:54 +0300
committerRobert Holcomb <bob_holcomb@hotmail.com>2007-03-24 21:41:54 +0300
commit808a5fc05a3e242661228ae0637fa47e4e41860b (patch)
treedefa1d65e2d8a936265717a75f6ee375c7479c63 /source/blender/blenkernel
parentd193ce012a8dc674211d9241213fbc16b7798303 (diff)
Scons build system. MSVC 7.1 in a moment.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_node.h111
-rw-r--r--source/blender/blenkernel/SConscript2
-rw-r--r--source/blender/blenkernel/intern/node.c282
3 files changed, 215 insertions, 180 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index e8fe21c0ae5..d06e8625bf9 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -33,6 +33,8 @@
#ifndef BKE_NODE_H
#define BKE_NODE_H
+
+
struct ID;
struct bNodeTree;
struct bNode;
@@ -78,17 +80,19 @@ typedef struct bNodeType {
/* after this line is set on startup of blender */
int (*butfunc)(struct uiBlock *, struct bNodeTree *, struct bNode *, struct rctf *);
+ void (*initfunc)(struct bNode *);
+
} bNodeType;
/* nodetype->nclass, for add-menu and themes */
#define NODE_CLASS_INPUT 0
#define NODE_CLASS_OUTPUT 1
#define NODE_CLASS_OP_COLOR 3
-#define NODE_CLASS_OP_VECTOR 4
-#define NODE_CLASS_OP_FILTER 5
+#define NODE_CLASS_OP_VECTOR 4
+#define NODE_CLASS_OP_FILTER 5
#define NODE_CLASS_GROUP 6
#define NODE_CLASS_FILE 7
-#define NODE_CLASS_CONVERTOR 8
+#define NODE_CLASS_CONVERTOR 8
#define NODE_CLASS_MATTE 9
#define NODE_CLASS_DISTORT 10
@@ -151,7 +155,7 @@ void nodeGroupSocketUseFlags(struct bNodeTree *ngroup);
/* ************** COMMON NODES *************** */
-#define NODE_GROUP 2
+#define NODE_GROUP 2
#define NODE_GROUP_MENU 1000
extern bNodeType node_group_typeinfo;
@@ -169,7 +173,7 @@ struct ShadeResult;
#define SH_NODE_OUTPUT 1
#define SH_NODE_MATERIAL 100
-#define SH_NODE_RGB 101
+#define SH_NODE_RGB 101
#define SH_NODE_VALUE 102
#define SH_NODE_MIX_RGB 103
#define SH_NODE_VALTORGB 104
@@ -183,14 +187,13 @@ struct ShadeResult;
#define SH_NODE_CAMERA 114
#define SH_NODE_MATH 115
#define SH_NODE_VECT_MATH 116
-#define SH_NODE_SQUEEZE 117
-/* custom defines: options for Material node */
-#define SH_NODE_MAT_DIFF 1
-#define SH_NODE_MAT_SPEC 2
-#define SH_NODE_MAT_NEG 4
+#define SH_NODE_SQUEEZE 117
+
+
+
/* the type definitions array */
-extern bNodeType *node_all_shaders[];
+static bNodeType *node_all_shaders[];
/* API */
@@ -199,10 +202,29 @@ void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, i
void nodeShaderSynchronizeID(struct bNode *node, int copyto);
/* switch material render loop */
+void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
+
/* ************** COMPOSITE NODES *************** */
+/* output socket defines */
+#define RRES_OUT_IMAGE 0
+#define RRES_OUT_ALPHA 1
+#define RRES_OUT_Z 2
+#define RRES_OUT_NORMAL 3
+#define RRES_OUT_UV 4
+#define RRES_OUT_VEC 5
+#define RRES_OUT_RGBA 6
+#define RRES_OUT_DIFF 7
+#define RRES_OUT_SPEC 8
+#define RRES_OUT_SHADOW 9
+#define RRES_OUT_AO 10
+#define RRES_OUT_REFLECT 11
+#define RRES_OUT_REFRACT 12
+#define RRES_OUT_RADIO 13
+#define RRES_OUT_INDEXOB 14
+
/* note: types are needed to restore callbacks, don't change values */
#define CMP_NODE_VIEWER 201
#define CMP_NODE_RGB 202
@@ -223,56 +245,39 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
#define CMP_NODE_SEPHSVA 217
#define CMP_NODE_SETALPHA 218
#define CMP_NODE_HUE_SAT 219
-#define CMP_NODE_IMAGE 220
-#define CMP_NODE_R_LAYERS 221
-#define CMP_NODE_COMPOSITE 222
+#define CMP_NODE_IMAGE 220
+#define CMP_NODE_R_LAYERS 221
+#define CMP_NODE_COMPOSITE 222
#define CMP_NODE_OUTPUT_FILE 223
-#define CMP_NODE_TEXTURE 224
-#define CMP_NODE_TRANSLATE 225
-#define CMP_NODE_ZCOMBINE 226
-#define CMP_NODE_COMBRGBA 227
+#define CMP_NODE_TEXTURE 224
+#define CMP_NODE_TRANSLATE 225
+#define CMP_NODE_ZCOMBINE 226
+#define CMP_NODE_COMBRGBA 227
#define CMP_NODE_DILATEERODE 228
-#define CMP_NODE_ROTATE 229
-#define CMP_NODE_SCALE 230
-#define CMP_NODE_SEPYCCA 231
-#define CMP_NODE_COMBYCCA 232
-#define CMP_NODE_SEPYUVA 233
-#define CMP_NODE_COMBYUVA 234
-#define CMP_NODE_DIFF_MATTE 235
+#define CMP_NODE_ROTATE 229
+#define CMP_NODE_SCALE 230
+#define CMP_NODE_SEPYCCA 231
+#define CMP_NODE_COMBYCCA 232
+#define CMP_NODE_SEPYUVA 233
+#define CMP_NODE_COMBYUVA 234
+#define CMP_NODE_DIFF_MATTE 235
#define CMP_NODE_COLOR_SPILL 236
-#define CMP_NODE_CHROMA 237
+#define CMP_NODE_CHROMA 237
#define CMP_NODE_CHANNEL_MATTE 238
-#define CMP_NODE_FLIP 239
+#define CMP_NODE_FLIP 239
#define CMP_NODE_SPLITVIEWER 240
-#define CMP_NODE_INDEX_MASK 241
-#define CMP_NODE_MAP_UV 242
-#define CMP_NODE_ID_MASK 243
-#define CMP_NODE_DEFOCUS 244
-#define CMP_NODE_DISPLACE 245
-#define CMP_NODE_COMBHSVA 246
-#define CMP_NODE_MATH 247
-#define CMP_NODE_LUMA_MATTE 248
-
-
-/* filter types */
-
-
-/* filter types, in custom1 */
-
-#define CMP_FILT_SOFT 0
-#define CMP_FILT_SHARP 1
-#define CMP_FILT_LAPLACE 2
-#define CMP_FILT_SOBEL 3
-#define CMP_FILT_PREWITT 4
-#define CMP_FILT_KIRSCH 5
-#define CMP_FILT_SHADOW 6
+#define CMP_NODE_INDEX_MASK 241
+#define CMP_NODE_MAP_UV 242
+#define CMP_NODE_ID_MASK 243
+#define CMP_NODE_DEFOCUS 244
+#define CMP_NODE_DISPLACE 245
+#define CMP_NODE_COMBHSVA 246
+#define CMP_NODE_MATH 247
+#define CMP_NODE_LUMA_MATTE 248
-/* scale node type, in custom1 */
-#define CMP_SCALE_RELATIVE 0
-#define CMP_SCALE_ABSOLUTE 1
/* the type definitions array */
-extern bNodeType *node_all_composit[];
+static bNodeType* node_all_composit[];
/* API */
struct CompBuf;
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index a852fde71b9..d7b48105d3d 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc ../include ../blenlib ../makesdna'
incs += ' ../python ../render/extern/include #/intern/decimation/extern'
-incs += ' ../imbuf ../avi #/intern/elbeem/extern'
+incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes'
incs += ' #/intern/iksolver/extern ../blenloader ../quicktime'
incs += ' ' + env['BF_OPENGL_INC']
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 62246fa59c5..2340e260d4f 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -56,6 +56,13 @@
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h" /* <- TexResult */
+#include "RE_render_ext.h" /* <- ibuf_sample() */
+
+#include "CMP_node.h"
+#include "SHD_node.h"
+
/* not very important, but the stack solver likes to know a maximum */
#define MAX_SOCKET 64
@@ -774,132 +781,9 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
}
/* need init handler later? */
- if(ntree->type==NTREE_SHADER) {
- if(type==SH_NODE_MATERIAL)
- node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC;
- else if(type==SH_NODE_VALTORGB)
- node->storage= add_colorband(1);
- else if(type==SH_NODE_MAPPING)
- node->storage= add_mapping();
- else if(type==SH_NODE_CURVE_VEC)
- node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
- else if(type==SH_NODE_CURVE_RGB)
- node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
- else if(type==SH_NODE_GEOMETRY)
- node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
- }
- else if(ntree->type==NTREE_COMPOSIT) {
- if(type==CMP_NODE_VALTORGB)
- node->storage= add_colorband(1);
- else if(type==CMP_NODE_CURVE_VEC)
- node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
- else if(type==CMP_NODE_CURVE_RGB)
- node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
- else if(type==CMP_NODE_TIME) {
- node->custom1= G.scene->r.sfra;
- node->custom2= G.scene->r.efra;
- node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
- }
- else if(type==CMP_NODE_MAP_VALUE)
- node->storage= add_mapping();
- else if(type==CMP_NODE_BLUR)
- node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data");
- else if(type==CMP_NODE_DEFOCUS) {
- /* qdn: defocus node */
- NodeDefocus *nbd = MEM_callocN(sizeof(NodeDefocus), "node defocus data");
- nbd->bktype = 0;
- nbd->rotation = 0.f;
- nbd->preview = 1;
- nbd->gamco = 0;
- nbd->samples = 16;
- nbd->fstop = 128.f;
- nbd->maxblur = 0;
- nbd->bthresh = 1.f;
- nbd->scale = 1.f;
- nbd->no_zbuf = 1;
- node->storage = nbd;
- }
- else if(type==CMP_NODE_VECBLUR) {
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data");
- node->storage= nbd;
- nbd->samples= 32;
- nbd->fac= 1.0f;
- }
- else if(ELEM3(type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
- ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user");
- node->storage= iuser;
- iuser->sfra= 1;
- iuser->fie_ima= 2;
- iuser->ok= 1;
-
- if(type==CMP_NODE_SPLITVIEWER){
- node->custom1= 50; /* default 50% split */
- }
- }
- else if(type==CMP_NODE_HUE_SAT) {
- NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat");
- node->storage= nhs;
- nhs->hue= 0.5f;
- nhs->sat= 1.0f;
- nhs->val= 1.0f;
- }
- else if(type==CMP_NODE_OUTPUT_FILE) {
- NodeImageFile *nif= MEM_callocN(sizeof(NodeImageFile), "node image file");
- node->storage= nif;
- BLI_strncpy(nif->name, G.scene->r.pic, sizeof(nif->name));
- nif->imtype= G.scene->r.imtype;
- nif->subimtype= G.scene->r.subimtype;
- nif->quality= G.scene->r.quality;
- nif->sfra= G.scene->r.sfra;
- nif->efra= G.scene->r.efra;
- }
- else if(type==CMP_NODE_DIFF_MATTE){
- NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
- node->storage= c;
- c->t1= 0.01f;
- c->t2= 0.01f;
- c->t3= 0.01f;
- c->fsize= 0.0f;
- c->fstrength= 0.0f;
- node->custom1= 1; /* RGB */
- }
- else if(type==CMP_NODE_COLOR_SPILL){
- NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
- node->storage=c;
- c->t1= 0.0f;
- c->t2= 0.0f;
- c->t3= 0.0f;
- c->fsize= 0.0f;
- c->fstrength= 0.0f;
- node->custom1= 2; /* green channel */
- }
- else if(type==CMP_NODE_CHROMA){
- NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
- node->storage= c;
- c->t1= 30.0f;
- c->t2= 10.0f;
- c->t3= 0.0f;
- c->fsize= 0.0f;
- c->fstrength= 1.0f;
- }
- else if(type==CMP_NODE_CHANNEL_MATTE){
- NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
- node->storage=c;
- c->t1= 0.0f;
- c->t2= 0.0f;
- c->t3= 0.0f;
- c->fsize= 0.0f;
- c->fstrength= 0.0f;
- node->custom1= 1; /* RGB channel */
- node->custom2= 2; /* Green Channel */
- }
- else if(type==CMP_NODE_LUMA_MATTE){
- NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma");
- node->storage=c;
- c->t1= 0.0f;
- c->t2= 0.0f;
- }
- }
+ /* got it-bob*/
+ if(ntype->initfunc!=NULL)
+ ntype->initfunc(node);
return node;
}
@@ -2266,3 +2150,149 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
}
+/* **************** call to switch lamploop for material node ************ */
+
+void set_node_shader_lamp_loop(void (*lamp_loop_func)(ShadeInput *, ShadeResult *))
+{
+ node_shader_lamp_loop= lamp_loop_func;
+}
+
+/* clumsy checking... should do dynamic outputs once */
+static void force_hidden_passes(bNode *node, int passflag)
+{
+ bNodeSocket *sock;
+
+ for(sock= node->outputs.first; sock; sock= sock->next)
+ sock->flag &= ~SOCK_UNAVAIL;
+
+ sock= BLI_findlink(&node->outputs, RRES_OUT_Z);
+ if(!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_NORMAL);
+ if(!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_VEC);
+ if(!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_UV);
+ if(!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_RGBA);
+ if(!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF);
+ if(!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_SPEC);
+ if(!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_SHADOW);
+ if(!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_AO);
+ if(!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_REFLECT);
+ if(!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT);
+ if(!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_RADIO);
+ if(!(passflag & SCE_PASS_RADIO)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB);
+ if(!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL;
+
+}
+
+/* based on rules, force sockets hidden always */
+void ntreeCompositForceHidden(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if(ntree==NULL) return;
+
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if( node->type==CMP_NODE_R_LAYERS) {
+ Scene *sce= node->id?(Scene *)node->id:G.scene; /* G.scene is WEAK! */
+ SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
+ if(srl)
+ force_hidden_passes(node, srl->passflag);
+ }
+ else if( node->type==CMP_NODE_IMAGE) {
+ Image *ima= (Image *)node->id;
+ if(ima) {
+ if(ima->rr) {
+ ImageUser *iuser= node->storage;
+ RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer);
+ if(rl)
+ force_hidden_passes(node, rl->passflag);
+ else
+ force_hidden_passes(node, 0);
+ }
+ else if(ima->type!=IMA_TYPE_MULTILAYER) { /* if ->rr not yet read we keep inputs */
+ force_hidden_passes(node, RRES_OUT_Z);
+ }
+ }
+ else
+ force_hidden_passes(node, 0);
+ }
+ }
+
+}
+
+/* called from render pipeline, to tag render input and output */
+/* need to do all scenes, to prevent errors when you re-render 1 scene */
+void ntreeCompositTagRender(Scene *curscene)
+{
+ Scene *sce;
+
+ for(sce= G.main->scene.first; sce; sce= sce->id.next) {
+ if(sce->nodetree) {
+ bNode *node;
+
+ for(node= sce->nodetree->nodes.first; node; node= node->next) {
+ if(node->id==(ID *)curscene || node->type==CMP_NODE_COMPOSITE)
+ NodeTagChanged(sce->nodetree, node);
+ }
+ }
+ }
+}
+
+/* tags nodes that have animation capabilities */
+int ntreeCompositTagAnimated(bNodeTree *ntree)
+{
+ bNode *node;
+ int tagged= 0;
+
+ if(ntree==NULL) return 0;
+
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->type==CMP_NODE_IMAGE) {
+ Image *ima= (Image *)node->id;
+ if(ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+ NodeTagChanged(ntree, node);
+ tagged= 1;
+ }
+ }
+ else if(node->type==CMP_NODE_TIME) {
+ NodeTagChanged(ntree, node);
+ tagged= 1;
+ }
+ else if(node->type==CMP_NODE_R_LAYERS) {
+ NodeTagChanged(ntree, node);
+ tagged= 1;
+ }
+ else if(node->type==NODE_GROUP) {
+ if( ntreeCompositTagAnimated((bNodeTree *)node->id) ) {
+ NodeTagChanged(ntree, node);
+ }
+ }
+ }
+
+ return tagged;
+}
+
+
+/* called from image window preview */
+void ntreeCompositTagGenerators(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if(ntree==NULL) return;
+
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if( ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE))
+ NodeTagChanged(ntree, node);
+ }
+}
+