diff options
author | Ton Roosendaal <ton@blender.org> | 2006-07-07 16:28:23 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-07-07 16:28:23 +0400 |
commit | 775d3561b1dfc5f133a07e8fbd8dc9079161a247 (patch) | |
tree | 824ea49adedd48376ead91b170962af2933d8d52 /source | |
parent | f51c8f276c0c7f214a36f87f79de63bded7438c8 (diff) |
Another fix based on venomgfx fraka .blend:
In december, when testing material layering, I've removed the check that
prevented specular and diffuse to become negative, this because it could
work nice for layering.
However, this breaks quite some cases too. For example negative lamps are
only used to cancel out other lights in same material, and should not give
negative (invisible!) peaks that work on a node system. Same goes for
negative diffuse from AO 'subtract' mode.
In fraka the error happened for AO on a translucent material. The inside
of the mesh got a negative AO, cancelling out the positive AO on the
outside.
Anyhoo; this commits ensures that a 'shade_lamp_loop' call will never
return negative values again!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 4d00ff13f9c..0d7d3fd1efa 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1897,14 +1897,21 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->alpha= shi->alpha; + if(shr->spec[0]<0.0f) shr->spec[0]= 0.0f; + if(shr->spec[1]<0.0f) shr->spec[1]= 0.0f; + if(shr->spec[2]<0.0f) shr->spec[2]= 0.0f; + shr->diff[0]+= shi->r*shi->amb*shi->rad[0]; shr->diff[0]+= shi->ambr; + if(shr->diff[0]<0.0f) shr->diff[0]= 0.0f; shr->diff[1]+= shi->g*shi->amb*shi->rad[1]; shr->diff[1]+= shi->ambg; + if(shr->diff[1]<0.0f) shr->diff[1]= 0.0f; shr->diff[2]+= shi->b*shi->amb*shi->rad[2]; shr->diff[2]+= shi->ambb; + if(shr->diff[2]<0.0f) shr->diff[2]= 0.0f; if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->diff, shi); if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shr->spec+1, shr->spec+2, shi); |