diff options
author | Ton Roosendaal <ton@blender.org> | 2008-01-19 14:17:12 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-01-19 14:17:12 +0300 |
commit | c8841a7f2f0e885335295b3cda34097e117d0edb (patch) | |
tree | d7ffd2daa844967a42cba8944b95da0b318e3e29 /source/blender | |
parent | e293eed86555487f1c64f4acbe8720690347452c (diff) |
Added new render pass: "Mist".
This is actually just the alpha value as currently being calculated
by the mist code. It is in many cases not very useful to have this as
alpha in shading result, also for postprocess and composite.
Note: this pass also works with "Mist" not set in World, of course.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 31 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_image.c | 9 | ||||
-rw-r--r-- | source/blender/render/extern/include/RE_shader_ext.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 9 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 9 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 11 | ||||
-rw-r--r-- | source/blender/render/intern/source/strand.c | 7 | ||||
-rw-r--r-- | source/blender/render/intern/source/zbuf.c | 21 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 3 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 2 | ||||
-rw-r--r-- | source/blender/src/outliner.c | 4 |
15 files changed, 92 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 2008b18b5ed..f324c5d693c 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -236,21 +236,22 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str /* ************** COMPOSITE NODES *************** */ /* output socket defines */ -#define RRES_OUT_IMAGE 0 -#define RRES_OUT_ALPHA 1 -#define RRES_OUT_Z 2 -#define RRES_OUT_NORMAL 3 -#define RRES_OUT_UV 4 -#define RRES_OUT_VEC 5 -#define RRES_OUT_RGBA 6 -#define RRES_OUT_DIFF 7 -#define RRES_OUT_SPEC 8 -#define RRES_OUT_SHADOW 9 -#define RRES_OUT_AO 10 -#define RRES_OUT_REFLECT 11 -#define RRES_OUT_REFRACT 12 -#define RRES_OUT_RADIO 13 -#define RRES_OUT_INDEXOB 14 +#define RRES_OUT_IMAGE 0 +#define RRES_OUT_ALPHA 1 +#define RRES_OUT_Z 2 +#define RRES_OUT_NORMAL 3 +#define RRES_OUT_UV 4 +#define RRES_OUT_VEC 5 +#define RRES_OUT_RGBA 6 +#define RRES_OUT_DIFF 7 +#define RRES_OUT_SPEC 8 +#define RRES_OUT_SHADOW 9 +#define RRES_OUT_AO 10 +#define RRES_OUT_REFLECT 11 +#define RRES_OUT_REFRACT 12 +#define RRES_OUT_RADIO 13 +#define RRES_OUT_INDEXOB 14 +#define RRES_OUT_MIST 15 /* note: types are needed to restore callbacks, don't change values */ #define CMP_NODE_VIEWER 201 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index ce14165a499..43a6f2091de 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2211,6 +2211,8 @@ static void force_hidden_passes(bNode *node, int passflag) if(!(passflag & SCE_PASS_RADIO)) 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); + if(!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; } diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index a5d404740cf..bc750e455a6 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -280,6 +280,7 @@ short imb_addrectfloatImBuf(struct ImBuf * ibuf) size = ibuf->x * ibuf->y; size = size * 4 * sizeof(float); + ibuf->channels= 4; if ( (ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf")) ){ ibuf->mall |= IB_rectfloat; @@ -445,7 +446,7 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) memcpy(ibuf2->rect, ibuf1->rect, x * y * sizeof(int)); if (flags & IB_rectfloat) - memcpy(ibuf2->rect_float, ibuf1->rect_float, 4 * x * y * sizeof(float)); + memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels * x * y * sizeof(float)); if (flags & IB_planes) memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int)); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 282093f39be..d5f3ce87cff 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -153,6 +153,8 @@ typedef struct SceneRenderLayer { #define SCE_PASS_INDEXOB 2048 #define SCE_PASS_UV 4096 #define SCE_PASS_RADIO 8192 +#define SCE_PASS_MIST 16384 + /* note, srl->passflag is treestore element 'nr' in outliner, short still... */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 20308e968d3..0984aa4bfe1 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -48,6 +48,7 @@ static bNodeSocketType cmp_node_rlayers_out[]= { { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 0, "Radio", 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}, { -1, 0, "" } }; @@ -149,6 +150,8 @@ void outputs_multilayer_get(RenderData *rd, RenderLayer *rl, bNodeStack **out, I out[RRES_OUT_RADIO]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_RADIO); 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) + out[RRES_OUT_MIST]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_MIST); }; @@ -236,7 +239,7 @@ static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, in CompBuf *buf; int buftype= CB_VEC3; - if(ELEM(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB)) + if(ELEM3(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST)) buftype= CB_VAL; else if(passcode==SCE_PASS_VECTOR) buftype= CB_VEC4; @@ -282,7 +285,9 @@ void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStack **out if(out[RRES_OUT_RADIO]->hasoutput) out[RRES_OUT_RADIO]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_RADIO); if(out[RRES_OUT_INDEXOB]->hasoutput) - out[RRES_OUT_INDEXOB]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXOB); + out[RRES_OUT_INDEXOB]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXOB); + if(out[RRES_OUT_MIST]->hasoutput) + out[RRES_OUT_MIST]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_MIST); }; diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 5d5db0471d8..8b5880ff507 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -47,7 +47,7 @@ typedef struct ShadeResult { float combined[4]; float col[4]; - float alpha; + float alpha, mist; float diff[3]; /* no ramps, shadow, etc */ float spec[3]; float shad[3]; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 7675747d18f..293b367a049 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3656,8 +3656,13 @@ void init_render_world(Render *re) } else { memset(&re->wrld, 0, sizeof(World)); - re->wrld.exp= 0.0; - re->wrld.range= 1.0; + re->wrld.exp= 0.0f; + re->wrld.range= 1.0f; + + /* for mist pass */ + re->wrld.miststa= re->clipsta; + re->wrld.mistdist= re->clipend-re->clipsta; + re->wrld.misi= 1.0f; } re->wrld.linfac= 1.0 + pow((2.0*re->wrld.exp + 0.5), -10); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 2c03b0ae6c7..ee50d28d55d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -331,6 +331,10 @@ static char *get_pass_name(int passtype, int channel) if(channel==-1) return "IndexOB"; return "IndexOB.X"; } + if(passtype == SCE_PASS_MIST) { + if(channel==-1) return "Mist"; + return "Mist.Z"; + } return "Unknown"; } @@ -379,6 +383,9 @@ static int passtype_from_name(char *str) if(strcmp(str, "IndexOB")==0) return SCE_PASS_INDEXOB; + if(strcmp(str, "Mist")==0) + return SCE_PASS_MIST; + return 0; } @@ -546,6 +553,8 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop, int render_layer_add_pass(rr, rl, 3, SCE_PASS_RADIO); if(srl->passflag & SCE_PASS_INDEXOB) render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB); + if(srl->passflag & SCE_PASS_MIST) + render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST); } /* sss, previewrender and envmap don't do layers, so we make a default one */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index d0ea69dc833..dbe149115d9 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -400,6 +400,12 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, *fp= (float)shi->obr->ob->index; } break; + case SCE_PASS_MIST: + /* */ + col= &shr->mist; + pixsize= 1; + break; + case SCE_PASS_VECTOR: { /* add minimum speed in pixel, no filter */ diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 586d54aa04b..3a8b0cca7fc 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -161,11 +161,16 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) } /* MIST */ - if((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { + if((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0)) { if(R.r.mode & R_ORTHO) - alpha= mistfactor(-shi->co[2], shi->co); + shr->mist= mistfactor(-shi->co[2], shi->co); else - alpha= mistfactor(VecLength(shi->co), shi->co); + shr->mist= mistfactor(VecLength(shi->co), shi->co); + } + else shr->mist= 0.0f; + + if((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { + alpha= shr->mist; } else alpha= 1.0f; diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index ccb3b3ee0f4..605b381cdc0 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -458,6 +458,11 @@ static int compare_strand_segment(const void *poin1, const void *poin2) return 1; } +static void interpolate_vec1(float *v1, float *v2, float t, float negt, float *v) +{ + v[0]= negt*v1[0] + t*v2[0]; +} + static void interpolate_vec3(float *v1, float *v2, float t, float negt, float *v) { v[0]= negt*v1[0] + t*v2[0]; @@ -504,6 +509,8 @@ static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float interpolate_vec3(shr1->refr, shr2->refr, t, negt, shr->refr); if(addpassflag & SCE_PASS_RADIO) interpolate_vec3(shr1->rad, shr2->rad, t, negt, shr->rad); + if(addpassflag & SCE_PASS_MIST) + interpolate_vec1(&shr1->mist, &shr2->mist, t, negt, &shr->mist); } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 98a19c8c0e0..223653ddf07 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3346,6 +3346,10 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) case SCE_PASS_NORMAL: col= shr->nor; break; + case SCE_PASS_MIST: + col= &shr->mist; + pixsize= 1; + break; case SCE_PASS_VECTOR: { @@ -3397,6 +3401,7 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph for(rpass= rl->passes.first; rpass; rpass= rpass->next) { float *fp, *col= NULL; + int pixsize= 3; switch(rpass->passtype) { case SCE_PASS_RGBA: @@ -3427,13 +3432,19 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph case SCE_PASS_NORMAL: col= shr->nor; break; + case SCE_PASS_MIST: + col= &shr->mist; + pixsize= 1; + break; } if(col) { - fp= rpass->rect + 3*offset; + fp= rpass->rect + pixsize*offset; fp[0]= alpha*col[0] + (1.0f-alpha)*fp[0]; - fp[1]= alpha*col[1] + (1.0f-alpha)*fp[1]; - fp[2]= alpha*col[2] + (1.0f-alpha)*fp[2]; + if(pixsize==3) { + fp[1]= alpha*col[1] + (1.0f-alpha)*fp[1]; + fp[2]= alpha*col[2] + (1.0f-alpha)*fp[2]; + } } } } @@ -3595,6 +3606,10 @@ int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassflag) if(addpassflag & SCE_PASS_RADIO) addvecmul(samp_shr->rad, shr->rad, fac); + + if(addpassflag & SCE_PASS_MIST) + samp_shr->mist= samp_shr->mist+fac*shr->mist; + } } } diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 178d92459c7..6c465cae953 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -2659,7 +2659,8 @@ static void render_panel_layers(void) uiDefButBitI(block, TOG, SCE_PASS_VECTOR, B_SET_PASS,"Vec", 120, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Speed Vector pass"); uiDefButBitI(block, TOG, SCE_PASS_NORMAL, B_SET_PASS,"Nor", 160, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Normal pass"); uiDefButBitI(block, TOG, SCE_PASS_UV, B_SET_PASS,"UV", 200, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Texture UV pass"); - uiDefButBitI(block, TOG, SCE_PASS_INDEXOB, B_SET_PASS,"IndexOb",240, 30, 70, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Object Index pass"); + uiDefButBitI(block, TOG, SCE_PASS_MIST, B_SET_PASS,"Mist", 240, 30, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Mist factor pass (0-1)"); + uiDefButBitI(block, TOG, SCE_PASS_INDEXOB, B_SET_PASS,"Index", 275, 30, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Object Index pass"); uiDefButBitI(block, TOG, SCE_PASS_RGBA, B_SET_PASS,"Col", 10, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver shade-less Color pass"); uiDefButBitI(block, TOG, SCE_PASS_DIFFUSE, B_SET_PASS,"Diff", 45, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass"); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index d21d4f3c8de..2ac76942da7 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -3831,7 +3831,7 @@ static void material_panel_shading(Material *ma) uiBlockBeginAlign(block); uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_MATPRV, "GR:", 9, 55, 150, 19, &ma->group, "Limit Lighting to Lamps in this Group"); - uiDefButBitI(block, TOG, MA_GROUP_NOLAY, B_MATPRV, "Exclusive", 159,55, 85,20, &(ma->mode), 0, 0, 0, 0, "The material exclusively uses Lamps in this Group"); + uiDefButBitI(block, TOG, MA_GROUP_NOLAY, B_MATPRV, "Exclusive", 159,55, 85,20, &(ma->mode), 0, 0, 0, 0, "Material uses Lights in this group exclusively, they get excluded from the Scene lighting"); } diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index f0d23f9988a..ed910607040 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -444,6 +444,10 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc te->name= "UV"; te->directdata= &srl->passflag; + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_MIST); + te->name= "Mist"; + te->directdata= &srl->passflag; + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_INDEXOB); te->name= "Index Object"; te->directdata= &srl->passflag; |