Cycles OSL: refactoring and fixes
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 3 Nov 2012 14:32:13 +0000 (14:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 3 Nov 2012 14:32:13 +0000 (14:32 +0000)
* Moved kernel/osl/nodes to kernel/shaders
* Renamed standard attributes to use geom:, particle:, object: prefixes
* Update stdosl.h to properly reflect the closures we support
* Fix the wrong stdosl.h being used for building shaders
* Add geom:numpolyvertices, geom:trianglevertices, geom:polyvertices attributes

74 files changed:
CMakeLists.txt
intern/cycles/blender/addon/engine.py
intern/cycles/blender/addon/enums.py
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/closure/bsdf_microfacet.h
intern/cycles/kernel/kernel_triangle.h
intern/cycles/kernel/osl/CMakeLists.txt
intern/cycles/kernel/osl/osl_services.cpp
intern/cycles/kernel/shaders/CMakeLists.txt [moved from intern/cycles/kernel/osl/nodes/CMakeLists.txt with 89% similarity]
intern/cycles/kernel/shaders/node_add_closure.osl [moved from intern/cycles/kernel/osl/nodes/node_add_closure.osl with 100% similarity]
intern/cycles/kernel/shaders/node_attribute.osl [moved from intern/cycles/kernel/osl/nodes/node_attribute.osl with 100% similarity]
intern/cycles/kernel/shaders/node_background.osl [moved from intern/cycles/kernel/osl/nodes/node_background.osl with 100% similarity]
intern/cycles/kernel/shaders/node_brick_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_brick_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_brightness.osl [moved from intern/cycles/kernel/osl/nodes/node_brightness.osl with 100% similarity]
intern/cycles/kernel/shaders/node_bump.osl [moved from intern/cycles/kernel/osl/nodes/node_bump.osl with 100% similarity]
intern/cycles/kernel/shaders/node_camera.osl [moved from intern/cycles/kernel/osl/nodes/node_camera.osl with 100% similarity]
intern/cycles/kernel/shaders/node_checker_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_checker_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_color.h [moved from intern/cycles/kernel/osl/nodes/node_color.h with 100% similarity]
intern/cycles/kernel/shaders/node_combine_rgb.osl [moved from intern/cycles/kernel/osl/nodes/node_combine_rgb.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_color.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_color.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_float.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_float.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_int.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_int.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_normal.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_normal.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_point.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_point.osl with 100% similarity]
intern/cycles/kernel/shaders/node_convert_from_vector.osl [moved from intern/cycles/kernel/osl/nodes/node_convert_from_vector.osl with 100% similarity]
intern/cycles/kernel/shaders/node_diffuse_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_diffuse_bsdf.osl with 100% similarity]
intern/cycles/kernel/shaders/node_emission.osl [moved from intern/cycles/kernel/osl/nodes/node_emission.osl with 100% similarity]
intern/cycles/kernel/shaders/node_environment_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_environment_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_fresnel.h [moved from intern/cycles/kernel/osl/nodes/node_fresnel.h with 100% similarity]
intern/cycles/kernel/shaders/node_fresnel.osl [moved from intern/cycles/kernel/osl/nodes/node_fresnel.osl with 100% similarity]
intern/cycles/kernel/shaders/node_gamma.osl [moved from intern/cycles/kernel/osl/nodes/node_gamma.osl with 100% similarity]
intern/cycles/kernel/shaders/node_geometry.osl [moved from intern/cycles/kernel/osl/nodes/node_geometry.osl with 100% similarity]
intern/cycles/kernel/shaders/node_glass_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl with 91% similarity]
intern/cycles/kernel/shaders/node_glossy_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl with 90% similarity]
intern/cycles/kernel/shaders/node_gradient_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_gradient_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_holdout.osl [moved from intern/cycles/kernel/osl/nodes/node_holdout.osl with 100% similarity]
intern/cycles/kernel/shaders/node_hsv.osl [moved from intern/cycles/kernel/osl/nodes/node_hsv.osl with 100% similarity]
intern/cycles/kernel/shaders/node_image_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_image_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_invert.osl [moved from intern/cycles/kernel/osl/nodes/node_invert.osl with 100% similarity]
intern/cycles/kernel/shaders/node_layer_weight.osl [moved from intern/cycles/kernel/osl/nodes/node_layer_weight.osl with 100% similarity]
intern/cycles/kernel/shaders/node_light_falloff.osl [moved from intern/cycles/kernel/osl/nodes/node_light_falloff.osl with 96% similarity]
intern/cycles/kernel/shaders/node_light_path.osl [moved from intern/cycles/kernel/osl/nodes/node_light_path.osl with 96% similarity]
intern/cycles/kernel/shaders/node_magic_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_magic_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_mapping.osl [moved from intern/cycles/kernel/osl/nodes/node_mapping.osl with 100% similarity]
intern/cycles/kernel/shaders/node_math.osl [moved from intern/cycles/kernel/osl/nodes/node_math.osl with 100% similarity]
intern/cycles/kernel/shaders/node_mix.osl [moved from intern/cycles/kernel/osl/nodes/node_mix.osl with 100% similarity]
intern/cycles/kernel/shaders/node_mix_closure.osl [moved from intern/cycles/kernel/osl/nodes/node_mix_closure.osl with 100% similarity]
intern/cycles/kernel/shaders/node_musgrave_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_musgrave_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_noise_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_noise_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_normal.osl [moved from intern/cycles/kernel/osl/nodes/node_normal.osl with 100% similarity]
intern/cycles/kernel/shaders/node_object_info.osl [moved from intern/cycles/kernel/osl/nodes/node_object_info.osl with 83% similarity]
intern/cycles/kernel/shaders/node_output_displacement.osl [moved from intern/cycles/kernel/osl/nodes/node_output_displacement.osl with 100% similarity]
intern/cycles/kernel/shaders/node_output_surface.osl [moved from intern/cycles/kernel/osl/nodes/node_output_surface.osl with 100% similarity]
intern/cycles/kernel/shaders/node_output_volume.osl [moved from intern/cycles/kernel/osl/nodes/node_output_volume.osl with 100% similarity]
intern/cycles/kernel/shaders/node_particle_info.osl [moved from intern/cycles/kernel/osl/nodes/node_particle_info.osl with 75% similarity]
intern/cycles/kernel/shaders/node_rgb_ramp.osl [moved from intern/cycles/kernel/osl/nodes/node_rgb_ramp.osl with 100% similarity]
intern/cycles/kernel/shaders/node_separate_rgb.osl [moved from intern/cycles/kernel/osl/nodes/node_separate_rgb.osl with 100% similarity]
intern/cycles/kernel/shaders/node_set_normal.osl [moved from intern/cycles/kernel/osl/nodes/node_set_normal.osl with 100% similarity]
intern/cycles/kernel/shaders/node_sky_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_sky_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_texture.h [moved from intern/cycles/kernel/osl/nodes/node_texture.h with 100% similarity]
intern/cycles/kernel/shaders/node_texture_coordinate.osl [moved from intern/cycles/kernel/osl/nodes/node_texture_coordinate.osl with 92% similarity]
intern/cycles/kernel/shaders/node_translucent_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_translucent_bsdf.osl with 100% similarity]
intern/cycles/kernel/shaders/node_transparent_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_transparent_bsdf.osl with 100% similarity]
intern/cycles/kernel/shaders/node_value.osl [moved from intern/cycles/kernel/osl/nodes/node_value.osl with 100% similarity]
intern/cycles/kernel/shaders/node_vector_math.osl [moved from intern/cycles/kernel/osl/nodes/node_vector_math.osl with 100% similarity]
intern/cycles/kernel/shaders/node_velvet_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl with 94% similarity]
intern/cycles/kernel/shaders/node_voronoi_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_voronoi_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/node_ward_bsdf.osl [moved from intern/cycles/kernel/osl/nodes/node_ward_bsdf.osl with 100% similarity]
intern/cycles/kernel/shaders/node_wave_texture.osl [moved from intern/cycles/kernel/osl/nodes/node_wave_texture.osl with 100% similarity]
intern/cycles/kernel/shaders/oslutil.h [moved from intern/cycles/kernel/osl/nodes/oslutil.h with 100% similarity]
intern/cycles/kernel/shaders/stdosl.h [moved from intern/cycles/kernel/osl/nodes/stdosl.h with 78% similarity]
intern/cycles/render/mesh.cpp
intern/cycles/util/util_md5.h
source/creator/CMakeLists.txt

