Fix T66171: Cycles OSL trace() crashing in displacement shaders

This is not supported, meshes do not exist in the BVH before displacement.
This commit is contained in:
Brecht Van Lommel 2019-06-27 12:39:10 +02:00
parent 6f516fcc63
commit 5eb156e769
Notes: blender-bot 2023-02-14 02:05:08 +01:00
Referenced by issue #66171, OSL Crashes when script with trace connected to displacement output
1 changed files with 8 additions and 1 deletions

View File

@ -1392,9 +1392,16 @@ bool OSLRenderServices::trace(TraceOpt &options,
tracedata->init = true;
tracedata->sd.osl_globals = sd->osl_globals;
KernelGlobals *kg = sd->osl_globals;
/* Can't raytrace from shaders like displacement, before BVH exists. */
if (kernel_data.bvh.bvh_layout == BVH_LAYOUT_NONE) {
return false;
}
/* Raytrace, leaving out shadow opaque to avoid early exit. */
uint visibility = PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE;
return scene_intersect(sd->osl_globals, ray, visibility, &tracedata->isect);
return scene_intersect(kg, ray, visibility, &tracedata->isect);
}
bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg,