OSL missing distance to line segment function
Closed, ResolvedPublic

Description

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
.

Details

Type
Bug

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).

Brecht:
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.

provided a workarounf here for people needing it: http://blenderthings.blogspot.nl/2012/12/a-replacement-for-missing-osl-distance.html

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