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-02 22:55:32 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-02 22:55:32 +0400
commit30f1f28a8af3b393608b5869512a8823111294ad (patch)
tree035cee751100c31e25b55087efa476145b29af64 /source/blender/makesrna/intern
parent97a0ae3e1b7eea3c069da8c6d3c7a3535734059d (diff)
Nodes: add support for shader nodes on world and lamps, in addition to materials.
The internal render engine does not support them, and they are not accesible in the UI yet, but cycles will use them.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c21
-rw-r--r--source/blender/makesrna/intern/rna_material.c11
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c7
-rw-r--r--source/blender/makesrna/intern/rna_object.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c11
-rw-r--r--source/blender/makesrna/intern/rna_world.c22
6 files changed, 65 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index 572559546c8..629711fcf96 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -46,6 +46,7 @@
#include "BKE_main.h"
#include "BKE_texture.h"
+#include "ED_node.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -145,6 +146,15 @@ static void rna_Lamp_spot_size_set(PointerRNA *ptr, float value)
la->spotsize= RAD2DEGF(value);
}
+static void rna_Lamp_use_nodes_update(Main *blain, Scene *scene, PointerRNA *ptr)
+{
+ Lamp *la= (Lamp*)ptr->data;
+
+ if(la->use_nodes && la->nodetree==NULL)
+ ED_node_shader_default(scene, &la->id);
+
+ rna_Lamp_update(blain, scene, ptr);
+}
#else
@@ -366,6 +376,17 @@ static void rna_def_lamp(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF);
RNA_def_property_ui_text(prop, "Diffuse", "Lamp does diffuse shading");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
+ /* nodes */
+ prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
+ RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lamps");
+
+ prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the lamp");
+ RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update");
/* common */
rna_def_animdata_common(srna);
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 990d3b89bce..57770be57eb 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -269,13 +269,14 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value)
ma->ramp_spec= add_colorband(0);
}
-static void rna_Material_use_nodes_set(PointerRNA *ptr, int value)
+static void rna_Material_use_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Material *ma= (Material*)ptr->data;
- ma->use_nodes= value;
if(ma->use_nodes && ma->nodetree==NULL)
- ED_node_shader_default(ma);
+ ED_node_shader_default(scene, &ma->id);
+
+ rna_Material_update(bmain, scene, ptr);
}
static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr,
@@ -1954,9 +1955,9 @@ void RNA_def_material(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
- RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
- RNA_def_property_update(prop, 0, "rna_Material_update");
+ RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update");
prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Material");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 96c23effdfb..1445cf3b537 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -56,7 +56,7 @@
#include "MEM_guardedalloc.h"
EnumPropertyItem nodetree_type_items[] = {
- {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes" },
+ {NTREE_SHADER, "SHADER", ICON_MATERIAL, "Shader", "Shader nodes" },
{NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes" },
{NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes" },
{0, NULL, 0, NULL, NULL}
@@ -189,7 +189,7 @@ static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr)
case NTREE_TEXTURE:
return &RNA_TextureNodeTree;
default:
- return &RNA_UnknownType;
+ return &RNA_NodeTree;
}
}
@@ -232,6 +232,8 @@ static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
case SOCK_RGBA:
return &RNA_NodeSocketRGBA;
break;
+ case SOCK_SHADER:
+ return &RNA_NodeSocketShader;
}
#undef SUBTYPE
@@ -2998,6 +3000,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
#undef SUBTYPE
rna_def_node_socket_subtype(brna, SOCK_BOOLEAN, 0, "NodeSocketBoolean", "Boolean Node Socket");
rna_def_node_socket_subtype(brna, SOCK_RGBA, 0, "NodeSocketRGBA", "RGBA Node Socket");
+ rna_def_node_socket_subtype(brna, SOCK_SHADER, 0, "NodeSocketShader", "Shader Closure Node Socket");
rna_def_node(brna);
rna_def_node_link(brna);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index f0ba435954b..137eebe6397 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1793,7 +1793,6 @@ static void rna_def_object(BlenderRNA *brna)
{OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounding box of the object"},
{OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"},
{OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"},
- // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""},
{OB_TEXTURE, "TEXTURED", 0, "Textured", "Draw the object with textures (if textures are enabled in the viewport)"},
{0, NULL, 0, NULL, NULL}};
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 5c494a3337f..0dc4ca343fe 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2505,6 +2505,11 @@ static void rna_def_space_node(BlenderRNA *brna)
{SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush"},
{0, NULL, 0, NULL, NULL}};
+ static EnumPropertyItem shader_type_items[] = {
+ {SNODE_SHADER_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit shader nodes from Object"},
+ {SNODE_SHADER_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit shader nodes from World"},
+ {0, NULL, 0, NULL, NULL}};
+
static EnumPropertyItem backdrop_channels_items[] = {
{0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"},
{SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
@@ -2528,6 +2533,12 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, NULL);
+ prop= RNA_def_property(srna, "shader_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "shaderfrom");
+ RNA_def_property_enum_items(prop, shader_type_items);
+ RNA_def_property_ui_text(prop, "Shader Type", "Type of data to take shader from");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, NULL);
+
prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "ID", "Datablock whose nodes are being edited");
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 21ab9d9c845..d421aff7157 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -46,6 +46,8 @@
#include "BKE_main.h"
#include "BKE_texture.h"
+#include "ED_node.h"
+
#include "WM_api.h"
static PointerRNA rna_World_lighting_get(PointerRNA *ptr)
@@ -119,6 +121,15 @@ static void rna_World_stars_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
WM_main_add_notifier(NC_WORLD|ND_WORLD_STARS, wo);
}
+static void rna_World_use_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ World *wrld= (World*)ptr->data;
+
+ if(wrld->use_nodes && wrld->nodetree==NULL)
+ ED_node_shader_default(scene, &wrld->id);
+
+ rna_World_update(bmain, scene, ptr);
+}
#else
@@ -552,6 +563,17 @@ void RNA_def_world(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Stars", "World stars settings");
+ /* nodes */
+ prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
+ RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based worlds");
+
+ prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the world");
+ RNA_def_property_update(prop, 0, "rna_World_use_nodes_update");
+
rna_def_lighting(brna);
rna_def_world_mist(brna);
rna_def_world_stars(brna);