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-10-22 22:51:45 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-10-22 22:51:45 +0400
commit586c631c88d7a4ea24810bf18ab96ed7ec542d37 (patch)
treef82477dc819aede374c68f509b964929ff07f05a
parent9adfa289e800a52a7c4a47ea3ee8dcdf5b50f9c2 (diff)
Cycles: when creating nodes from a blender material, set the diffuse color in
the diffuse node, similar for lamps and world.
-rw-r--r--intern/cycles/blender/addon/ui.py11
-rw-r--r--source/blender/editors/space_node/node_edit.c46
2 files changed, 41 insertions, 16 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 94a48e6c42d..d894f66c32e 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -348,7 +348,7 @@ def find_node_input(node, name):
def panel_node_draw(layout, id, output_type, input_name):
if not id.node_tree:
- layout.prop(id, "use_nodes")
+ layout.prop(id, "use_nodes", icon='NODETREE')
return
ntree = id.node_tree
@@ -435,7 +435,8 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return context.world and CyclesButtonsPanel.poll(context)
+ world = context.world
+ return world and world.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
@@ -465,7 +466,8 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return context.material and CyclesButtonsPanel.poll(context)
+ mat = context.material
+ return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
@@ -484,7 +486,8 @@ class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
- return context.material and CyclesButtonsPanel.poll(context)
+ mat = context.material
+ return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 10c5ca7ee1a..83f15243ebe 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -283,16 +283,18 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree)
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);
switch(GS(id->name)) {
- case ID_MA:
- ((Material*)id)->nodetree = ntree;
+ case ID_MA: {
+ Material *ma= (Material*)id;
+ ma->nodetree = ntree;
if(scene_use_new_shading_nodes(scene)) {
output_type = SH_NODE_OUTPUT_MATERIAL;
@@ -302,17 +304,36 @@ void ED_node_shader_default(Scene *scene, ID *id)
output_type = SH_NODE_OUTPUT;
shader_type = SH_NODE_MATERIAL;
}
+
+ copy_v3_v3(color, &ma->r);
+ strength= 0.0f;
break;
- case ID_WO:
- ((World*)id)->nodetree = ntree;
+ }
+ case ID_WO: {
+ World *wo= (World*)id;
+
+ wo->nodetree = ntree;
output_type = SH_NODE_OUTPUT_WORLD;
shader_type = SH_NODE_BACKGROUND;
+
+ copy_v3_v3(color, &wo->horr);
+ strength= 1.0f;
break;
- case ID_LA:
+ }
+ case ID_LA: {
+ Lamp *la= (Lamp*)id;
+
((Lamp*)id)->nodetree = ntree;
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:
printf("ED_node_shader_default called on wrong ID type.\n");
return;
@@ -332,13 +353,14 @@ void ED_node_shader_default(Scene *scene, ID *id)
tosock= out->inputs.first;
nodeAddLink(ntree, in, fromsock, out, tosock);
- if(GS(id->name) == ID_LA) {
- Lamp *la= (Lamp*)id;
+ /* default values */
+ if(scene_use_new_shading_nodes(scene)) {
+ sock= in->inputs.first;
+ copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color);
- if(la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) {
- bNodeSocket *sock= in->inputs.last;
- bNodeSocketValueFloat *default_value= sock->default_value;
- default_value->value= 100.0f;
+ if(strength != 0.0f) {
+ sock= in->inputs.last;
+ ((bNodeSocketValueFloat*)sock->default_value)->value= strength;
}
}