Page MenuHome

OSL missing distance to line segment function
Closed, ResolvedPublic


An OSL script that contains a call to distance(p,p1,p2) compiles fine but crashes blender when rendering starts. See attached screenshot for the detailed error message. It appears that this function is missing in the runtime OSL library, so this might be an OSL bug instead of a Blender issue. The two argument version of the function (distance(p1,p2) ) works fine.

My system: w32, blender r53247 from buildbot

steps to reproduce:

- with cycles & OSL enabled and viewport in anything but rendered mode
- add a node material
- add a script node, choose external and point to attached .osl script (should compile fine)
- enable console to see relevant error message
- switch viewport to rendered view

Event Timeline

We need Thomas' advice for this!

Seems to be strange to have OSL compile this fine, and then crash...

Crash confirmed, related to OSL itself.

OSL code only contains a "osl_distance_fvv" but not a "osl_distance_fvvv" shadeop.
I can't find it in the codebase of our blender-fixes branch (the one we used to compile the libs, currently in SVN).

OpenShadingLanguage\src\include\dual_vec.h only contains the code for the distance(point p0, point p1) function, the other (distance line -> point) is not there if I see that correct?

I forgot: As the function header is in stdosl.h, it compiles fine, but then it can't find the underneath code.

So OSL team either had this function before, and removed it again or it has not been implemented yet.

It seems this was never implemented. I've removed it now from our stdosl.h so it should now give a compile error, will look into a fix for OSL itself later.

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Resolved.Dec 22 2012, 4:16 PM

provided a workarounf here for people needing it:

instead of implementing it in the library it could be an alternative to implement it in stdosl.h