Cycles / Ramp closures:

* Fix crash with negative values in Phong Ramp, and add some checks to survive INF and NAN values. 

Patch by Brecht and myself.
This commit is contained in:
Thomas Dinges
2013-06-27 16:08:06 +00:00
parent c6ce8de20e
commit c15b13f78f
2 changed files with 6 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ __device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float
float npos = pos * (float)(MAXCOLORS - 1);
int ipos = float_to_int(npos);
if (ipos < 0)
return colors[0];
if (ipos >= (MAXCOLORS - 1))
return colors[MAXCOLORS - 1];
float offset = npos - (float)ipos;

View File

@@ -41,6 +41,8 @@ __device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3
float npos = pos * (float)(MAXCOLORS - 1);
int ipos = float_to_int(npos);
if (ipos < 0)
return colors[0];
if (ipos >= (MAXCOLORS - 1))
return colors[MAXCOLORS - 1];
float offset = npos - (float)ipos;
@@ -49,6 +51,8 @@ __device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3
__device int bsdf_phong_ramp_setup(ShaderClosure *sc)
{
sc->data0 = max(sc->data0, 0.0f);
sc->type = CLOSURE_BSDF_PHONG_RAMP_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
}