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>2011-11-08 15:38:16 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-08 15:38:16 +0400
commitdb75cc4cdebb536774a8f2d7601319e2c898ecb0 (patch)
tree19a1990fae100454d661be7000580b1bbce85978 /source/blender/editors
parentee6f269cda2164509a36caf0947663689823a104 (diff)
Nodes: add cycles shader nodes, these will only be available to render engines
that use the new shading nodes system. Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/object/object_add.c18
-rw-r--r--source/blender/editors/space_node/drawnode.c79
-rw-r--r--source/blender/editors/space_node/node_edit.c47
3 files changed, 133 insertions, 11 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 8d4d29dbe50..9b539871cbc 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -78,6 +78,7 @@
#include "BKE_particle.h"
#include "BKE_report.h"
#include "BKE_sca.h"
+#include "BKE_scene.h"
#include "BKE_speaker.h"
#include "BKE_texture.h"
@@ -92,6 +93,7 @@
#include "ED_curve.h"
#include "ED_mball.h"
#include "ED_mesh.h"
+#include "ED_node.h"
#include "ED_object.h"
#include "ED_render.h"
#include "ED_screen.h"
@@ -322,6 +324,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int en
/* more editor stuff */
ED_object_base_init_transform(C, BASACT, loc, rot);
+ DAG_id_type_tag(bmain, ID_OB);
DAG_scene_sort(bmain, scene);
ED_render_id_flush_update(bmain, ob->data);
@@ -700,7 +703,9 @@ static const char *get_lamp_defname(int type)
static int object_lamp_add_exec(bContext *C, wmOperator *op)
{
+ Scene *scene= CTX_data_scene(C);
Object *ob;
+ Lamp *la;
int type= RNA_enum_get(op->ptr, "type");
int enter_editmode;
unsigned int layer;
@@ -711,9 +716,16 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer);
- ((Lamp*)ob->data)->type= type;
- rename_id((ID *)ob, get_lamp_defname(type));
- rename_id((ID *)ob->data, get_lamp_defname(type));
+ la= (Lamp*)ob->data;
+
+ la->type= type;
+ rename_id(&ob->id, get_lamp_defname(type));
+ rename_id(&la->id, get_lamp_defname(type));
+
+ if(scene_use_new_shading_nodes(scene)) {
+ ED_node_shader_default(scene, &la->id);
+ la->use_nodes= 1;
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 648027b9c58..4394b4b1920 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -994,6 +994,54 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA
}
}
+static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
+}
+
+static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ //uiItemR(layout, ptr, "image", 0, "", ICON_NONE);
+ uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
+ uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
+}
+
+static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
+ uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
+}
+
+static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
+}
+
+static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
+}
+
+static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
+}
+
+static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
+}
+
+static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
+}
+
+static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
+}
+
static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
Main *bmain= CTX_data_main(C);
@@ -1080,6 +1128,37 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_GEOMETRY:
ntype->uifunc= node_shader_buts_geometry;
break;
+ case SH_NODE_ATTRIBUTE:
+ ntype->uifunc= node_shader_buts_attribute;
+ break;
+ case SH_NODE_TEX_SKY:
+ ntype->uifunc= node_shader_buts_tex_sky;
+ break;
+ case SH_NODE_TEX_IMAGE:
+ ntype->uifunc= node_shader_buts_tex_image;
+ break;
+ case SH_NODE_TEX_ENVIRONMENT:
+ ntype->uifunc= node_shader_buts_tex_image;
+ break;
+ case SH_NODE_TEX_GRADIENT:
+ ntype->uifunc= node_shader_buts_tex_gradient;
+ break;
+ case SH_NODE_TEX_MAGIC:
+ ntype->uifunc= node_shader_buts_tex_magic;
+ break;
+ case SH_NODE_TEX_WAVE:
+ ntype->uifunc= node_shader_buts_tex_wave;
+ break;
+ case SH_NODE_TEX_MUSGRAVE:
+ ntype->uifunc= node_shader_buts_tex_musgrave;
+ break;
+ case SH_NODE_TEX_VORONOI:
+ ntype->uifunc= node_shader_buts_tex_voronoi;
+ break;
+ case SH_NODE_BSDF_GLOSSY:
+ case SH_NODE_BSDF_GLASS:
+ ntype->uifunc= node_shader_buts_glossy;
+ break;
case NODE_DYNAMIC:
ntype->uifunc= node_shader_buts_dynamic;
break;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 2d8fbb133b4..a1b705610f4 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -61,6 +61,7 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_paint.h"
+#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
#include "BKE_report.h"
@@ -269,13 +270,14 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree)
/* assumes nothing being done in ntree yet, sets the default in/out node */
/* called from shading buttons or header */
-void ED_node_shader_default(Scene *UNUSED(scene), ID *id)
+void ED_node_shader_default(Scene *scene, ID *id)
{
bNode *in, *out;
- bNodeSocket *fromsock, *tosock;
+ bNodeSocket *fromsock, *tosock, *sock;
bNodeTree *ntree;
bNodeTemplate ntemp;
int output_type, shader_type;
+ float color[3], strength = 1.0f;
ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0);
@@ -284,24 +286,42 @@ void ED_node_shader_default(Scene *UNUSED(scene), ID *id)
Material *ma= (Material*)id;
ma->nodetree = ntree;
- output_type = SH_NODE_OUTPUT;
- shader_type = SH_NODE_MATERIAL;
+ if(scene_use_new_shading_nodes(scene)) {
+ output_type = SH_NODE_OUTPUT_MATERIAL;
+ shader_type = SH_NODE_BSDF_DIFFUSE;
+ }
+ else {
+ output_type = SH_NODE_OUTPUT;
+ shader_type = SH_NODE_MATERIAL;
+ }
+
+ copy_v3_v3(color, &ma->r);
+ strength= 0.0f;
break;
}
case ID_WO: {
World *wo= (World*)id;
wo->nodetree = ntree;
- output_type = SH_NODE_OUTPUT;
- shader_type = SH_NODE_MATERIAL;
+ output_type = SH_NODE_OUTPUT_WORLD;
+ shader_type = SH_NODE_BACKGROUND;
+
+ copy_v3_v3(color, &wo->horr);
+ strength= 1.0f;
break;
}
case ID_LA: {
Lamp *la= (Lamp*)id;
la->nodetree = ntree;
- output_type = SH_NODE_OUTPUT;
- shader_type = SH_NODE_MATERIAL;
+ output_type = SH_NODE_OUTPUT_LAMP;
+ shader_type = SH_NODE_EMISSION;
+
+ copy_v3_v3(color, &la->r);
+ if(la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA)
+ strength= 100.0f;
+ else
+ strength= 1.0f;
break;
}
default:
@@ -322,6 +342,17 @@ void ED_node_shader_default(Scene *UNUSED(scene), ID *id)
fromsock= in->outputs.first;
tosock= out->inputs.first;
nodeAddLink(ntree, in, fromsock, out, tosock);
+
+ /* default values */
+ if(scene_use_new_shading_nodes(scene)) {
+ sock= in->inputs.first;
+ copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color);
+
+ if(strength != 0.0f) {
+ sock= in->inputs.last;
+ ((bNodeSocketValueFloat*)sock->default_value)->value= strength;
+ }
+ }
ntreeUpdateTree(ntree);
}