Fix T48783: OSL render errors after recent refactoring.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 3 Jul 2016 11:08:21 +0000 (13:08 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 3 Jul 2016 11:08:21 +0000 (13:08 +0200)
intern/cycles/kernel/osl/osl_services.cpp
intern/cycles/kernel/shaders/CMakeLists.txt
intern/cycles/kernel/shaders/node_image_texture.osl
intern/cycles/kernel/shaders/node_rgb_to_bw.osl [new file with mode: 0644]
intern/cycles/render/nodes.cpp

index ebe739ebd0e2918cf749ac0cfcd226bb9ebe1765..acc6887cb1791b637f2c1cb03f9495d6b64c3171 100644 (file)
@@ -912,7 +912,7 @@ bool OSLRenderServices::texture(ustring filename,
 #endif
        bool status;
 
-       if(filename[0] == '@') {
+       if(filename.length() && filename[0] == '@') {
                int slot = atoi(filename.c_str() + 1);
                float4 rgba = kernel_tex_image_interp(slot, s, 1.0f - t);
 
@@ -993,7 +993,7 @@ bool OSLRenderServices::texture3d(ustring filename,
        }
 
        bool status;
-       if(filename[0] == '@') {
+       if(filename.length() && filename[0] == '@') {
                int slot = atoi(filename.c_str() + 1);
                float4 rgba = kernel_tex_image_interp_3d(slot, P.x, P.y, P.z);
 
index 49030f33c26efe69309b49f2283be7a5b73c5d34..b43f8402d42f57c7157acc8da476f87d8ca0566b 100644 (file)
@@ -81,6 +81,7 @@ set(SRC_OSL
        node_wireframe.osl
        node_hair_bsdf.osl
        node_uv_map.osl
+       node_rgb_to_bw.osl
 )
 
 set(SRC_OSL_HEADERS
index a00401845c819d907ae23930eb6486214c03fbc8..7cd2922dd4fac389dcea1ad1b58c44ed89667c7e 100644 (file)
@@ -88,7 +88,7 @@ shader node_image_texture(
        string color_space = "sRGB",
        string projection = "flat",
        string interpolation = "smartcubic",
-       string wrap = "periodic",
+       string extension = "periodic",
        float projection_blend = 0.0,
        int is_float = 1,
        int use_alpha = 1,
@@ -108,7 +108,7 @@ shader node_image_texture(
                                             use_alpha,
                                             is_float,
                                             interpolation,
-                                            wrap);
+                                            extension);
        }
        else if (projection == "box") {
                /* object space normal */
@@ -184,7 +184,7 @@ shader node_image_texture(
                                                                  use_alpha,
                                                                  is_float,
                                                                  interpolation,
-                                                                 wrap);
+                                                                 extension);
                        Alpha += weight[0] * tmp_alpha;
                }
                if (weight[1] > 0.0) {
@@ -195,7 +195,7 @@ shader node_image_texture(
                                                                  use_alpha,
                                                                  is_float,
                                                                  interpolation,
-                                                                 wrap);
+                                                                 extension);
                        Alpha += weight[1] * tmp_alpha;
                }
                if (weight[2] > 0.0) {
@@ -206,7 +206,7 @@ shader node_image_texture(
                                                                  use_alpha,
                                                                  is_float,
                                                                  interpolation,
-                                                                 wrap);
+                                                                 extension);
                        Alpha += weight[2] * tmp_alpha;
                }
        }
@@ -219,7 +219,7 @@ shader node_image_texture(
                                             use_alpha,
                                             is_float,
                                             interpolation,
-                                            wrap);
+                                            extension);
        }
        else if (projection == "tube") {
                point projected = map_to_tube(texco_remap_square(p));
@@ -230,6 +230,6 @@ shader node_image_texture(
                                             use_alpha,
                                             is_float,
                                             interpolation,
-                                            wrap);
+                                            extension);
        }
 }
diff --git a/intern/cycles/kernel/shaders/node_rgb_to_bw.osl b/intern/cycles/kernel/shaders/node_rgb_to_bw.osl
new file mode 100644 (file)
index 0000000..903dfcd
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2011-2013 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stdosl.h"
+
+shader node_rgb_to_bw(
+       color Color = 0.0,
+       output float Val = 0.0)
+{
+       Val = Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722;
+}
+
index b38135f59bd1e036a058236d659c099e03c7620a..15b55d17301053b8c5c66091340047abf33383e7 100644 (file)
@@ -1596,7 +1596,7 @@ void RGBToBWNode::compile(SVMCompiler& compiler)
 
 void RGBToBWNode::compile(OSLCompiler& compiler)
 {
-       compiler.add(this, "node_convert_from_color");
+       compiler.add(this, "node_rgb_to_bw");
 }
 
 /* Convert */