index 259805446479455ff68d85acaa329f18cf21eb54..5cb6f255d1096e6877178d48a73169e519179413 100644 (file)
@@ -658,11 +658,7 @@ if(UNIX AND NOT APPLE)
                        else()
                                set(Boost_USE_MULTITHREADED ON)
                        endif()
-                       if(WITH_CYCLES_OSL)
-                               find_package(Boost 1.34 COMPONENTS filesystem python3 regex system thread) # osl_nodes uses boost_python
-                       else()
-                               find_package(Boost 1.34 COMPONENTS filesystem regex system thread)
-                       endif()
+                       find_package(Boost 1.34 COMPONENTS filesystem regex system thread)
                        mark_as_advanced(Boost_DIR)  # why doesnt boost do this?
                endif()
 
@@ -1137,12 +1133,6 @@ elseif(WIN32)
                                debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
                                debug libboost_regex-${BOOST_DEBUG_POSTFIX}
                                debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
-                               if(WITH_CYCLES_OSL)
-                                       set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
-                                               optimized libboost_python3-${BOOST_POSTFIX}
-                                               debug libboost_python3-${BOOST_DEBUG_POSTFIX})
-                               endif(WITH_CYCLES_OSL)
-                               
                        set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
                endif()
                        
@@ -1323,12 +1313,6 @@ elseif(WIN32)
                                debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
                                boost_regex-${BOOST_DEBUG_POSTFIX}
                                boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
