Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-09-15 19:41:37 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-09-15 19:41:37 +0400
commit21964e65380131324dcb50567e913cf6e4a29102 (patch)
tree3dd5dd0d705ac1fb312cc9e2ce0c9cffea854c12 /intern/cycles/render/osl.cpp
parent2390a2657e3ba1bde477d999c06d000491edbea8 (diff)
OSL implementation of RGB ramp node.
The sampled color ramp data is passed to OSL as a color array. This has to be done as actual float[3] array though, since the Cycles float3 type actually contains 4 floats, leading to shifting color components in the array. Additional parameter set functions for arrays have been added to the Cycles OSL interface for this purpose.
Diffstat (limited to 'intern/cycles/render/osl.cpp')
-rw-r--r--intern/cycles/render/osl.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index dbd6b0ac9d9..75a10d38c5d 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -309,6 +309,70 @@ void OSLCompiler::parameter(const char *name, const Transform& tfm)
ss->Parameter(name, TypeDesc::TypeMatrix, (float*)&tfm);
}
+void OSLCompiler::parameter_array(const char *name, const float f[], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeFloat;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_color_array(const char *name, const float f[][3], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeColor;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_vector_array(const char *name, const float f[][3], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeVector;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_normal_array(const char *name, const float f[][3], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeNormal;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_point_array(const char *name, const float f[][3], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypePoint;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_array(const char *name, const int f[], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeInt;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, f);
+}
+
+void OSLCompiler::parameter_array(const char *name, const char * const s[], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeString;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, s);
+}
+
+void OSLCompiler::parameter_array(const char *name, const Transform tfm[], int arraylen)
+{
+ OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
+ TypeDesc type = TypeDesc::TypeMatrix;
+ type.arraylen = arraylen;
+ ss->Parameter(name, type, (const float *)tfm);
+}
+
void OSLCompiler::find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input)
{
ShaderNode *node = (input->link)? input->link->parent: NULL;