forked from bartvdbraak/blender
Merge branch 'blender-v2.93-release'
This commit is contained in:
commit
93b7c9595b
@ -57,14 +57,22 @@ ccl_device ccl_addr_space void *closure_alloc_extra(ShaderData *sd, int size)
|
|||||||
|
|
||||||
ccl_device_inline ShaderClosure *bsdf_alloc(ShaderData *sd, int size, float3 weight)
|
ccl_device_inline ShaderClosure *bsdf_alloc(ShaderData *sd, int size, float3 weight)
|
||||||
{
|
{
|
||||||
|
const float sample_weight = fabsf(average(weight));
|
||||||
|
|
||||||
|
/* Use comparison this way to help dealing with non-finite weight: if the average is not finite
|
||||||
|
* we will not allocate new closure. */
|
||||||
|
if (sample_weight >= CLOSURE_WEIGHT_CUTOFF) {
|
||||||
ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
|
ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
|
||||||
|
if (sc == NULL) {
|
||||||
if (sc == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
float sample_weight = fabsf(average(weight));
|
|
||||||
sc->sample_weight = sample_weight;
|
sc->sample_weight = sample_weight;
|
||||||
return (sample_weight >= CLOSURE_WEIGHT_CUTOFF) ? sc : NULL;
|
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __OSL__
|
#ifdef __OSL__
|
||||||
@ -73,17 +81,25 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd,
|
|||||||
float3 weight,
|
float3 weight,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
|
const float sample_weight = fabsf(average(weight));
|
||||||
|
|
||||||
if (!sc)
|
/* Use comparison this way to help dealing with non-finite weight: if the average is not finite
|
||||||
|
* we will not allocate new closure. */
|
||||||
|
if (sample_weight >= CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
|
||||||
|
if (!sc) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy((void *)sc, data, size);
|
memcpy((void *)sc, data, size);
|
||||||
|
|
||||||
float sample_weight = fabsf(average(weight));
|
|
||||||
sc->weight = weight;
|
sc->weight = weight;
|
||||||
sc->sample_weight = sample_weight;
|
sc->sample_weight = sample_weight;
|
||||||
return (sample_weight >= CLOSURE_WEIGHT_CUTOFF) ? sc : NULL;
|
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user