-                               if(WITH_CYCLES_OSL)
-                                       set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
-                                               optimized libboost_python3-${BOOST_POSTFIX}
-                                               debug libboost_python3-${BOOST_DEBUG_POSTFIX}) 
-                               endif(WITH_CYCLES_OSL)
-                                       
                        set(BOOST_LIBPATH ${BOOST}/lib)
                        set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
                endif()
@@ -1583,11 +1567,7 @@ elseif(APPLE)
        if(WITH_BOOST)
                set(BOOST ${LIBDIR}/boost)
                set(BOOST_INCLUDE_DIR ${BOOST}/include)
-               if(WITH_CYCLES_OSL)
-                       set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_python3-mt boost_regex-mt boost_system-mt boost_thread-mt)
-               else(WITH_CYCLES_OSL)
-                       set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
-               endif(WITH_CYCLES_OSL)
+               set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
                set(BOOST_LIBPATH ${BOOST}/lib)
                set(BOOST_DEFINITIONS)
        endif()
index 05b1f88359433f761b919106524e670c5623d873..e4f80cb4d5d12bb8edf6560103c1b0182f2387ee 100644 (file)
@@ -83,3 +83,4 @@ def available_devices():
 def with_osl():
     import _cycles
     return _cycles.with_osl
+
index 6cc3010eb0ebb2b65f926d0df2b4fd693dd8b063..e63e1e84245de72991e54802e109039adfa390aa 100644 (file)
@@ -60,3 +60,4 @@ panorama_types = (
     ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"),
     ('FISHEYE_EQUISOLID', "Fisheye Equisolid", "Similar to most fisheye modern lens, take sensor dimensions into consideration"),
     )
+
index d24c7d4128c2a8486092e8d80caea453e4fd78d7..82b0605ab6b499e77b49a2fb2ea2a57dad541a5a 100644 (file)
@@ -134,6 +134,7 @@ endif()
 
 if(WITH_CYCLES_OSL)
        add_subdirectory(osl)
+       add_subdirectory(shaders)
 endif()
 
 # CPU module
index f671e858481a62151d4e8717cc27eec742039cda..a564b99e759794123177de873a7a64668c343fe6 100644 (file)
@@ -45,13 +45,10 @@ __device_inline float safe_sqrtf(float f)
 __device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
 {
        float ag = sc->data0;
-       float eta = sc->data1;
 
        float m_ag = clamp(ag, 1e-4f, 1.0f);
-       float m_eta = eta;
 
        sc->data0 = m_ag;
-       sc->data1 = m_eta;
        sc->type = CLOSURE_BSDF_MICROFACET_GGX_ID;
 
        return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
@@ -82,7 +79,6 @@ __device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
 __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
 {
        float m_ag = sc->data0;
-       //float m_eta = sc->data1;
        int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
        float3 N = sc->N;
 
@@ -155,7 +151,6 @@ __device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const
 __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
 {
        float m_ag = sc->data0;
-       float m_eta = sc->data1;
        int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
        float3 N = sc->N;
 
@@ -221,6 +216,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
 #ifdef __RAY_DIFFERENTIALS__
                        float3 dRdx, dRdy, dTdx, dTdy;
 #endif
+                       float m_eta = sc->data1;
                        bool inside;
                        fresnel_dielectric(m_eta, m, I, &R, &T,
 #ifdef __RAY_DIFFERENTIALS__
@@ -274,12 +270,9 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
 __device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
 {
        float ab = sc->data0;
-       float eta = sc->data1;
        float m_ab = clamp(ab, 1e-4f, 1.0f);
-       float m_eta = eta;
 
        sc->data0 = m_ab;
-       sc->data1 = m_eta;
 
        sc->type = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
        return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
@@ -309,7 +302,6 @@ __device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
 __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
 {
        float m_ab = sc->data0;
-       //float m_eta = sc->data1;
        int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
        float3 N = sc->N;
 
@@ -386,7 +378,6 @@ __device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc,
 __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
 {
        float m_ab = sc->data0;
-       float m_eta = sc->data1;
        int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
        float3 N = sc->N;
 
@@ -456,6 +447,7 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
 #ifdef __RAY_DIFFERENTIALS__
                        float3 dRdx, dRdy, dTdx, dTdy;
 #endif
+                       float m_eta = sc->data1;
                        bool inside;
                        fresnel_dielectric(m_eta, m, I, &R, &T,
 #ifdef __RAY_DIFFERENTIALS__
index 43cfa3307242d23db7e1b28b04dae28432f49773..e39ae1d4fbcbb6dfeda729acb50a6a755507454f 100644 (file)
@@ -68,6 +68,17 @@ __device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int
 #endif
 }
 
+/* Return 3 triangle vertex locations */
+__device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3])
+{
+       /* load triangle vertices */
+       float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
+
+       P[0] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.x)));
+       P[1] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.y)));
+       P[2] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z)));
+}
+
 __device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v)
 {
        /* load triangle vertices */
index d6449b4349bc0368b0a813a66a8e09bf67ef6c78..8938b16a48ff181f7ccd5ffb8c5c858cef4e23fb 100644 (file)
@@ -34,4 +34,3 @@ include_directories(SYSTEM ${INC_SYS})
 
 add_library(cycles_kernel_osl ${SRC} ${HEADER_SRC})
 
-add_subdirectory(nodes)
index 7c415e22012d2b7507cc17f624f5cb669df3f41c..ade085c795d61bffbe6ef42efd4ca41d04768437 100644 (file)
@@ -345,6 +345,51 @@ static void set_attribute_float(float f[3], TypeDesc type, bool derivatives, voi
        }
 }
 
