Hey man, nice going. I do detect a problem with node materials. I believe the MatID should be in "Render Pipeline Options" for node materials and affect the entire node shader. See why in this blend
http://www.pasteall.org/blend/7439 cheers! Daniel Salazar 3Developer.com On Mon, Jul 4, 2011 at 12:14 PM, Jeroen Bakker <j.bak...@atmind.nl> wrote: > Revision: 38090 > > http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38090 > Author: jbakker > Date: 2011-07-04 18:14:41 +0000 (Mon, 04 Jul 2011) > Log Message: > ----------- > Current situation > > A mesh can consist out of multiple material. Take a character with > clothing's. the skin can be a different material as the different clothing's. > During compositing it is a common use-case to only do a part of the composit > on only a specific material. Currently this can not be done. > > In blender movies this feature is known to be implemented, but until now it > never got integrated into trunk. > Proposal > > With material index the Blender internal renderer will be capable of creating > a buffer containing the material indexes of the first pixel-hit. This will be > implemented in the same manner as the object index. > > In the compositor the ID Mask node can be used to extract the information out > of the Render pass. > Impact > User interface > > On the properties-space the next changes will be done > > Scene?\226?\135?\146Render > layer?\226?\135?\146Passes?\226?\135?\146Material index will be added > Material?\226?\135?\146Options?\226?\135?\146Pass index will be added > > DNA > > Material struct will get an new field called > ?\226?\128?\156index?\226?\128?\157. this will be a short-type. > Material struct the field pad will be removed. > A new Render-layer pass will be added (bit 1?\194?\17118) > > RNA > > Material RNA is updated (based on ?\226?\128?\156pass index?\226?\128?\157 > from object) > Render layer RNA is updated (based on IndexOB) > > Blender internal renderer > > The Blender internal renderer will process the render pass as a copy of the > Object index. > Blender compositor > > The render layer input will get a new output socket called > ?\226?\128?\156IndexMA?\226?\128?\157 > Usage > > An example on how to use material index can be found at: > > https://svn.blender.org/svnroot/bf-blender/trunk/lib/tests/compositing/composite_materialindex.blend > > This is also example of a commit message longer than the commit itself :) > > Modified Paths: > -------------- > trunk/blender/release/scripts/startup/bl_ui/properties_material.py > trunk/blender/release/scripts/startup/bl_ui/properties_render.py > trunk/blender/source/blender/blenkernel/BKE_node.h > trunk/blender/source/blender/blenkernel/intern/node.c > trunk/blender/source/blender/editors/space_outliner/outliner.c > trunk/blender/source/blender/makesdna/DNA_material_types.h > trunk/blender/source/blender/makesdna/DNA_scene_types.h > trunk/blender/source/blender/makesrna/intern/rna_material.c > trunk/blender/source/blender/makesrna/intern/rna_render.c > trunk/blender/source/blender/makesrna/intern/rna_scene.c > trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c > trunk/blender/source/blender/render/intern/source/pipeline.c > trunk/blender/source/blender/render/intern/source/rendercore.c > trunk/blender/source/blender/render/intern/source/shadeinput.c > trunk/blender/source/blender/render/intern/source/zbuf.c > > Modified: trunk/blender/release/scripts/startup/bl_ui/properties_material.py > =================================================================== > --- trunk/blender/release/scripts/startup/bl_ui/properties_material.py > 2011-07-04 18:11:41 UTC (rev 38089) > +++ trunk/blender/release/scripts/startup/bl_ui/properties_material.py > 2011-07-04 18:14:41 UTC (rev 38090) > @@ -729,6 +729,7 @@ > 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") > > > class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): > > Modified: trunk/blender/release/scripts/startup/bl_ui/properties_render.py > =================================================================== > --- trunk/blender/release/scripts/startup/bl_ui/properties_render.py > 2011-07-04 18:11:41 UTC (rev 38089) > +++ trunk/blender/release/scripts/startup/bl_ui/properties_render.py > 2011-07-04 18:14:41 UTC (rev 38090) > @@ -141,6 +141,7 @@ > col.prop(rl, "use_pass_uv") > col.prop(rl, "use_pass_mist") > col.prop(rl, "use_pass_object_index") > + col.prop(rl, "use_pass_material_index") > col.prop(rl, "use_pass_color") > > col = split.column() > > Modified: trunk/blender/source/blender/blenkernel/BKE_node.h > =================================================================== > --- trunk/blender/source/blender/blenkernel/BKE_node.h 2011-07-04 18:11:41 > UTC (rev 38089) > +++ trunk/blender/source/blender/blenkernel/BKE_node.h 2011-07-04 18:14:41 > UTC (rev 38090) > @@ -319,9 +319,10 @@ > #define RRES_OUT_REFRACT 12 > #define RRES_OUT_INDIRECT 13 > #define RRES_OUT_INDEXOB 14 > -#define RRES_OUT_MIST 15 > -#define RRES_OUT_EMIT 16 > -#define RRES_OUT_ENV 17 > +#define RRES_OUT_INDEXMA 15 > +#define RRES_OUT_MIST 16 > +#define RRES_OUT_EMIT 17 > +#define RRES_OUT_ENV 18 > > /* note: types are needed to restore callbacks, don't change values */ > #define CMP_NODE_VIEWER 201 > > Modified: trunk/blender/source/blender/blenkernel/intern/node.c > =================================================================== > --- trunk/blender/source/blender/blenkernel/intern/node.c 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/blenkernel/intern/node.c 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -3156,7 +3156,9 @@ > if(!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; > sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); > if(!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; > - sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); > + sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXMA); > + if(!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL; > + sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); > if(!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; > sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT); > if(!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; > > Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c > =================================================================== > --- trunk/blender/source/blender/editors/space_outliner/outliner.c > 2011-07-04 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/editors/space_outliner/outliner.c > 2011-07-04 18:14:41 UTC (rev 38090) > @@ -480,7 +480,11 @@ > te->name= "Index Object"; > te->directdata= &srl->passflag; > > - te= outliner_add_element(soops, &tenla->subtree, id, tenla, > TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); > + te= outliner_add_element(soops, &tenla->subtree, id, tenla, > TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); > + te->name= "Index Material"; > + te->directdata= &srl->passflag; > + > + te= outliner_add_element(soops, &tenla->subtree, id, tenla, > TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); > te->name= "Color"; > te->directdata= &srl->passflag; > > > Modified: trunk/blender/source/blender/makesdna/DNA_material_types.h > =================================================================== > --- trunk/blender/source/blender/makesdna/DNA_material_types.h 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/makesdna/DNA_material_types.h 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -161,7 +161,7 @@ > > int mapto_textured; /* render-time cache to optimise texture > lookups */ > short shadowonly_flag; /* "shadowsonly" type */ > - short pad; > + short index; /* custom index for render passes */ > > ListBase gpumaterial; /* runtime */ > } Material; > > Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h > =================================================================== > --- trunk/blender/source/blender/makesdna/DNA_scene_types.h 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/makesdna/DNA_scene_types.h 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -201,6 +201,7 @@ > #define SCE_PASS_RAYHITS (1<<15) > #define SCE_PASS_EMIT (1<<16) > #define SCE_PASS_ENVIRONMENT (1<<17) > +#define SCE_PASS_INDEXMA (1<<18) > > /* note, srl->passflag is treestore element 'nr' in outliner, short still... > */ > > > Modified: trunk/blender/source/blender/makesrna/intern/rna_material.c > =================================================================== > --- trunk/blender/source/blender/makesrna/intern/rna_material.c 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/makesrna/intern/rna_material.c 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -1675,7 +1675,12 @@ > RNA_def_property_flag(prop, PROP_EDITABLE); > RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps > in this Group"); > RNA_def_property_update(prop, 0, "rna_Material_update"); > - > + > + prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); > + RNA_def_property_int_sdna(prop, NULL, "index"); > + RNA_def_property_ui_text(prop, "Pass Index", "Index # for the > IndexMA render pass"); > + RNA_def_property_update(prop, NC_OBJECT, NULL); > + > /* flags */ > > prop= RNA_def_property(srna, "use_light_group_exclusive", > PROP_BOOLEAN, PROP_NONE); > > Modified: trunk/blender/source/blender/makesrna/intern/rna_render.c > =================================================================== > --- trunk/blender/source/blender/makesrna/intern/rna_render.c 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/makesrna/intern/rna_render.c 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -388,7 +388,8 @@ > {SCE_PASS_MIST, "MIST", 0, "Mist", ""}, > {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""}, > {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""}, > - {0, NULL, 0, NULL, NULL}}; > + {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", > ""}, > + {0, NULL, 0, NULL, NULL}}; > > srna= RNA_def_struct(brna, "RenderPass", NULL); > RNA_def_struct_ui_text(srna, "Render Pass", ""); > > Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c > =================================================================== > --- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2011-07-04 > 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2011-07-04 > 18:14:41 UTC (rev 38090) > @@ -1515,7 +1515,13 @@ > if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, > "rna_SceneRenderLayer_pass_update"); > else RNA_def_property_clear_flag(prop, PROP_EDITABLE); > > - prop= RNA_def_property(srna, "use_pass_color", PROP_BOOLEAN, > PROP_NONE); > + prop= RNA_def_property(srna, "use_pass_material_index", > PROP_BOOLEAN, PROP_NONE); > + RNA_def_property_boolean_sdna(prop, NULL, "passflag", > SCE_PASS_INDEXMA); > + RNA_def_property_ui_text(prop, "Material Index", "Deliver material > index pass"); > + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, > "rna_SceneRenderLayer_pass_update"); > + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); > + > + prop= RNA_def_property(srna, "use_pass_color", PROP_BOOLEAN, > PROP_NONE); > RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_RGBA); > RNA_def_property_ui_text(prop, "Color", "Deliver shade-less color > pass"); > if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, > "rna_SceneRenderLayer_pass_update"); > > Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c > =================================================================== > --- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c > 2011-07-04 18:11:41 UTC (rev 38089) > +++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_image.c > 2011-07-04 18:14:41 UTC (rev 38090) > @@ -53,7 +53,8 @@ > { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > { SOCK_VALUE, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > - { SOCK_VALUE, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > + { SOCK_VALUE, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > + { SOCK_VALUE, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > { SOCK_RGBA, 0, "Environment",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, > 1.0f}, > { -1, 0, "" } > @@ -211,7 +212,9 @@ > out[RRES_OUT_INDIRECT]->data= compbuf_multilayer_get(rd, rl, > ima, iuser, SCE_PASS_INDIRECT); > if(out[RRES_OUT_INDEXOB]->hasoutput) > out[RRES_OUT_INDEXOB]->data= compbuf_multilayer_get(rd, rl, > ima, iuser, SCE_PASS_INDEXOB); > - if(out[RRES_OUT_MIST]->hasoutput) > + if(out[RRES_OUT_INDEXMA]->hasoutput) > + out[RRES_OUT_INDEXMA]->data= compbuf_multilayer_get(rd, rl, > ima, iuser, SCE_PASS_INDEXMA); > + if(out[RRES_OUT_MIST]->hasoutput) > out[RRES_OUT_MIST]->data= compbuf_multilayer_get(rd, rl, ima, > iuser, SCE_PASS_MIST); > if(out[RRES_OUT_EMIT]->hasoutput) > out[RRES_OUT_EMIT]->data= compbuf_multilayer_get(rd, rl, ima, > iuser, SCE_PASS_EMIT); > @@ -326,7 +329,7 @@ > CompBuf *buf; > int buftype= CB_VEC3; > > - if(ELEM3(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, > SCE_PASS_MIST)) > + if(ELEM4(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, > SCE_PASS_MIST, SCE_PASS_INDEXMA)) > buftype= CB_VAL; > else if(passcode==SCE_PASS_VECTOR) > buftype= CB_VEC4; > @@ -373,6 +376,8 @@ > out[RRES_OUT_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, > recty, SCE_PASS_INDIRECT); > if(out[RRES_OUT_INDEXOB]->hasoutput) > out[RRES_OUT_INDEXOB]->data= compbuf_from_pass(rd, rl, rectx, > recty, SCE_PASS_INDEXOB); > + if(out[RRES_OUT_INDEXMA]->hasoutput) > + out[RRES_OUT_INDEXMA]->data= compbuf_from_pass(rd, rl, rectx, > recty, SCE_PASS_INDEXMA); > if(out[RRES_OUT_MIST]->hasoutput) > > @@ Diff output truncated at 10240 characters. @@ > _______________________________________________ > Bf-blender-cvs mailing list > bf-blender-...@blender.org > http://lists.blender.org/mailman/listinfo/bf-blender-cvs > _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers