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:
authorJeroen Bakker <j.bakker@atmind.nl>2011-07-04 22:14:41 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2011-07-04 22:14:41 +0400
commitc4491f558b77530ef45ef7a1b80ba7567e338bae (patch)
tree5c1ce078945aee276a5dd0202eba49a93f648ce6 /source/blender/render
parent7c1514344911ff2c44f45111429726fd39ff4b74 (diff)
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⇒Render layer⇒Passes⇒Material index will be added Material⇒Options⇒Pass index will be added DNA Material struct will get an new field called “index”. this will be a short-type. Material struct the field pad will be removed. A new Render-layer pass will be added (bit 1«18) RNA Material RNA is updated (based on “pass index” 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 “IndexMA” 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 :)
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/pipeline.c13
-rw-r--r--source/blender/render/intern/source/rendercore.c10
-rw-r--r--source/blender/render/intern/source/shadeinput.c2
-rw-r--r--source/blender/render/intern/source/zbuf.c13
4 files changed, 31 insertions, 7 deletions
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 1d4014aac3e..37226018a91 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -383,7 +383,11 @@ static const char *get_pass_name(int passtype, int channel)
if(channel==-1) return "IndexOB";
return "IndexOB.X";
}
- if(passtype == SCE_PASS_MIST) {
+ if(passtype == SCE_PASS_INDEXMA) {
+ if(channel==-1) return "IndexMA";
+ return "IndexMA.X";
+ }
+ if(passtype == SCE_PASS_MIST) {
if(channel==-1) return "Mist";
return "Mist.Z";
}
@@ -448,6 +452,9 @@ static int passtype_from_name(char *str)
if(strcmp(str, "IndexOB")==0)
return SCE_PASS_INDEXOB;
+ if(strcmp(str, "IndexMA")==0)
+ return SCE_PASS_INDEXMA;
+
if(strcmp(str, "Mist")==0)
return SCE_PASS_MIST;
@@ -631,7 +638,9 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop, int
render_layer_add_pass(rr, rl, 3, SCE_PASS_REFRACT);
if(srl->passflag & SCE_PASS_INDEXOB)
render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB);
- if(srl->passflag & SCE_PASS_MIST)
+ if(srl->passflag & SCE_PASS_INDEXMA)
+ render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA);
+ if(srl->passflag & SCE_PASS_MIST)
render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST);
if(rl->passflag & SCE_PASS_RAYHITS)
render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 6747784b21a..11ae721ad95 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -515,7 +515,15 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset,
*fp= (float)shi->obr->ob->index;
}
break;
- case SCE_PASS_MIST:
+ case SCE_PASS_INDEXMA:
+ /* no filter */
+ if(shi->vlr) {
+ fp= rpass->rect + offset;
+ if(*fp==0.0f)
+ *fp= (float)shi->mat->index;
+ }
+ break;
+ case SCE_PASS_MIST:
/* */
col= &shr->mist;
pixsize= 1;
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 2702b7e5145..277cec1835a 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -1455,7 +1455,7 @@ int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y)
shade_samples_do_AO(ssamp);
/* if shade (all shadepinputs have same passflag) */
- if(ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB)) {
+ if(ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) {
for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) {
shade_input_set_shade_texco(shi);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 98dbb796f5b..3ac6d2c33ff 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -3497,7 +3497,7 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
RenderPass *rpass;
for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
- if(rpass->passtype == SCE_PASS_INDEXOB) {
+ if(rpass->passtype == SCE_PASS_INDEXOB||rpass->passtype == SCE_PASS_INDEXMA) {
float *fp= rpass->rect + offset;
*fp= (float)ob->index;
break;
@@ -3820,7 +3820,7 @@ static int shade_tra_samples(ShadeSample *ssamp, StrandShadeCache *cache, int x,
shade_samples_do_AO(ssamp);
/* if shade (all shadepinputs have same passflag) */
- if(shi->passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB)) {
+ if(shi->passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) {
for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) {
shade_input_set_shade_texco(shi);
shade_input_do_shade(shi, shr);
@@ -4115,7 +4115,14 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
add_transp_obindex(rlpp[a], od, obr->ob);
}
}
-
+ if(addpassflag & SCE_PASS_INDEXMA) {
+ ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr;
+ if(obr->ob) {
+ for(a= 0; a<totfullsample; a++)
+ add_transp_obindex(rlpp[a], od, obr->ob);
+ }
+ }
+
/* for each mask-sample we alpha-under colors. then in end it's added using filter */
memset(samp_shr, 0, sizeof(ShadeResult)*osa);
for(a=0; a<osa; a++) {