diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-03 16:21:44 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-03 16:21:44 +0400 |
commit | 41f98978e3430a7d38684d49891505bb954375aa (patch) | |
tree | a69caf8413332c0d359c7a873d86c77f16d3c4fc /intern/cycles/kernel/osl | |
parent | f00a49baaaf4b2f8d8a6a6265255fa7085a79bf8 (diff) |
Fix cycles issue when NaN is used for RGB ramp, can access array out of bounds then.
OSL noise() function is generating NaN's in certain cases, fix for that goes to our
OSL branch.
Also add missing minimum weight and max closure checks to OSL, forgot to add these
when fixing another bug.
Diffstat (limited to 'intern/cycles/kernel/osl')
-rw-r--r-- | intern/cycles/kernel/osl/osl_shader.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index 67a0e16419c..f72e4dd1384 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -150,13 +150,14 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, /* sample weight */ float sample_weight = fabsf(average(weight)); - sd->flag |= bsdf->shaderdata_flag(); - sc.sample_weight = sample_weight; sc.type = bsdf->shaderclosure_type(); /* add */ - sd->closure[sd->num_closure++] = sc; + if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) { + sd->closure[sd->num_closure++] = sc; + sd->flag |= bsdf->shaderdata_flag(); + } break; } case OSL::ClosurePrimitive::Emissive: { @@ -170,9 +171,10 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, sc.type = CLOSURE_EMISSION_ID; /* flag */ - sd->flag |= SD_EMISSION; - - sd->closure[sd->num_closure++] = sc; + if(sd->num_closure < MAX_CLOSURE) { + sd->closure[sd->num_closure++] = sc; + sd->flag |= SD_EMISSION; + } break; } case AmbientOcclusion: { @@ -185,8 +187,10 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, sc.sample_weight = sample_weight; sc.type = CLOSURE_AMBIENT_OCCLUSION_ID; - sd->closure[sd->num_closure++] = sc; - sd->flag |= SD_AO; + if(sd->num_closure < MAX_CLOSURE) { + sd->closure[sd->num_closure++] = sc; + sd->flag |= SD_AO; + } break; } case OSL::ClosurePrimitive::Holdout: @@ -195,8 +199,11 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, sc.sample_weight = 0.0f; sc.type = CLOSURE_HOLDOUT_ID; - sd->flag |= SD_HOLDOUT; - sd->closure[sd->num_closure++] = sc; + + if(sd->num_closure < MAX_CLOSURE) { + sd->closure[sd->num_closure++] = sc; + sd->flag |= SD_HOLDOUT; + } break; case OSL::ClosurePrimitive::BSSRDF: case OSL::ClosurePrimitive::Debug: @@ -334,7 +341,8 @@ static void flatten_volume_closure_tree(ShaderData *sd, sc.type = CLOSURE_VOLUME_ID; /* add */ - sd->closure[sd->num_closure++] = sc; + if(sc.sample_weight > 1e-5f && sd->num_closure < MAX_CLOSURE) + sd->closure[sd->num_closure++] = sc; break; } case OSL::ClosurePrimitive::Holdout: |