diff options
author | Ton Roosendaal <ton@blender.org> | 2008-09-19 20:01:22 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-09-19 20:01:22 +0400 |
commit | 65ddef19b92d39415a5943e01903d66ede9f1df6 (patch) | |
tree | d28d3580fa93f9304f2866b8ae7abc7460eaa774 /source/blender/render/intern | |
parent | a0504ac922b314929e0028b8bcd0c6b1cd7eef91 (diff) |
Patch #13422, By Roland Hess, Shadow Color
Finally, after a long time new render candy for the non-game peoples! :)
Good doc is here: (url splits in two)
http://www.harkyman.com/2008/08/06/controllable-shadow-intensity-
and-color/
Note the colorpicker for shadow is in "Shadow and Spot" panel. A bit
hidden, could get more attention. For later. :)
Diffstat (limited to 'source/blender/render/intern')
6 files changed, 29 insertions, 13 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 7e2194549cc..1768b052b54 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -421,6 +421,7 @@ typedef struct LampRen { short type; int mode; float r, g, b, k; + float shdwr, shdwg, shdwb; float energy, haint; int lay; float spotsi,spotbl; diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 8e56c4a852f..62833566652 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -55,7 +55,7 @@ struct ImBuf; void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf); void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, float *blend, int skyflag); void do_material_tex(struct ShadeInput *shi); -void do_lamp_tex(LampRen *la, float *lavec, struct ShadeInput *shi, float *colf); +void do_lamp_tex(LampRen *la, float *lavec, struct ShadeInput *shi, float *colf, short effect); void init_render_textures(Render *re); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 322d2066a6c..45d79be2f62 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3566,6 +3566,9 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->r= lar->energy*la->r; lar->g= lar->energy*la->g; lar->b= lar->energy*la->b; + lar->shdwr= la->shdwr; + lar->shdwg= la->shdwg; + lar->shdwb= la->shdwb; lar->k= la->k; // area @@ -3718,7 +3721,10 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) for(c=0; c<MAX_MTEX; c++) { if(la->mtex[c] && la->mtex[c]->tex) { - lar->mode |= LA_TEXTURE; + if (la->mtex[c]->mapto & LAMAP_COL) + lar->mode |= LA_TEXTURE; + if (la->mtex[c]->mapto & LAMAP_SHAD) + lar->mode |= LA_SHAD_TEX; if(G.rendering) { if(re->osa) { diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 2e3509f0471..ef723eea6b5 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -141,7 +141,7 @@ static void render_lighting_halo(HaloRen *har, float *colf) VECCOPY(shi.co, rco); shi.osatex= 0; - do_lamp_tex(lar, lv, &shi, lacol); + do_lamp_tex(lar, lv, &shi, lacol, LA_TEXTURE); } if(lar->type==LA_SPOT) { diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 5a80173d1f1..91621c24365 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1179,7 +1179,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int { Material *ma= shi->mat; VlakRen *vlr= shi->vlr; - float lv[3], lampdist, lacol[3], shadfac[4]; + float lv[3], lampdist, lacol[3], shadfac[4], lashdw[3]; float i, is, i_noshad, inp, *vn, *view, vnor[3], phongcorr=1.0f; float visifac; @@ -1219,7 +1219,12 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lacol[1]= lar->g; lacol[2]= lar->b; - if(lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol); + lashdw[0]= lar->shdwr; + lashdw[1]= lar->shdwg; + lashdw[2]= lar->shdwb; + + if(lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); + if(lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX); /* tangent case; calculate fake face normal, aligned with lampvector */ /* note, vnor==vn is used as tangent trigger for buffer shadow */ @@ -1342,13 +1347,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int if((lar->mode & LA_ONLYSHADOW) && i>0.0) { shadfac[3]= i*lar->energy*(1.0f-shadfac[3]); - shr->shad[0] -= shadfac[3]*shi->r; - shr->shad[1] -= shadfac[3]*shi->g; - shr->shad[2] -= shadfac[3]*shi->b; + shr->shad[0] -= shadfac[3]*shi->r*(1.0f-lashdw[0]); + shr->shad[1] -= shadfac[3]*shi->g*(1.0f-lashdw[1]); + shr->shad[2] -= shadfac[3]*shi->b*(1.0f-lashdw[2]); - shr->spec[0] -= shadfac[3]*shi->specr; - shr->spec[1] -= shadfac[3]*shi->specg; - shr->spec[2] -= shadfac[3]*shi->specb; + shr->spec[0] -= shadfac[3]*shi->specr*(1.0f-lashdw[0]); + shr->spec[1] -= shadfac[3]*shi->specg*(1.0f-lashdw[1]); + shr->spec[2] -= shadfac[3]*shi->specb*(1.0f-lashdw[2]); return; } @@ -1366,6 +1371,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int else add_to_diffuse(shr->shad, shi, is, i*lacol[0], i*lacol[1], i*lacol[2]); } + /* add light for colored shadow */ + if (i_noshad>i && !(lashdw[0]==0 && lashdw[1]==0 && lashdw[2]==0)) { + add_to_diffuse(shr->shad, shi, is, lashdw[0]*(i_noshad-i)*lacol[0], lashdw[1]*(i_noshad-i)*lacol[1], lashdw[2]*(i_noshad-i)*lacol[2]); + } if(i_noshad>0.0f) { if(passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) { if(ma->mode & MA_SHADOW_TRA) diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 27628d91465..628ac95710a 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -2301,7 +2301,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f /* ------------------------------------------------------------------------- */ /* colf supposed to be initialized with la->r,g,b */ -void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf) +void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, short effect) { Object *ob; MTex *mtex; @@ -2440,7 +2440,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf) } /* mapping */ - if(mtex->mapto & LAMAP_COL) { + if(((mtex->mapto & LAMAP_COL) && (effect & LA_TEXTURE))||((mtex->mapto & LAMAP_SHAD) && (effect & LA_SHAD_TEX))) { float col[3]; if(rgb==0) { |