This patch Implements a subset of osl on top of cycles-svm
Tested on:
-MSVC2013/X64
-CPU
-GPU Cuda/gtx670
-GPU OpenCL/gtx670
Current state:
- This patch picks up the compiled oso file and implements a basic oso->svm compiler. External files are currently not supported. (Couldn't find a hook i could use in the osl compiler classes that would just give me the bytecode)
- Pretty much all math related operators are implemented, most procedural shaders should work even complex ones like the mandelbulb and lyapunov volume shaders from https://github.com/maitag/blender-osl-shader and many of the procedural ones from https://github.com/sambler/osl-shaders
- Loops are fully supported (do/while, while, for)
- Except the color closure and matrix datatypes, all datatypes should be supported.
- Given the small stack space we have for svm, string support is very limited, strings are hashed (hash is lame right now, should really replace it with crc32 or something better) during pre-process, so direct compares and assignment works, but none of the concatenation, substring, etc operators.
- Colorspace Conversion is limited, while hsv->rgb conversion works, the results are different between svm and osl, seems like svm is clipping the input values while osl looks to do a modulus , noticed a difference haven't investigated the cause yet.
- No matrix support what so ever.
- No closures, I don't understand well enough how they are implemented in cycles (or what they really are) so I left this for 'some other time' or 'someone smarter'
- Limited globals, P works, i'm fairly sure I implemented u/v wrong given the results are quite different between osl and this implementation all others are missing.
- No texture support
- No transformations
- No debug printf support
- Noise, cellnoise 3D works, everything else is either not implemented or give a different results compared to regular osl.
- No Pointcloud support
- the Math node has been extended significantly, while all new operations have been tested, I have not exposed them to the end user in the Node Editor UI. The math node has this drop down that becomes really long/useless with this many items in there, a better UI solution might be needed here. Other nodes (like integermath) are not exposed in the end user UI at all.
Performance:
Some benchmarks:
http://www.lazydodo.com/tmp/osl_gpu.png
http://www.lazydodo.com/tmp/gpu_osl3.jpg
http://www.lazydodo.com/tmp/gpu_osl2.png
When rendering 100% osl shaded pixels, osl generally is faster, but when used for a few elements in a scene, svm tends to be the faster one
Overall conclusion:
If you're using osl for procedurals, this patch is fairly feature complete, and will work wonderfully , more advanced use is currently not supported, some things should be trivial to implement (transformations) others not as much (string support will be hard given the limited stack space available) others will be near impossible (printf from a shader? yeahh unlikely that'll happen)
The biggest risk is the oso format, it's is not standardized / documented , the osl people are free to completely change this format next revision and screw up this implementation.