[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38506] trunk/blender: fix for [#28012] Mat ID messy with shader nodes

Jeroen Bakker j.bakker at atmind.nl
Tue Jul 19 10:31:54 CEST 2011


Revision: 38506
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38506
Author:   jbakker
Date:     2011-07-19 08:31:53 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
fix for [#28012] Mat ID messy with shader nodes

Issue was that the Shader tree execution changed the ShaderInput.
Changes are that the UI is updated that only the main material will have the pass_index this is displayed in the "render pipeline options" panel.
When the material is not a node material the pass_index will be shown at the "options" panel

To test enable nodes on the material
Add a new input material
change the pass_index of the material (render pipeline options)
Enable RenderPass material ID and use the compositor to read out the material pass

Jeroen

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_material.py
    trunk/blender/source/blender/nodes/intern/SHD_util.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_material.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_material.py	2011-07-19 07:56:01 UTC (rev 38505)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_material.py	2011-07-19 08:31:53 UTC (rev 38506)
@@ -174,6 +174,7 @@
         row.prop(mat, "use_transparency")
         sub = row.column()
         sub.prop(mat, "offset_z")
+
         sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
 
         row = layout.row()
@@ -199,6 +200,7 @@
         col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
         col.prop(mat, "use_cast_buffer_shadows")
         col.prop(mat, "use_cast_approximate")
+        col.prop(mat, "pass_index")
 
 
 class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
@@ -729,7 +731,8 @@
         col.prop(mat, "use_vertex_color_paint")
         col.prop(mat, "use_vertex_color_light")
         col.prop(mat, "use_object_color")
-        col.prop(mat, "pass_index")
+        if simple_material(base_mat):
+            col.prop(mat, "pass_index")
 
 
 class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel):

Modified: trunk/blender/source/blender/nodes/intern/SHD_util.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/SHD_util.c	2011-07-19 07:56:01 UTC (rev 38505)
+++ trunk/blender/source/blender/nodes/intern/SHD_util.c	2011-07-19 08:31:53 UTC (rev 38506)
@@ -83,7 +83,11 @@
 void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
 {
 	ShaderCallData scd;
-	
+	/*
+	 @note: preserve material from ShadeInput for material id, nodetree execs change it
+	 fix for bug "[#28012] Mat ID messy with shader nodes"
+	 */
+	Material *mat = shi->mat;
 	/* convert caller data to struct */
 	scd.shi= shi;
 	scd.shr= shr;
@@ -92,7 +96,8 @@
 	memset(shr, 0, sizeof(ShadeResult));
 		   
 	ntreeExecTree(ntree, &scd, shi->thread);	/* threads */
-	
+	// @note: set material back to preserved material
+	shi->mat = mat;
 	/* better not allow negative for now */
 	if(shr->combined[0]<0.0f) shr->combined[0]= 0.0f;
 	if(shr->combined[1]<0.0f) shr->combined[1]= 0.0f;




More information about the Bf-blender-cvs mailing list