+static bool set_attribute_int(int i, TypeDesc type, bool derivatives, void *val)
+{
+       if(type.basetype == TypeDesc::INT && type.aggregate == TypeDesc::SCALAR && type.arraylen == 0) {
+               int *ival = (int *)val;
+               ival[0] = i;
+
+               if (derivatives) {
+                       ival[1] = 0;
+                       ival[2] = 0;
+               }
+
+               return true;
+       }
+
+       return false;
+}
+
+static bool set_attribute_float3_3(float3 P[3], TypeDesc type, bool derivatives, void *val)
+{
+       if(type.vecsemantics == TypeDesc::POINT && type.arraylen >= 3) {
+               float *fval = (float *)val;
+
+               fval[0] = P[0].x;
+               fval[1] = P[0].y;
+               fval[2] = P[0].z;
+
+               fval[3] = P[1].x;
+               fval[4] = P[1].y;
+               fval[5] = P[1].z;
+
+               fval[6] = P[2].x;
+               fval[7] = P[2].y;
+               fval[8] = P[2].z;
+
+               if(type.arraylen > 3)
+                       memset(fval + 3*3, 0, sizeof(float)*3*(type.arraylen - 3));
+               if (derivatives)
+                       memset(fval + type.arraylen*3, 0, sizeof(float)*2*3*type.arraylen);
+
+               return true;
+       }
+
+       return false;
+}
+
 static bool get_mesh_attribute(KernelGlobals *kg, const ShaderData *sd, const OSLGlobals::Attribute& attr,
                                const TypeDesc& type, bool derivatives, void *val)
 {
@@ -381,43 +426,45 @@ static void get_object_attribute(const OSLGlobals::Attribute& attr, bool derivat
 static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ustring name,
                                           TypeDesc type, bool derivatives, void *val)
 {
+       /* todo: turn this into hash table + callback once */
+
        /* Object Attributes */
-       if (name == "std::object_location") {
+       if (name == "object:location") {
                float3 fval[3];
                fval[0] = object_location(kg, sd);
                fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
                set_attribute_float3(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::object_index") {
+       else if (name == "object:index") {
                float fval[3];
                fval[0] = object_pass_id(kg, sd->object);
                fval[1] = fval[2] = 0.0;        /* derivates set to 0 */
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::dupli_generated") {
+       else if (name == "geom:dupli_generated") {
                float3 fval[3];
                fval[0] = object_dupli_generated(kg, sd->object);
                fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
                set_attribute_float3(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::dupli_uv") {
+       else if (name == "geom:dupli_uv") {
                float3 fval[3];
                fval[0] = object_dupli_uv(kg, sd->object);
                fval[1] = fval[2] = make_float3(0.0, 0.0, 0.0); /* derivates set to 0 */
                set_attribute_float3(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::material_index") {
+       else if (name == "material:index") {
                float fval[3];
                fval[0] = shader_pass_id(kg, sd);
                fval[1] = fval[2] = 0.0;        /* derivates set to 0 */
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::object_random") {
+       else if (name == "object:random") {
                float fval[3];
                fval[0] = object_random_number(kg, sd->object);
                fval[1] = fval[2] = 0.0;        /* derivates set to 0 */
@@ -426,7 +473,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
        }
 
        /* Particle Attributes */
-       else if (name == "std::particle_index") {
+       else if (name == "particle:index") {
                float fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_index(kg, particle_id);
@@ -434,7 +481,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::particle_age") {
+       else if (name == "particle:age") {
                float fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_age(kg, particle_id);
@@ -442,7 +489,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::particle_lifetime") {
+       else if (name == "particle:lifetime") {
                float fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_lifetime(kg, particle_id);
@@ -450,7 +497,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::particle_location") {
+       else if (name == "particle:location") {
                float3 fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_location(kg, particle_id);
@@ -459,7 +506,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                return true;
        }
 #if 0  /* unsupported */
-       else if (name == "std::particle_rotation") {
+       else if (name == "particle:rotation") {
                float4 fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_rotation(kg, particle_id);
@@ -468,7 +515,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                return true;
        }
 #endif
-       else if (name == "std::particle_size") {
+       else if (name == "particle:size") {
                float fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_size(kg, particle_id);
@@ -476,7 +523,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::particle_velocity") {
+       else if (name == "particle:velocity") {
                float3 fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_velocity(kg, particle_id);
@@ -484,7 +531,7 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float3(fval, type, derivatives, val);
                return true;
        }
-       else if (name == "std::particle_angular_velocity") {
+       else if (name == "particle:angular_velocity") {
                float3 fval[3];
                uint particle_id = object_particle_id(kg, sd->object);
                fval[0] = particle_angular_velocity(kg, particle_id);
@@ -492,7 +539,17 @@ static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ust
                set_attribute_float3(fval, type, derivatives, val);
                return true;
        }
-       
+       else if (name == "geom:numpolyvertices") {
+               return set_attribute_int(3, type, derivatives, val);
+       }
+       else if (name == "geom:trianglevertices" || name == "geom:polyvertices") {
+               float3 P[3];
+               triangle_vertices(kg, sd->prim, P);
+               object_position_transform(kg, sd, &P[0]);
+               object_position_transform(kg, sd, &P[1]);
+               object_position_transform(kg, sd, &P[2]);
+               return set_attribute_float3_3(P, type, derivatives, val);
+       }
        else
                return false;
 }
@@ -501,7 +558,7 @@ static bool get_background_attribute(KernelGlobals *kg, ShaderData *sd, ustring
                                      TypeDesc type, bool derivatives, void *val)
 {
        /* Ray Length */
-       if (name == "std::ray_length") {
+       if (name == "path:ray_length") {
                float fval[3];
                fval[0] = sd->ray_length;
                fval[1] = fval[2] = 0.0;        /* derivates set to 0 */
similarity index 89%
rename from intern/cycles/kernel/osl/nodes/CMakeLists.txt
rename to intern/cycles/kernel/shaders/CMakeLists.txt
index da5441f11e07fac646b16131b16f4a4b55316b99..00ab52a1d133c2205bb5148210769a041daef813 100644 (file)
@@ -76,11 +76,11 @@ set(SRC_OSO
 # TODO, add a module to compile OSL
 foreach(_file ${SRC_OSL})
        set(_OSL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
-       string(REPLACE ".osl" ".oso" _OSO_FILE ${_OSL_FILE})  # TODO, replace extension only
+       string(REPLACE ".osl" ".oso" _OSO_FILE ${_OSL_FILE})
        string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
        add_custom_command(
                OUTPUT ${_OSO_FILE} 
-               COMMAND ${OSL_COMPILER} -O2 ${_OSL_FILE}
+               COMMAND ${OSL_COMPILER} -O2  -I"${CMAKE_CURRENT_SOURCE_DIR}" ${_OSL_FILE}
                DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS})
        list(APPEND SRC_OSO
                ${_OSO_FILE}
@@ -94,3 +94,5 @@ add_custom_target(cycles_osl_shaders ALL DEPENDS ${SRC_OSO} ${SRC_OSL_HEADERS})
 
 # CMAKE_CURRENT_SOURCE_DIR is already included in OSO paths
 delayed_install("" "${SRC_OSO}" ${CYCLES_INSTALL_PATH}/shader)
+delayed_install("${CMAKE_CURRENT_SOURCE_DIR}" "${SRC_OSL_HEADERS}" ${CYCLES_INSTALL_PATH}/shader)
+
similarity index 91%
rename from intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl
rename to intern/cycles/kernel/shaders/node_glass_bsdf.osl
index f3fcce572cfc2f68945865b35eb4dfb100d2c462..30b9d301f3297ae62b2c44f1b33ac44f8e2a5dc1 100644 (file)
@@ -34,10 +34,10 @@ shader node_glass_bsdf(
        if (distribution == "Sharp")
                BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
        else if (distribution == "Beckmann")
-               BSDF = Color * (Fr * microfacet_beckmann(Normal, Roughness, eta) +
+               BSDF = Color * (Fr * microfacet_beckmann(Normal, Roughness) +
                                (1.0 - Fr) * microfacet_beckmann_refraction(Normal, Roughness, eta));
        else if (distribution == "GGX")
-               BSDF = Color * (Fr * microfacet_ggx(Normal, Roughness, eta) +
+               BSDF = Color * (Fr * microfacet_ggx(Normal, Roughness) +
                                (1.0 - Fr) * microfacet_ggx_refraction(Normal, Roughness, eta));
 }
 
similarity index 90%
rename from intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl
rename to intern/cycles/kernel/shaders/node_glossy_bsdf.osl
index 48d61ea0ab59fa80400b823fe9f306742e258640..03340c74af553cfb071864693ff64a7a65036f69 100644 (file)
@@ -29,9 +29,9 @@ shader node_glossy_bsdf(
        if (distribution == "Sharp")
                BSDF = Color * reflection(Normal);
        else if (distribution == "Beckmann")
-               BSDF = Color * microfacet_beckmann(Normal, Roughness, 1.0);
+               BSDF = Color * microfacet_beckmann(Normal, Roughness);
        else if (distribution == "GGX")
-               BSDF = Color * microfacet_ggx(Normal, Roughness, 1.0);
+               BSDF = Color * microfacet_ggx(Normal, Roughness);
 
 }
 
similarity index 96%
rename from intern/cycles/kernel/osl/nodes/node_light_falloff.osl
rename to intern/cycles/kernel/shaders/node_light_falloff.osl
index 3877b6d5bdc2167451685418c44ccbe67f6f1817..7ffa6fe0ffb4273193090e330ea384c76efe4a9b 100644 (file)
@@ -27,7 +27,7 @@ shader node_light_falloff(
 {
        float ray_length = 0.0;
        float strength = Strength;
-       getattribute("std::ray_length", ray_length);
+       getattribute("path:ray_length", ray_length);
 
        if (Smooth > 0.0) {
                float squared = ray_length*ray_length;
similarity index 96%
rename from intern/cycles/kernel/osl/nodes/node_light_path.osl
rename to intern/cycles/kernel/shaders/node_light_path.osl
index ca92a5e6553a76cf6e9c4f4c02510fcb18d5a881..9e3f6c7b4a985c6dd14d41e367c1260046c658f9 100644 (file)
@@ -36,6 +36,6 @@ shader node_light_path(
        IsReflectionRay = raytype("reflection");
        IsTransmissionRay = raytype("refraction");
 
-       getattribute("std::ray_length", RayLength);
+       getattribute("path:ray_length", RayLength);
 }
 
similarity index 83%
rename from intern/cycles/kernel/osl/nodes/node_object_info.osl
rename to intern/cycles/kernel/shaders/node_object_info.osl
index 0d503258179ac769fbb89b80a273396454ad5198..c3b1ff29f097a35860035f39346bdfc2a4b88057 100644 (file)
@@ -24,9 +24,9 @@ shader node_object_info(
        output float MaterialIndex = 0.0,
        output float Random = 0.0)
 {
-       getattribute("std::object_location", Location);
-       getattribute("std::object_index", ObjectIndex);
-       getattribute("std::material_index", MaterialIndex);
-       getattribute("std::object_random", Random);
+       getattribute("object:location", Location);
+       getattribute("object:index", ObjectIndex);
+       getattribute("material:index", MaterialIndex);
+       getattribute("object:random", Random);
 }
 
similarity index 75%
rename from intern/cycles/kernel/osl/nodes/node_particle_info.osl
rename to intern/cycles/kernel/shaders/node_particle_info.osl
index ba51ccbd953c32a0e8979f2d0c331f9724418cfe..5e59ad1a990a65632c58c8d520002ed4047d357d 100644 (file)
@@ -27,12 +27,12 @@ shader node_particle_info(
     output vector Velocity = point(0.0, 0.0, 0.0),
     output vector AngularVelocity = point(0.0, 0.0, 0.0))
 {
-       getattribute("std::particle_index", Index);
-       getattribute("std::particle_age", Age);
-       getattribute("std::particle_lifetime", Lifetime);
-       getattribute("std::particle_location", Location);
-       getattribute("std::particle_size", Size);
-       getattribute("std::particle_velocity", Velocity);
-       getattribute("std::particle_angular_velocity", AngularVelocity);
+       getattribute("particle:index", Index);
+       getattribute("particle:age", Age);
+       getattribute("particle:lifetime", Lifetime);
+       getattribute("particle:location", Location);
+       getattribute("particle:size", Size);
+       getattribute("particle:velocity", Velocity);
+       getattribute("particle:angular_velocity", AngularVelocity);
 }
 
similarity index 92%
rename from intern/cycles/kernel/osl/nodes/node_texture_coordinate.osl
rename to intern/cycles/kernel/shaders/node_texture_coordinate.osl
index 405ed118c2b8b9fe6c572684e2657096e7aaac43..791838dfffec9d8224799f705d95f61478cf08e8 100644 (file)
@@ -44,12 +44,12 @@ shader node_texture_coordinate(
        }
        else {
                if (from_dupli) {
-                       getattribute("std::dupli_generated", Generated); 
-                       getattribute("std::dupli_uv", UV);
+                       getattribute("geom:dupli_generated", Generated); 
+                       getattribute("geom:dupli_uv", UV);
                }
                else {
-                       getattribute("std::generated", Generated); 
-                       getattribute("std::uv", UV);
+                       getattribute("geom:generated", Generated); 
+                       getattribute("geom:uv", UV);
                }
 
                Object = transform("object", P);
similarity index 94%
rename from intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl
rename to intern/cycles/kernel/shaders/node_velvet_bsdf.osl
index 4bb4e39a1ba99235b439a3ff7474cd34edbfd257..3aa662bdd08f8fc238342b34f38d5a1595ca3d37 100644 (file)
@@ -27,6 +27,6 @@ shader node_velvet_bsdf(
 {
        float sigma = clamp(Sigma, 0.0, 1.0);
 
-       BSDF = Color * ashikhmin_velvet(Normal, sigma, 1.0);
+       BSDF = Color * ashikhmin_velvet(Normal, sigma);
 }
 
similarity index 78%
rename from intern/cycles/kernel/osl/nodes/stdosl.h
rename to intern/cycles/kernel/shaders/stdosl.h
index e5accf4eb547d22579e567b80a69bb001275560d..4237291c7a46fa00e91ffcd60c4d207a3f39b0a8 100644 (file)
@@ -434,81 +434,18 @@ string concat (string a, string b, string c, string d, string e, string f) {
 closure color diffuse(normal N) BUILTIN;
 closure color oren_nayar(normal N, float sigma) BUILTIN;
 closure color translucent(normal N) BUILTIN;
-closure color reflection(normal N, float eta) BUILTIN;
-closure color reflection(normal N) { return reflection (N, 0.0); }
+closure color reflection(normal N) BUILTIN;
 closure color refraction(normal N, float eta) BUILTIN;
-closure color dielectric(normal N, float eta) BUILTIN;
 closure color transparent() BUILTIN;
-closure color microfacet_ggx(normal N, float ag, float eta) BUILTIN;
+closure color microfacet_ggx(normal N, float ag) BUILTIN;
 closure color microfacet_ggx_refraction(normal N, float ag, float eta) BUILTIN;
-closure color microfacet_beckmann(normal N, float ab, float eta) BUILTIN;
+closure color microfacet_beckmann(normal N, float ab) BUILTIN;
 closure color microfacet_beckmann_refraction(normal N, float ab, float eta) BUILTIN;
 closure color ward(normal N, vector T,float ax, float ay) BUILTIN;
-closure color phong(normal N, float exponent) BUILTIN;
-closure color phong_ramp(normal N, float exponent, color colors[8]) BUILTIN;
-closure color hair_diffuse(vector T) BUILTIN;
-closure color hair_specular(vector T, float offset, float exponent) BUILTIN;
-closure color ashikhmin_velvet(normal N, float sigma, float eta) BUILTIN;
-closure color westin_backscatter(normal N, float roughness) BUILTIN;
-closure color westin_sheen(normal N, float edginess) BUILTIN;
-closure color bssrdf_cubic(color radius) BUILTIN;
-closure color emission(float inner_angle, float outer_angle) BUILTIN;
-closure color emission(float outer_angle) BUILTIN;
+closure color ashikhmin_velvet(normal N, float sigma) BUILTIN;
 closure color emission() BUILTIN;
-closure color debug(string tag) BUILTIN;
 closure color background() BUILTIN;
 closure color holdout() BUILTIN;
-closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN;
-
-closure color cloth(normal N, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy,
-                    float area_scaled, vector dPdu, color diff_warp_col, color diff_weft_col,
-                    color spec_warp_col, color spec_weft_col, float fresnel_warp, float fresnel_weft,
-                    float spread_x_mult, float spread_y_mult, int pattern, float pattern_angle,
-                    float warp_width_scale, float weft_width_scale, float thread_count_mult_u,
-                    float thread_count_mult_v) BUILTIN;
-closure color cloth_specular(normal N, color spec_col[4], float eta[4], int thread_pattern[4],
-                             float pattern_weight[4], int   current_thread, float brdf_interp,
-                             float btf_interp, float uux, float vvx, float area_scaled, vector dPdu,
-                             float eccentricity[4], float angle[4], float Kx[4], float Ky[4],
-                             float Sx[4], float Sy[4]) BUILTIN;
-closure color fakefur_diffuse(normal N, vector T, float fur_reflectivity, float fur_transmission,
-                              float shadow_start, float shadow_end, float fur_attenuation, float fur_density,
-                              float fur_avg_radius, float fur_length, float fur_shadow_fraction) BUILTIN;
-closure color fakefur_specular(normal N, vector T, float offset, float exp, float fur_reflectivity,
-                               float fur_transmission, float shadow_start, float shadow_end,
-                               float fur_attenuation, float fur_density, float fur_avg_radius,
-                               float fur_length, float fur_shadow_fraction) BUILTIN;
-
-closure color fakefur_skin(vector N, vector T, float fur_reflectivity, float fur_transmission,
-                           float shadow_start, float shadow_end, float fur_attenuation, float fur_density,
-                           float fur_avg_radius, float fur_length) BUILTIN;
-
-
-closure color cloth(normal N, float s, float t, color diff_warp, color diff_weft, 
-                    color spec_warp, color spec_weft, float fresnel_warp, float fresnel_weft,
-                    float spread_x_mult, float spread_y_mult, int pattern, float pattern_angle,
-                    float warp_width_scale, float weft_width_scale, float thread_count_mult_u,
-                    float thread_count_mult_v)
-{
-
-    return cloth(N, s, t, Dx(s), Dx(t), Dy(s), Dy(t), area(P), dPdu, diff_warp, diff_weft, spec_warp, spec_weft,
-                 fresnel_warp, fresnel_weft, spread_x_mult, spread_y_mult, pattern, pattern_angle, 
-                 warp_width_scale, weft_width_scale, thread_count_mult_u, thread_count_mult_v);
-}
-
-closure color cloth(normal N, float s, float t, color diff_warp, color diff_weft, 
-                    color spec_warp, color spec_weft, float fresnel_warp, float fresnel_weft,
-                    float spread_x_mult, float spread_y_mult, int pattern, float pattern_angle,
-                    float warp_width_scale, float weft_width_scale, float thread_count_mult_u,
-                    float thread_count_mult_v, string tok, string val)
-{
-
-    return cloth(N, s, t, Dx(s), Dx(t), Dy(s), Dy(t), area(P), dPdu, diff_warp, diff_weft, spec_warp, spec_weft,
-                 fresnel_warp, fresnel_weft, spread_x_mult, spread_y_mult, pattern, pattern_angle, 
-                 warp_width_scale, weft_width_scale, thread_count_mult_u, thread_count_mult_v, tok, val);
-}
-
-
 
 // Renderer state
 int raytype (string typename) BUILTIN;
index 3c41b4f1ad3865ae5df50bbbdfa2e5a1a59c4693..13c06a922cc13eeb9738d114e59df596960dfbc2 100644 (file)
@@ -366,8 +366,8 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att
                                osl_attr.type = TypeDesc::TypeColor;
 
                        if(req.std != ATTR_STD_NONE) {
-                               /* if standard attribute, add lookup by std:: name convention */
-                               ustring stdname(std::string("std::") + std::string(attribute_standard_name(req.std)));
+                               /* if standard attribute, add lookup by geom: name convention */
+                               ustring stdname(string("geom:") + string(attribute_standard_name(req.std)));
                                og->attribute_map[i][stdname] = osl_attr;
                        }
                        else if(req.name != ustring()) {
index 43e08e64f39fc7d03fef77b6346bd10549ea5a20..aab177d9fe677be8c2fffd4f580173d712bbcf6f 100644 (file)
@@ -44,7 +44,7 @@ public:
        bool append_file(const string& filepath);
        string get_hex();
 
-       protected:
+protected:
        void process(const uint8_t *data);
        void finish(uint8_t digest[16]);
 
index 1d5f762d7061e21aaee363b2a7b083fe6b32209b..c06669c3ac2462e7859a6e6e997f4adca95bcb9b 100644 (file)
@@ -737,14 +737,6 @@ elseif(APPLE)
 
        endif()
        
-       #OSL shader_headers needed
-       if(WITH_CYCLES_OSL)
-               install(
-                       FILES ${LIBDIR}/osl/shaders/oslutil.h ${LIBDIR}/osl/shaders/stdosl.h
-                       DESTINATION ${TARGETDIR}/blender.app/Contents/shaders/
-               )
-       endif()
-       
        # install blenderplayer bundle - copy of blender.app above. re-using macros et al
        # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
        if(WITH_GAMEENGINE AND WITH_PLAYER)