[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41112] branches/cycles/intern/cycles: Cycles: fix some issues with mix shaders when the weight for an emission shader

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Oct 19 02:13:43 CEST 2011


Revision: 41112
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41112
Author:   blendix
Date:     2011-10-19 00:13:41 +0000 (Wed, 19 Oct 2011)
Log Message:
-----------
Cycles: fix some issues with mix shaders when the weight for an emission shader
was 0.0, and background shader mix wasn't working.

Modified Paths:
--------------
    branches/cycles/intern/cycles/blender/addon/ui.py
    branches/cycles/intern/cycles/kernel/svm/svm.h
    branches/cycles/intern/cycles/kernel/svm/svm_closure.h
    branches/cycles/intern/cycles/render/nodes.cpp

Modified: branches/cycles/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/cycles/intern/cycles/blender/addon/ui.py	2011-10-18 23:36:43 UTC (rev 41111)
+++ branches/cycles/intern/cycles/blender/addon/ui.py	2011-10-19 00:13:41 UTC (rev 41112)
@@ -431,6 +431,7 @@
 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
     bl_label = "Volume"
     bl_context = "world"
+    bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
     def poll(cls, context):
@@ -460,6 +461,7 @@
 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
     bl_label = "Volume"
     bl_context = "material"
+    bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
     def poll(cls, context):

Modified: branches/cycles/intern/cycles/kernel/svm/svm.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/svm.h	2011-10-18 23:36:43 UTC (rev 41111)
+++ branches/cycles/intern/cycles/kernel/svm/svm.h	2011-10-19 00:13:41 UTC (rev 41112)
@@ -179,7 +179,7 @@
 				svm_node_closure_emission(sd, stack, node);
 				break;
 			case NODE_CLOSURE_BACKGROUND:
-				svm_node_closure_background(sd, node);
+				svm_node_closure_background(sd, stack, node);
 				break;
 			case NODE_CLOSURE_HOLDOUT:
 				svm_node_closure_holdout(sd, stack, node);

Modified: branches/cycles/intern/cycles/kernel/svm/svm_closure.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/svm_closure.h	2011-10-18 23:36:43 UTC (rev 41111)
+++ branches/cycles/intern/cycles/kernel/svm/svm_closure.h	2011-10-19 00:13:41 UTC (rev 41112)
@@ -236,7 +236,6 @@
 __device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
 {
 #ifdef __MULTI_CLOSURE__
-	ShaderClosure *sc = svm_node_closure_get(sd);
 	uint mix_weight_offset = node.y;
 
 	if(stack_valid(mix_weight_offset)) {
@@ -245,31 +244,52 @@
 		if(mix_weight == 0.0f)
 			return;
 
+		ShaderClosure *sc = svm_node_closure_get(sd);
 		sc->weight *= mix_weight;
+		sc->type = CLOSURE_EMISSION_ID;
 	}
+	else {
+		ShaderClosure *sc = svm_node_closure_get(sd);
+		sc->type = CLOSURE_EMISSION_ID;
+	}
+
 #else
 	ShaderClosure *sc = &sd->closure;
+	sc->type = CLOSURE_EMISSION_ID;
 #endif
 
-	sc->type = CLOSURE_EMISSION_ID;
 	sd->flag |= SD_EMISSION;
 }
 
-__device void svm_node_closure_background(ShaderData *sd, uint4 node)
+__device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
 {
 #ifdef __MULTI_CLOSURE__
-	ShaderClosure *sc = svm_node_closure_get(sd);
+	uint mix_weight_offset = node.y;
+
+	if(stack_valid(mix_weight_offset)) {
+		float mix_weight = stack_load_float(stack, mix_weight_offset);
+
+		if(mix_weight == 0.0f)
+			return;
+
+		ShaderClosure *sc = svm_node_closure_get(sd);
+		sc->weight *= mix_weight;
+		sc->type = CLOSURE_BACKGROUND_ID;
+	}
+	else {
+		ShaderClosure *sc = svm_node_closure_get(sd);
+		sc->type = CLOSURE_BACKGROUND_ID;
+	}
+
 #else
 	ShaderClosure *sc = &sd->closure;
+	sc->type = CLOSURE_BACKGROUND_ID;
 #endif
-
-	sc->type = CLOSURE_BACKGROUND_ID;
 }
 
 __device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
 {
 #ifdef __MULTI_CLOSURE__
-	ShaderClosure *sc = svm_node_closure_get(sd);
 	uint mix_weight_offset = node.y;
 
 	if(stack_valid(mix_weight_offset)) {
@@ -278,17 +298,20 @@
 		if(mix_weight == 0.0f)
 			return;
 
+		ShaderClosure *sc = svm_node_closure_get(sd);
 		sc->weight = make_float3(mix_weight, mix_weight, mix_weight);
+		sc->type = CLOSURE_HOLDOUT_ID;
 	}
-	else
+	else {
+		ShaderClosure *sc = svm_node_closure_get(sd);
 		sc->weight = make_float3(1.0f, 1.0f, 1.0f);
-
-	sc->sample_weight = 0.0f;
+		sc->type = CLOSURE_HOLDOUT_ID;
+	}
 #else
 	ShaderClosure *sc = &sd->closure;
+	sc->type = CLOSURE_HOLDOUT_ID;
 #endif
 
-	sc->type = CLOSURE_HOLDOUT_ID;
 	sd->flag |= SD_HOLDOUT;
 }
 

Modified: branches/cycles/intern/cycles/render/nodes.cpp
===================================================================
--- branches/cycles/intern/cycles/render/nodes.cpp	2011-10-18 23:36:43 UTC (rev 41111)
+++ branches/cycles/intern/cycles/render/nodes.cpp	2011-10-19 00:13:41 UTC (rev 41112)
@@ -1370,7 +1370,7 @@
 	else
 		compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value*strength_in->value.x);
 
-	compiler.add_node(NODE_CLOSURE_BACKGROUND, CLOSURE_BACKGROUND_ID);
+	compiler.add_node(NODE_CLOSURE_BACKGROUND, compiler.closure_mix_weight_offset());
 }
 
 void BackgroundNode::compile(OSLCompiler& compiler)




More information about the Bf-blender-cvs mailing list