This is really @cppBeginner's answer to his own post.. (see commentary on OP). The `backfacing()` function can be called on the implicit shading point in an OSL script, but is not available as an attribute returned in a message from a script-cast ray. But many [mesh and object attributes][1] can be returned by OSL's `trace()`. See `getmessage ("trace", ...)` in the [OSL specification][2].. this page of [Blender source][3] might help with types, etc.. (but that's only a grep, I don't strictly know how it ties in. Maybe someone can edit to flesh that out.) These attributes include `geom:trianglevertices`, which is an array of three 3D points: the coordinates in World space of the corners of the triangle containing the shading point. They appear to be in order, so their cross-product can be taken to find the direction of the triangle's normal, as defined by the mesh. #include "stdosl.h" shader Hit_Backfacing ( vector RayDir = vector(0.0), output int Hit = 0, output int Hit_Backfacing = 0 ){ if (trace(P,rayDir)){ Hit = 1; vector triNormal = vector(0.0); point triVerts[3]; getmessage("trace","geom:trianglevertices",triVerts); triNormal = cross(triVerts[1]-triVerts[0],triVerts[2]-triVerts[0]); Hit_Backfacing = dot(triNormal,rayDir) > 0; } } In this example, the sign of dot-product of that normal and the cast ray direction tells us whether the triangle we hit faces us, or not... [![enter image description here][4]][4] The large plane carries the illustrated material. [<img src="https://blend-exchange.giantcowfilms.com/embedImage.png?bid=GEoObKwB" />](https://blend-exchange.giantcowfilms.com/b/GEoObKwB/) [1]: https://docs.blender.org/manual/en/2.79/render/cycles/nodes/osl.html#attributes [2]: https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf [3]: https://developer.blender.org/diffusion/B/browse/master/intern/cycles/kernel/osl/osl_services.cpp$78 [4]: https://i.sstatic.net/Rl2DQ.png