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!
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user