Merged revision(s) 58682-58770 from trunk/blender into soc-2013-dingto.
authorThomas Dinges <blender@dingto.org>
Wed, 31 Jul 2013 18:14:18 +0000 (18:14 +0000)
committerThomas Dinges <blender@dingto.org>
Wed, 31 Jul 2013 18:14:18 +0000 (18:14 +0000)
68 files changed:
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/device/device.h
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_multi.cpp
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/kernel_accumulate.h
intern/cycles/kernel/kernel_displace.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_object.h
intern/cycles/kernel/kernel_passes.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_textures.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/osl/osl_services.cpp
intern/cycles/kernel/osl/osl_services.h
intern/cycles/kernel/shaders/CMakeLists.txt
intern/cycles/kernel/shaders/node_blackbody.osl [new file with mode: 0644]
intern/cycles/kernel/shaders/node_combine_hsv.osl [new file with mode: 0644]
intern/cycles/kernel/shaders/node_light_path.osl
intern/cycles/kernel/shaders/node_separate_hsv.osl [new file with mode: 0644]
intern/cycles/kernel/shaders/node_vector_transform.osl [new file with mode: 0644]
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_blackbody.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_image.h
intern/cycles/kernel/svm/svm_light_path.h
intern/cycles/kernel/svm/svm_sepcomb_hsv.h [new file with mode: 0644]
intern/cycles/kernel/svm/svm_types.h
intern/cycles/kernel/svm/svm_vector_transform.h [new file with mode: 0644]
intern/cycles/render/CMakeLists.txt
intern/cycles/render/blackbody.cpp [new file with mode: 0644]
intern/cycles/render/blackbody.h [new file with mode: 0644]
intern/cycles/render/film.cpp
intern/cycles/render/graph.h
intern/cycles/render/image.cpp
intern/cycles/render/image.h
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
intern/cycles/render/scene.cpp
intern/cycles/render/scene.h
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h
intern/cycles/render/svm.cpp
release/datafiles/splash.png
release/datafiles/startup.blend
release/scripts/startup/nodeitems_builtins.py
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/editors/space_node/drawnode.c
source/blender/gpu/shaders/gpu_shader_material.glsl
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_scene.c
source/blender/nodes/CMakeLists.txt
source/blender/nodes/NOD_shader.h
source/blender/nodes/NOD_static_types.h
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/shader/nodes/node_shader_blackbody.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_light_path.c
source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_vectTransform.c [new file with mode: 0644]
source/blender/render/intern/source/render_result.c

index 1a17675cb71d83084f8318f2c0e689b0ec9399e5..b32b9ef48a4bf0145a8e76bb79627be29a99b0f5 100644 (file)
@@ -67,9 +67,7 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
         row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMOUT").remove_active = True
 
         row = layout.row()
-        sub = row.row()
-        sub.active = (device_type == 'NONE' or cscene.device == 'CPU')
-        sub.prop(cscene, "progressive")
+        row.prop(cscene, "progressive")
         row.prop(cscene, "squared_samples")
         
         split = layout.split()
@@ -80,7 +78,7 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "seed")
         sub.prop(cscene, "sample_clamp")
 
-        if cscene.progressive or (device_type != 'NONE' and cscene.device == 'GPU'):
+        if cscene.progressive:
             col = split.column()
             sub = col.column(align=True)
             sub.label(text="Samples:")
@@ -371,7 +369,13 @@ class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
         row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
         row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
         row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
-
+        col.label(text="Subsurface:")
+        row = col.row(align=True)
+        row.prop(rl, "use_pass_subsurface_direct", text="Direct", toggle=True)
+        row.prop(rl, "use_pass_subsurface_indirect", text="Indirect", toggle=True)
+        row.prop(rl, "use_pass_subsurface_color", text="Color", toggle=True)
+        
+        col.separator()
         col.prop(rl, "use_pass_emit", text="Emission")
         col.prop(rl, "use_pass_environment")
         col.prop(rl, "use_pass_ambient_occlusion")
@@ -648,7 +652,6 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
         lamp = context.lamp
         clamp = lamp.cycles
         cscene = context.scene.cycles
-        device_type = context.user_preferences.system.compute_device_type
 
         layout.prop(lamp, "type", expand=True)
 
@@ -667,7 +670,7 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
                 sub.prop(lamp, "size", text="Size X")
                 sub.prop(lamp, "size_y", text="Size Y")
 
-        if not cscene.progressive and (device_type == 'NONE' or cscene.device == 'CPU'):
+        if not cscene.progressive:
             col.prop(clamp, "samples")
 
         col = split.column()
@@ -856,7 +859,6 @@ class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
         world = context.world
         cworld = world.cycles
         cscene = context.scene.cycles
-        device_type = context.user_preferences.system.compute_device_type
 
         col = layout.column()
 
@@ -864,7 +866,7 @@ class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
         sub = col.row(align=True)
         sub.active = cworld.sample_as_light
         sub.prop(cworld, "sample_map_resolution")
-        if not cscene.progressive and (device_type == 'NONE' or cscene.device == 'CPU'):
+        if not cscene.progressive:
             sub.prop(cworld, "samples")
 
 
index 3a46897fcac673284c71289aac12a7fd602cf205..fb743acf29af3c34643b532418a5c65dfdf9af2e 100644 (file)
@@ -216,6 +216,8 @@ static PassType get_pass_type(BL::RenderPass b_pass)
                        return PASS_GLOSSY_DIRECT;
                case BL::RenderPass::type_TRANSMISSION_DIRECT:
                        return PASS_TRANSMISSION_DIRECT;
+               case BL::RenderPass::type_SUBSURFACE_DIRECT:
+                       return PASS_SUBSURFACE_DIRECT;
 
                case BL::RenderPass::type_DIFFUSE_INDIRECT:
                        return PASS_DIFFUSE_INDIRECT;
@@ -223,6 +225,8 @@ static PassType get_pass_type(BL::RenderPass b_pass)
                        return PASS_GLOSSY_INDIRECT;
                case BL::RenderPass::type_TRANSMISSION_INDIRECT:
                        return PASS_TRANSMISSION_INDIRECT;
+               case BL::RenderPass::type_SUBSURFACE_INDIRECT:
+                       return PASS_SUBSURFACE_INDIRECT;
 
                case BL::RenderPass::type_DIFFUSE_COLOR:
                        return PASS_DIFFUSE_COLOR;
@@ -230,6 +234,8 @@ static PassType get_pass_type(BL::RenderPass b_pass)
                        return PASS_GLOSSY_COLOR;
                case BL::RenderPass::type_TRANSMISSION_COLOR:
                        return PASS_TRANSMISSION_COLOR;
+               case BL::RenderPass::type_SUBSURFACE_COLOR:
+                       return PASS_SUBSURFACE_COLOR;
 
                case BL::RenderPass::type_EMIT:
                        return PASS_EMISSION;
index 923f9b1e726d2ed3a029f815fcac6ca7fbd4eef9..d0b83d9e55379e50f40406b8adb1669b2c694d8d 100644 (file)
@@ -231,6 +231,12 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
        else if (b_node.is_a(&RNA_ShaderNodeCombineRGB)) {
                node = new CombineRGBNode();
        }
+       else if (b_node.is_a(&RNA_ShaderNodeSeparateHSV)) {
+               node = new SeparateHSVNode();
+       }
+       else if (b_node.is_a(&RNA_ShaderNodeCombineHSV)) {
+               node = new CombineHSVNode();
+       }
        else if (b_node.is_a(&RNA_ShaderNodeHueSaturation)) {
                node = new HSVNode();
        }
@@ -250,6 +256,14 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
                vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
                node = vmath;
        }
+       else if (b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
+               BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
+               VectorTransformNode *vtransform = new VectorTransformNode();
+               vtransform->type = VectorTransformNode::type_enum[b_vector_transform_node.type()];
+               vtransform->convert_from = VectorTransformNode::convert_from_enum[b_vector_transform_node.convert_from()];
+               vtransform->convert_to = VectorTransformNode::convert_to_enum[b_vector_transform_node.convert_to()];
+               node = vtransform;
+       }
        else if (b_node.is_a(&RNA_ShaderNodeNormal)) {
                BL::Node::outputs_iterator out_it;
                b_node.outputs.begin(out_it);
@@ -400,6 +414,9 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
        else if (b_node.is_a(&RNA_ShaderNodeWavelength)) {
                node = new WavelengthNode();
        }
+       else if (b_node.is_a(&RNA_ShaderNodeBlackbody)) {
+               node = new BlackbodyNode();
+       }
        else if (b_node.is_a(&RNA_ShaderNodeLightPath)) {
                node = new LightPathNode();
        }
index 11e2be5e0fb0cd483f8e7d6540d86297a4979fcc..86a95e337efb960df789c3d6689537963337b131 100644 (file)
@@ -421,7 +421,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use
                preview_aa_samples = preview_aa_samples * preview_aa_samples;
        }
 
-       if(get_boolean(cscene, "progressive") == 0 && params.device.type == DEVICE_CPU) {
+       if(get_boolean(cscene, "progressive") == 0) {
                if(background) {
                        params.samples = aa_samples;
                }
index 7b31b9ba157e366af934de0c63a0a904d19d7c0f..e6d3922d3be53b21298ed7100fe3b4971b8d215b 100644 (file)
@@ -53,6 +53,7 @@ public:
        string description;
        string id;
        int num;
+       int extended_images;
        bool display_device;
        bool advanced_shading;
        bool pack_images;
@@ -63,6 +64,7 @@ public:
                type = DEVICE_CPU;
                id = "CPU";
                num = 0;
+               extended_images = false;
                display_device = false;
                advanced_shading = true;
                pack_images = false;
index 7bc84878dab6511df007fd1b5c6bc5fd0d1d48ae..f2743e15e2b7f364eedb13b92306aeb3bb78091f 100644 (file)
@@ -339,6 +339,7 @@ void device_cpu_info(vector<DeviceInfo>& devices)
        info.description = system_cpu_brand_string();
        info.id = "CPU";
        info.num = 0;
+       info.extended_images = true;
        info.advanced_shading = true;
        info.pack_images = false;
 
index 4441ff1c69fe708b0adbb257cc0223f34685bdfa..65dd001f70f6885b6492c18ae76cbfb678084d25 100644 (file)
@@ -1021,6 +1021,7 @@ void device_cuda_info(vector<DeviceInfo>& devices)
                int major, minor;
                cuDeviceComputeCapability(&major, &minor, num);
                info.advanced_shading = (major >= 2);
+               info.extended_images = (major >= 3);
                info.pack_images = false;
 
                /* if device has a kernel timeout, assume it is used for display */
index 807bfe578f30b2fe6b3ec69554db8590433da491..02db5b8483186453f39f60410a6123afbe0bc8d9 100644 (file)
@@ -330,6 +330,7 @@ static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool
 
        info.advanced_shading = with_advanced_shading;
        info.pack_images = false;
+       info.extended_images = true;
 
        foreach(DeviceInfo& subinfo, devices) {
                if(subinfo.type == type) {
@@ -353,6 +354,7 @@ static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool
                        if(subinfo.display_device)
                                info.display_device = true;
                        info.pack_images = info.pack_images || subinfo.pack_images;
+                       info.extended_images = info.extended_images && subinfo.extended_images;
                        num_added++;
                }
        }
index 2fa1393e935581494784f92f97ac879882150047..963ec65278499e280686f5f9759b8802a07ec5a6 100644 (file)
@@ -72,6 +72,7 @@ set(SRC_CLOSURE_HEADERS
 set(SRC_SVM_HEADERS
        svm/svm.h
        svm/svm_attribute.h
+       svm/svm_blackbody.h
        svm/svm_camera.h
        svm/svm_closure.h
        svm/svm_convert.h
@@ -99,11 +100,13 @@ set(SRC_SVM_HEADERS
        svm/svm_normal.h
        svm/svm_ramp.h
        svm/svm_sepcomb_rgb.h
+       svm/svm_sepcomb_hsv.h
        svm/svm_sky.h
        svm/svm_tex_coord.h
        svm/svm_texture.h
        svm/svm_types.h
        svm/svm_value.h
+       svm/svm_vector_transform.h
        svm/svm_voronoi.h
        svm/svm_wave.h
 )
index e6307f23b32f2e5f0cb828dd921246ba86809f93..9e26aa6fa2b74e7cefd26049b22dcbeda8863af0 100644 (file)
@@ -124,14 +124,17 @@ __device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
                L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                L->color_glossy = make_float3(0.0f, 0.0f, 0.0f);
                L->color_transmission = make_float3(0.0f, 0.0f, 0.0f);
+               L->color_subsurface = make_float3(0.0f, 0.0f, 0.0f);
 
                L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
                L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
+               L->direct_subsurface = make_float3(0.0f, 0.0f, 0.0f);
 
                L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
                L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
+               L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
 
                L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
@@ -337,10 +340,12 @@ __device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float c
                        L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                        L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
                        L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
+                       L->direct_subsurface = make_float3(0.0f, 0.0f, 0.0f);
 
                        L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
                        L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
                        L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
+                       L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
 
                        L->emission = make_float3(0.0f, 0.0f, 0.0f);
                }
@@ -357,10 +362,12 @@ __device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float c
                        L->direct_diffuse *= scale;
                        L->direct_glossy *= scale;
                        L->direct_transmission *= scale;
+                       L->direct_subsurface *= scale;
 
                        L->indirect_diffuse *= scale;
                        L->indirect_glossy *= scale;
                        L->indirect_transmission *= scale;
+                       L->indirect_subsurface *= scale;
 
                        L->emission *= scale;
                }
index ae2e35e8d93be2d1e75dd3d06844576578455866..b4ece1610beee096528a887d8feb6f7fa4e95f29 100644 (file)
@@ -57,7 +57,7 @@ __device void kernel_shader_evaluate(KernelGlobals *kg, __global uint4 *input, _
 #endif
 
                /* setup shader data */
-               shader_setup_from_background(kg, &sd, &ray);
+               shader_setup_from_background(kg, &sd, &ray, 0);
 
                /* evaluate */
                int flag = 0; /* we can't know which type of BSDF this is for */
index 77dc59d2691fe4fed592e19141fe4007ad35f043..dab5b68a159ea7396b963a08487d9d0097933e40 100644 (file)
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
 /* Direction Emission */
 
 __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
-       LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time)
+       LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time, int bounce)
 {
        /* setup shading at emitter */
        ShaderData sd;
@@ -41,7 +41,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
 #ifdef __CAMERA_MOTION__
                ray.time = time;
 #endif
-               shader_setup_from_background(kg, &sd, &ray);
+               shader_setup_from_background(kg, &sd, &ray, bounce);
                eval = shader_eval_background(kg, &sd, 0, SHADER_CONTEXT_EMISSION);
        }
        else
@@ -49,10 +49,10 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
        {
 #ifdef __HAIR__
                if(ls->type == LIGHT_STRAND)
-                       shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v, t, time, ls->prim);
+                       shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v, t, time, bounce, ls->prim);
                else
 #endif
-                       shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v, t, time, ~0);
+                       shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v, t, time, bounce, ~0);
 
                ls->Ng = sd.Ng;
 
@@ -74,7 +74,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
 
 __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
        float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
-       bool *is_lamp)
+       bool *is_lamp, int bounce)
 {
        LightSample ls;
 
@@ -97,7 +97,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
        differential3 dD = differential3_zero();
 
        /* evaluate closure */
-       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D, dD, ls.t, sd->time);
+       float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D, dD, ls.t, sd->time, bounce);
 
        if(is_zero(light_eval))
                return false;
@@ -185,7 +185,7 @@ __device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderDa
 
 /* Indirect Lamp Emission */
 
-__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission)
+__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
 {
        LightSample ls;
        int lamp = lamp_light_eval_sample(kg, randt);
@@ -209,7 +209,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
        /* todo: missing texture coordinates */
        float u = 0.0f;
        float v = 0.0f;
-       float3 L = direct_emissive_eval(kg, 0.0f, &ls, u, v, -ray->D, ray->dD, ls.t, ray->time);
+       float3 L = direct_emissive_eval(kg, 0.0f, &ls, u, v, -ray->D, ray->dD, ls.t, ray->time, bounce);
 
        if(!(path_flag & PATH_RAY_MIS_SKIP)) {
                /* multiple importance sampling, get regular light pdf,
@@ -224,7 +224,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
 
 /* Indirect Background */
 
-__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf)
+__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
 {
 #ifdef __BACKGROUND__
        int shader = kernel_data.background.shader;
@@ -240,7 +240,7 @@ __device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int pa
 
        /* evaluate background closure */
        ShaderData sd;
-       shader_setup_from_background(kg, &sd, ray);
+       shader_setup_from_background(kg, &sd, ray, bounce);
 
        float3 L = shader_eval_background(kg, &sd, path_flag, SHADER_CONTEXT_EMISSION);
 
index bb5ed50c995e567a7d4834e1e785d455cc30923c..3cd7738f6b849c93a3701e20ef88b4afdda90d41 100644 (file)
@@ -154,6 +154,16 @@ __device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, flo
 #endif
 }
 
+__device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
+{
+#ifdef __OBJECT_MOTION__
+       *D = transform_direction(&sd->ob_itfm, *D);
+#else
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
+       *D = transform_direction(&tfm, *D);
+#endif
+}
+
 __device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
 {
        if(sd->object == ~0)
index f07e1b1fc649261dba7e7f7ac5bbabba65843817..0b45e2432831ea52a8921f4af6d45852cba1a3d1 100644 (file)
@@ -86,6 +86,8 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float
                L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput;
        if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT))
                L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput;
+       if(flag & (PASS_SUBSURFACE_INDIRECT|PASS_SUBSURFACE_COLOR|PASS_SUBSURFACE_DIRECT))
+               L->color_subsurface += shader_bsdf_subsurface(kg, sd)*throughput;
 
        if(flag & PASS_MIST) {
                /* bring depth into 0..1 range */
@@ -128,12 +130,16 @@ __device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float
                kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, L->indirect_glossy);
        if(flag & PASS_TRANSMISSION_INDIRECT)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, L->indirect_transmission);
+       if(flag & PASS_SUBSURFACE_INDIRECT)
+               kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, sample, L->indirect_subsurface);
        if(flag & PASS_DIFFUSE_DIRECT)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, L->direct_diffuse);
        if(flag & PASS_GLOSSY_DIRECT)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, L->direct_glossy);
        if(flag & PASS_TRANSMISSION_DIRECT)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, L->direct_transmission);
+       if(flag & PASS_SUBSURFACE_DIRECT)
+               kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, sample, L->direct_subsurface);
 
        if(flag & PASS_EMISSION)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission);
@@ -148,6 +154,8 @@ __device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float
                kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy);
        if(flag & PASS_TRANSMISSION_COLOR)
                kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission);
+       if(flag & PASS_SUBSURFACE_COLOR)
+               kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, sample, L->color_subsurface);
        if(flag & PASS_SHADOW) {
                float4 shadow = L->shadow;
                shadow.w = kernel_data.film.pass_shadow_scale;
index 0ef255786fa66c534e39ae0258b8dab68abc5701..7d0b9a0afb810e47cc6e915cbd21069a55132e4a 100644 (file)
@@ -215,7 +215,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
                                        return true;
 
                                ShaderData sd;
-                               shader_setup_from_ray(kg, &sd, &isect, ray);
+                               shader_setup_from_ray(kg, &sd, &isect, ray, state->bounce);
                                shader_eval_surface(kg, &sd, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
 
                                throughput *= shader_bsdf_transparency(kg, &sd);
@@ -300,7 +300,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                        float light_t = path_rng_1D(kg, rng, sample, num_samples, rng_offset + PRNG_LIGHT);
                        float3 emission;
 
-                       if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission))
+                       if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission, state.bounce))
                                path_radiance_accum_emission(&L, throughput, emission, state.bounce);
                }
 #endif
@@ -318,7 +318,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
 
 #ifdef __BACKGROUND__
                        /* sample background shader */
-                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf);
+                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf, state.bounce);
                        path_radiance_accum_background(&L, throughput, L_background, state.bounce);
 #endif
 
@@ -327,7 +327,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
 
                /* setup shading */
                ShaderData sd;
-               shader_setup_from_ray(kg, &sd, &isect, &ray);
+               shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
                float rbsdf = path_rng_1D(kg, rng, sample, num_samples, rng_offset + PRNG_BSDF);
                shader_eval_surface(kg, &sd, rbsdf, state.flag, SHADER_CONTEXT_MAIN);
 
@@ -464,7 +464,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                                light_ray.time = sd.time;
 #endif
 
-                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
+                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
@@ -575,7 +575,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                        float light_t = path_rng_1D(kg, rng, sample, num_total_samples, rng_offset + PRNG_LIGHT);
                        float3 emission;
 
-                       if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission))
+                       if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission, state.bounce))
                                path_radiance_accum_emission(L, throughput, emission, state.bounce);
                }
 #endif
@@ -583,7 +583,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                if(!hit) {
 #ifdef __BACKGROUND__
                        /* sample background shader */
-                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf);
+                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf, state.bounce);
                        path_radiance_accum_background(L, throughput, L_background, state.bounce);
 #endif
 
@@ -592,7 +592,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
 
                /* setup shading */
                ShaderData sd;
-               shader_setup_from_ray(kg, &sd, &isect, &ray);
+               shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
                float rbsdf = path_rng_1D(kg, rng, sample, num_total_samples, rng_offset + PRNG_BSDF);
                shader_eval_surface(kg, &sd, rbsdf, state.flag, SHADER_CONTEXT_INDIRECT);
                shader_merge_closures(kg, &sd);
@@ -706,7 +706,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
 #endif
 
                                /* sample random light */
-                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
+                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
@@ -838,7 +838,7 @@ __device_noinline void kernel_path_non_progressive_lighting(KernelGlobals *kg, R
                                float light_u, light_v;
                                path_rng_2D(kg, &lamp_rng, sample*num_samples + j, aa_samples*num_samples, rng_offset + PRNG_LIGHT_U, &light_u, &light_v);
 
-                               if(direct_emission(kg, sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
+                               if(direct_emission(kg, sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
@@ -867,7 +867,7 @@ __device_noinline void kernel_path_non_progressive_lighting(KernelGlobals *kg, R
                                if(kernel_data.integrator.num_all_lights)
                                        light_t = 0.5f*light_t;
 
-                               if(direct_emission(kg, sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
+                               if(direct_emission(kg, sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
@@ -1013,7 +1013,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
 
 #ifdef __BACKGROUND__
                        /* sample background shader */
-                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf);
+                       float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf, state.bounce);
                        path_radiance_accum_background(&L, throughput, L_background, state.bounce);
 #endif
 
@@ -1022,7 +1022,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
 
                /* setup shading */
                ShaderData sd;
-               shader_setup_from_ray(kg, &sd, &isect, &ray);
+               shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce);
                shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
                shader_merge_closures(kg, &sd);
 
index 039981a031a4c0ecf4fcbd94d9d450ee23b756c1..333c116070d40e7e02b8846c638e986bc24e6915 100644 (file)
@@ -64,7 +64,7 @@ __device_noinline
 __device
 #endif
 void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
-       const Intersection *isect, const Ray *ray)
+       const Intersection *isect, const Ray *ray, int bounce)
 {
 #ifdef __INSTANCING__
        sd->object = (isect->object == ~0)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
@@ -80,6 +80,7 @@ void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
 
        sd->prim = kernel_tex_fetch(__prim_index, isect->prim);
        sd->ray_length = isect->t;
+       sd->ray_depth = (float)bounce;
 
 #ifdef __HAIR__
        if(kernel_tex_fetch(__prim_segment, isect->prim) != ~0) {
@@ -277,7 +278,7 @@ __device
 #endif
 void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
        const float3 P, const float3 Ng, const float3 I,
-       int shader, int object, int prim, float u, float v, float t, float time, int segment)
+       int shader, int object, int prim, float u, float v, float t, float time, int bounce, int segment)
 {
        /* vectors */
        sd->P = P;
@@ -300,6 +301,7 @@ void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
        sd->v = v;
 #endif
        sd->ray_length = t;
+       sd->ray_depth = (float)bounce;
 
        /* detect instancing, for non-instanced the object index is -object-1 */
 #ifdef __INSTANCING__
@@ -408,12 +410,12 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
 
        /* watch out: no instance transform currently */
 
-       shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID, ~0);
+       shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID, 0, ~0);
 }
 
 /* ShaderData setup from ray into background */
 
-__device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray)
+__device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
 {
        /* vectors */
        sd->P = ray->D;
@@ -426,6 +428,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
        sd->time = ray->time;
 #endif
        sd->ray_length = 0.0f;
+       sd->ray_depth = (float)bounce;
 
 #ifdef __INSTANCING__
        sd->object = ~0;
@@ -682,6 +685,27 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
 #endif
 }
 
+__device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
+{
+#ifdef __MULTI_CLOSURE__
+       float3 eval = make_float3(0.0f, 0.0f, 0.0f);
+
+       for(int i = 0; i< sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
+
+               if(CLOSURE_IS_BSSRDF(sc->type))
+                       eval += sc->weight;
+       }
+
+       return eval;
+#else
+       if(CLOSURE_IS_BSSRDF(sd->closure.type))
+               return sd->closure.weight;
+       else
+               return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
 __device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N)
 {
 #ifdef __MULTI_CLOSURE__
@@ -931,8 +955,15 @@ __device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
                                sci->sample_weight += scj->sample_weight;
 
                                int size = sd->num_closure - (j+1);
-                               if(size > 0)
+                               if(size > 0) {
+#ifdef __KERNEL_GPU__
+                                       for(int k = 0; k < size; k++) {
+                                               scj[k] = scj[k+1];
+                                       }
+#else
                                        memmove(scj, scj+1, size*sizeof(ShaderClosure));
+#endif
+                               }
 
                                sd->num_closure--;
                                j--;
index 55c6e15ad04b20d0dc9631037c9b62c692c6522d..f09bb95046bc37177d4e3e856f2cc7ed535a4951 100644 (file)
@@ -176,6 +176,61 @@ KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_097)
 KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_098)
 KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_099)
 
+/* Kepler and above */
+#if defined(__KERNEL_CUDA__) && __CUDA_ARCH__ >= 300
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_100)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_101)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_102)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_103)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_104)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_105)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_106)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_107)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_108)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_109)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_110)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_111)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_112)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_113)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_114)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_115)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_116)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_117)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_118)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_119)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_120)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_121)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_122)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_123)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_124)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_125)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_126)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_127)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_128)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_129)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_130)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_131)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_132)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_133)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_134)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_135)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_136)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_137)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_138)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_139)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_140)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_141)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_142)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_143)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_144)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_145)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_146)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_147)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_148)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_149)
+KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_150)
+#endif
+
 /* packed image (opencl) */
 KERNEL_TEX(uchar4, texture_uchar4, __tex_image_packed)
 KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info)
index 38ababa96bdbb4c5e45f67ab99c1722e21dad188..c6a7e1a9c2fb8a2cff37f0e50c8d800e998524c7 100644 (file)
@@ -44,6 +44,12 @@ CCL_NAMESPACE_BEGIN
 #define BSSRDF_MIN_RADIUS                      1e-8f
 #define BSSRDF_MAX_ATTEMPTS                    8
 
+#define BB_DRAPPER 800.0
+#define BB_MAX_TABLE_RANGE 12000.0
+#define BB_TABLE_XPOWER 1.5
+#define BB_TABLE_YPOWER 5.0
+#define BB_TABLE_SPACING 2.0
+
 #define TEX_NUM_FLOAT_IMAGES   5
 
 /* device capabilities */
@@ -62,6 +68,7 @@ CCL_NAMESPACE_BEGIN
 #define __KERNEL_SHADING__
 #if __CUDA_ARCH__ >= 200
 #define __KERNEL_ADV_SHADING__
+#define __NON_PROGRESSIVE__
 #endif
 #endif
 
@@ -262,7 +269,10 @@ typedef enum PassType {
        PASS_SHADOW = 262144,
        PASS_MOTION = 524288,
        PASS_MOTION_WEIGHT = 1048576,
-       PASS_MIST = 2097152
+       PASS_MIST = 2097152,
+       PASS_SUBSURFACE_DIRECT = 4194304,
+       PASS_SUBSURFACE_INDIRECT = 8388608,
+       PASS_SUBSURFACE_COLOR = 16777216
 } PassType;
 
 #define PASS_ALL (~0)
@@ -285,14 +295,17 @@ typedef struct PathRadiance {
        float3 color_diffuse;
        float3 color_glossy;
        float3 color_transmission;
+       float3 color_subsurface;
 
        float3 direct_diffuse;
        float3 direct_glossy;
        float3 direct_transmission;
+       float3 direct_subsurface;
 
        float3 indirect_diffuse;
        float3 indirect_glossy;
        float3 indirect_transmission;
+       float3 indirect_subsurface;
 
        float3 path_diffuse;
        float3 path_glossy;
@@ -540,6 +553,9 @@ typedef struct ShaderData {
        
        /* length of the ray being shaded */
        float ray_length;
+       
+       /* ray bounce depth */
+       float ray_depth;
 
 #ifdef __RAY_DIFFERENTIALS__
        /* differential of P. these are orthogonal to Ng, not N */
@@ -663,22 +679,27 @@ typedef struct KernelFilm {
        int pass_diffuse_color;
        int pass_glossy_color;
        int pass_transmission_color;
+       int pass_subsurface_color;
+       
        int pass_diffuse_indirect;
-
        int pass_glossy_indirect;
        int pass_transmission_indirect;
+       int pass_subsurface_indirect;
+       
        int pass_diffuse_direct;
        int pass_glossy_direct;
-
        int pass_transmission_direct;
+       int pass_subsurface_direct;
+       
        int pass_emission;
        int pass_background;
        int pass_ao;
+       int pass_pad1;
 
        int pass_shadow;
        float pass_shadow_scale;
        int filter_table_offset;
-       int pass_pad1;
+       int pass_pad2;
 
        int pass_mist;
        float mist_start;
@@ -807,6 +828,12 @@ typedef struct KernelBSSRDF {
        int pad1, pad2;
 } KernelBSSRDF;
 
+typedef struct KernelBLACKBODY {
+       int table_offset;
+       int pad1, pad2, pad3;
+} KernelBLACKBODY;
+
+
 typedef struct KernelData {
        KernelCamera cam;
        KernelFilm film;
@@ -816,6 +843,7 @@ typedef struct KernelData {
        KernelBVH bvh;
        KernelCurves curve_kernel_data;
        KernelBSSRDF bssrdf;
+       KernelBLACKBODY blackbody;
 } KernelData;
 
 CCL_NAMESPACE_END
index e1e43b117e71e623e7e28a30f85cfb9dbd04c6a0..5ec9c6460791ffb548b0b64dfc7e338aa47713da 100644 (file)
@@ -84,6 +84,7 @@ ustring OSLRenderServices::u_curve_thickness("geom:curve_thickness");
 ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
 #endif
 ustring OSLRenderServices::u_path_ray_length("path:ray_length");
+ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
 ustring OSLRenderServices::u_trace("trace");
 ustring OSLRenderServices::u_hit("hit");
 ustring OSLRenderServices::u_hitdist("hitdist");
@@ -660,6 +661,11 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
                float f = sd->ray_length;
                return set_attribute_float(f, type, derivatives, val);
        }
+       else if (name == u_path_ray_depth) {
+               /* Ray Length */
+               float f = sd->ray_depth;
+               return set_attribute_float(f, type, derivatives, val);
+       }
        else if (name == u_ndc) {
                /* NDC coordinates with special exception for otho */
                OSLThreadData *tdata = kg->osl_tdata;
@@ -919,7 +925,7 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustri
 
                                if(!tracedata->setup) {
                                        /* lazy shader data setup */
-                                       shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray);
+                                       shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, -1);
                                        tracedata->setup = true;
                                }
 
index ca18c85a1671c742876acb9b27410e328afed4e2..5ec4673ef3799850a53f972b484e111fa665b909 100644 (file)
@@ -135,6 +135,7 @@ public:
        static ustring u_curve_thickness;
        static ustring u_curve_tangent_normal;
        static ustring u_path_ray_length;
+       static ustring u_path_ray_depth;
        static ustring u_trace;
        static ustring u_hit;
        static ustring u_hitdist;
index 23112f565369366ca9c02ad59224fed37e88fd58..660cfbce528e28036c1b907e5dc8b50861094595 100644 (file)
@@ -12,6 +12,7 @@ set(SRC_OSL
        node_camera.osl
        node_checker_texture.osl
        node_combine_rgb.osl
+       node_combine_hsv.osl
        node_convert_from_color.osl
        node_convert_from_float.osl
        node_convert_from_int.osl
@@ -53,6 +54,7 @@ set(SRC_OSL
        node_rgb_curves.osl
        node_rgb_ramp.osl
        node_separate_rgb.osl
+       node_separate_hsv.osl
        node_set_normal.osl
        node_sky_texture.osl
        node_subsurface_scattering.osl
@@ -64,10 +66,12 @@ set(SRC_OSL
        node_value.osl
        node_vector_curves.osl
        node_vector_math.osl
+       node_vector_transform.osl
        node_velvet_bsdf.osl
        node_voronoi_texture.osl
        node_ward_bsdf.osl
        node_wavelength.osl
+       node_blackbody.osl
        node_wave_texture.osl
        node_wireframe.osl
 )
diff --git a/intern/cycles/kernel/shaders/node_blackbody.osl b/intern/cycles/kernel/shaders/node_blackbody.osl
new file mode 100644 (file)
index 0000000..4a68eb9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_blackbody(
+       float Temperature = 1200.0,
+       output color Color = 0.0)
+{
+       color rgb = blackbody(Temperature);
+       
+       /* Scale by luminance */
+       float l = luminance(rgb);
+       Color = rgb /= l;
+}
+
diff --git a/intern/cycles/kernel/shaders/node_combine_hsv.osl b/intern/cycles/kernel/shaders/node_combine_hsv.osl
new file mode 100644 (file)
index 0000000..a5c889e
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_combine_hsv(
+       float H = 0.0,
+       float S = 0.0,
+       float V = 0.0,
+       output color Color = 0.8)
+{
+       Color = color("hsv", H, S, V);  
+}
+
index 9e3f6c7b4a985c6dd14d41e367c1260046c658f9..a2f3110eedeb4a60b215a4a76e1c7feb4c22df07 100644 (file)
@@ -26,7 +26,8 @@ shader node_light_path(
        output float IsSingularRay = 0.0,
        output float IsReflectionRay = 0.0,
        output float IsTransmissionRay = 0.0,
-       output float RayLength = 0.0)
+       output float RayLength = 0.0,
+       output float RayDepth = 0.0)
 {
        IsCameraRay = raytype("camera");
        IsShadowRay = raytype("shadow");
@@ -37,5 +38,6 @@ shader node_light_path(
        IsTransmissionRay = raytype("refraction");
 
        getattribute("path:ray_length", RayLength);
+       getattribute("path:ray_depth", RayDepth);
 }
 
diff --git a/intern/cycles/kernel/shaders/node_separate_hsv.osl b/intern/cycles/kernel/shaders/node_separate_hsv.osl
new file mode 100644 (file)
index 0000000..0f074bf
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+#include "node_color.h"
+
+shader node_separate_hsv(
+       color Color = 0.8,
+       output float H = 0.0,
+       output float S = 0.0,
+       output float V = 0.0)
+{
+       color col = rgb_to_hsv(Color);
+       
+       H = col[0];
+       S = col[1];
+       V = col[2];
+}
diff --git a/intern/cycles/kernel/shaders/node_vector_transform.osl b/intern/cycles/kernel/shaders/node_vector_transform.osl
new file mode 100644 (file)
index 0000000..746aab9
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "stdosl.h"
+
+shader node_vector_transform(
+       string type = "Vector",
+       string convert_from = "World",
+       string convert_to = "Object",
+       vector VectorIn = vector(0.0, 0.0, 0.0),
+       output vector VectorOut = vector(0.0, 0.0, 0.0))
+{
+       if (type == "Vector") {
+               VectorOut = transform(convert_from, convert_to, VectorIn);
+       }
+       else if (type == "Point") {
+               point Point = point(VectorIn[0], VectorIn[1], VectorIn[2]);
+               VectorOut = transform(convert_from, convert_to, Point);
+       }
+}
+
index e5df880b5967f6ed0e7610f14b7b51f04dac3e4c..5380bdad1aef4fac3e9d65138f997ddfdfb590b8 100644 (file)
@@ -146,6 +146,7 @@ CCL_NAMESPACE_END
 
 #include "svm_attribute.h"
 #include "svm_gradient.h"
+#include "svm_blackbody.h"
 #include "svm_closure.h"
 #include "svm_noisetex.h"
 #include "svm_convert.h"
@@ -169,6 +170,7 @@ CCL_NAMESPACE_END
 #include "svm_mix.h"
 #include "svm_ramp.h"
 #include "svm_sepcomb_rgb.h"
+#include "svm_sepcomb_hsv.h"
 #include "svm_musgrave.h"
 #include "svm_sky.h"
 #include "svm_tex_coord.h"
@@ -176,6 +178,7 @@ CCL_NAMESPACE_END
 #include "svm_voronoi.h"
 #include "svm_checker.h"
 #include "svm_brick.h"
+#include "svm_vector_transform.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -338,6 +341,12 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_COMBINE_RGB:
                                svm_node_combine_rgb(sd, stack, node.y, node.z, node.w);
                                break;
+                       case NODE_SEPARATE_HSV:
+                               svm_node_separate_hsv(kg, sd, stack, node.y, node.z, node.w, &offset);
+                               break;
+                       case NODE_COMBINE_HSV:
+                               svm_node_combine_hsv(kg, sd, stack, node.y, node.z, node.w, &offset);
+                               break;
                        case NODE_HSV:
                                svm_node_hsv(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
@@ -366,6 +375,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_WAVELENGTH:
                                svm_node_wavelength(sd, stack, node.y, node.z);
                                break;
+                       case NODE_BLACKBODY:
+                               svm_node_blackbody(kg, sd, stack, node.y, node.z);
+                               break;
                        case NODE_SET_DISPLACEMENT:
                                svm_node_set_displacement(sd, stack, node.y);
                                break;
@@ -378,6 +390,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
                        case NODE_VECTOR_MATH:
                                svm_node_vector_math(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
+                       case NODE_VECTOR_TRANSFORM:
+                               svm_node_vector_transform(kg, sd, stack, node);
+                               break;
                        case NODE_NORMAL:
                                svm_node_normal(kg, sd, stack, node.y, node.z, node.w, &offset);
                                break;
diff --git a/intern/cycles/kernel/svm/svm_blackbody.h b/intern/cycles/kernel/svm/svm_blackbody.h
new file mode 100644 (file)
index 0000000..4480325
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Adapted from Open Shading Language with this license:
+ *
+ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+ * All Rights Reserved.
+ *
+ * Modifications Copyright 2013, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sony Pictures Imageworks nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+/* Blackbody Node */
+
+__device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
+{
+       /* Output */
+       float3 color_rgb = make_float3(0.0f, 0.0f, 0.0f);
+
+       /* Input */
+       float temperature = stack_load_float(stack, temperature_offset);
+
+       if (temperature < BB_DRAPPER) {
+               /* just return very very dim red */
+               color_rgb = make_float3(1.0e-6f,0.0f,0.0f);
+       }
+       else if (temperature <= BB_MAX_TABLE_RANGE) {
+               /* This is the overall size of the table */
+               const int lookuptablesize = 956;
+               const float lookuptablesizef = 956.0f;
+
+               /* reconstruct a proper index for the table lookup, compared to OSL we don't look up two colors
+               just one (the OSL-lerp is also automatically done for us by "lookup_table_read") */
+               float t = powf ((temperature - BB_DRAPPER) / BB_TABLE_SPACING, 1.0f/BB_TABLE_XPOWER);
+
+               int blackbody_table_offset = kernel_data.blackbody.table_offset;
+
+               /* Retrieve colors from the lookup table */
+               float lutval = t/lookuptablesizef;
+               float R = lookup_table_read(kg, lutval, blackbody_table_offset, lookuptablesize);
+               lutval = (t + 319.0f*1.0f)/lookuptablesizef;
+               float G = lookup_table_read(kg, lutval, blackbody_table_offset, lookuptablesize);
+               lutval = (t + 319.0f*2.0f)/lookuptablesizef;
+               float B = lookup_table_read(kg, lutval, blackbody_table_offset, lookuptablesize);
+
+               R = powf(R, BB_TABLE_YPOWER);
+               G = powf(G, BB_TABLE_YPOWER);
+               B = powf(B, BB_TABLE_YPOWER);
+
+               color_rgb = make_float3(R, G, B);
+       }
+       
+       /* Luminance */
+       float l = linear_rgb_to_gray(color_rgb);
+       color_rgb /= l;
+
+       if (stack_valid(col_offset))
+               stack_store_float3(stack, col_offset, color_rgb);
+}
+
+CCL_NAMESPACE_END
index 57adaa863f111a859ef16482c664b30b233ea3eb..037bfa2d9b9014672ad1c86424b1143f818c7add 100644 (file)
@@ -229,6 +229,60 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u
                case 97: r = kernel_tex_image_interp(__tex_image_097, x, y); break;
                case 98: r = kernel_tex_image_interp(__tex_image_098, x, y); break;
                case 99: r = kernel_tex_image_interp(__tex_image_099, x, y); break;
+#if defined(__KERNEL_CUDA__) && __CUDA_ARCH__ >= 300
+               case 100: r = kernel_tex_image_interp(__tex_image_100, x, y); break;
+               case 101: r = kernel_tex_image_interp(__tex_image_101, x, y); break;
+               case 102: r = kernel_tex_image_interp(__tex_image_102, x, y); break;
+               case 103: r = kernel_tex_image_interp(__tex_image_103, x, y); break;
+               case 104: r = kernel_tex_image_interp(__tex_image_104, x, y); break;
+               case 105: r = kernel_tex_image_interp(__tex_image_105, x, y); break;
+               case 106: r = kernel_tex_image_interp(__tex_image_106, x, y); break;
+               case 107: r = kernel_tex_image_interp(__tex_image_107, x, y); break;
+               case 108: r = kernel_tex_image_interp(__tex_image_108, x, y); break;
+               case 109: r = kernel_tex_image_interp(__tex_image_109, x, y); break;
+               case 110: r = kernel_tex_image_interp(__tex_image_110, x, y); break;
+               case 111: r = kernel_tex_image_interp(__tex_image_111, x, y); break;
+               case 112: r = kernel_tex_image_interp(__tex_image_112, x, y); break;
+               case 113: r = kernel_tex_image_interp(__tex_image_113, x, y); break;
+               case 114: r = kernel_tex_image_interp(__tex_image_114, x, y); break;
+               case 115: r = kernel_tex_image_interp(__tex_image_115, x, y); break;
+               case 116: r = kernel_tex_image_interp(__tex_image_116, x, y); break;
+               case 117: r = kernel_tex_image_interp(__tex_image_117, x, y); break;
+               case 118: r = kernel_tex_image_interp(__tex_image_118, x, y); break;
+               case 119: r = kernel_tex_image_interp(__tex_image_119, x, y); break;
+               case 120: r = kernel_tex_image_interp(__tex_image_120, x, y); break;
+               case 121: r = kernel_tex_image_interp(__tex_image_121, x, y); break;
+               case 122: r = kernel_tex_image_interp(__tex_image_122, x, y); break;
+               case 123: r = kernel_tex_image_interp(__tex_image_123, x, y); break;
+               case 124: r = kernel_tex_image_interp(__tex_image_124, x, y); break;
+               case 125: r = kernel_tex_image_interp(__tex_image_125, x, y); break;
+               case 126: r = kernel_tex_image_interp(__tex_image_126, x, y); break;
+               case 127: r = kernel_tex_image_interp(__tex_image_127, x, y); break;
+               case 128: r = kernel_tex_image_interp(__tex_image_128, x, y); break;
+               case 129: r = kernel_tex_image_interp(__tex_image_129, x, y); break;
+               case 130: r = kernel_tex_image_interp(__tex_image_130, x, y); break;
+               case 131: r = kernel_tex_image_interp(__tex_image_131, x, y); break;
+               case 132: r = kernel_tex_image_interp(__tex_image_132, x, y); break;
+               case 133: r = kernel_tex_image_interp(__tex_image_133, x, y); break;
+               case 134: r = kernel_tex_image_interp(__tex_image_134, x, y); break;
+               case 135: r = kernel_tex_image_interp(__tex_image_135, x, y); break;
+               case 136: r = kernel_tex_image_interp(__tex_image_136, x, y); break;
+               case 137: r = kernel_tex_image_interp(__tex_image_137, x, y); break;
+               case 138: r = kernel_tex_image_interp(__tex_image_138, x, y); break;
+               case 139: r = kernel_tex_image_interp(__tex_image_139, x, y); break;
+               case 140: r = kernel_tex_image_interp(__tex_image_140, x, y); break;
+               case 141: r = kernel_tex_image_interp(__tex_image_141, x, y); break;
+               case 142: r = kernel_tex_image_interp(__tex_image_142, x, y); break;
+               case 143: r = kernel_tex_image_interp(__tex_image_143, x, y); break;
+               case 144: r = kernel_tex_image_interp(__tex_image_144, x, y); break;
+               case 145: r = kernel_tex_image_interp(__tex_image_145, x, y); break;
+               case 146: r = kernel_tex_image_interp(__tex_image_146, x, y); break;
+               case 147: r = kernel_tex_image_interp(__tex_image_147, x, y); break;
+               case 148: r = kernel_tex_image_interp(__tex_image_148, x, y); break;
+               case 149: r = kernel_tex_image_interp(__tex_image_149, x, y); break;
+               case 150: r = kernel_tex_image_interp(__tex_image_150, x, y); break;
+#endif
+
                default: 
                        kernel_assert(0);
                        return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
index b29dc9cbd45c436e8e3c287b40386a1e623fc875..b962ae2018d868d3d4fef81e91069d02534230be 100644 (file)
@@ -34,6 +34,7 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint
                case NODE_LP_transmission: info = (path_flag & PATH_RAY_TRANSMIT)? 1.0f: 0.0f; break;
                case NODE_LP_backfacing: info = (sd->flag & SD_BACKFACING)? 1.0f: 0.0f; break;
                case NODE_LP_ray_length: info = sd->ray_length; break;
+               case NODE_LP_ray_depth: info = sd->ray_depth; break;
        }
 
        stack_store_float(stack, out_offset, info);
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
new file mode 100644 (file)
index 0000000..d349d0e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+__device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset)
+{
+       uint4 node1 = read_node(kg, offset);
+       uint color_out = node1.y;
+       
+       float hue = stack_load_float(stack, hue_in);
+       float saturation = stack_load_float(stack, saturation_in);
+       float value = stack_load_float(stack, value_in);
+       
+       /* Combine, and convert back to RGB */
+       float3 color = hsv_to_rgb(make_float3(hue, saturation, value));
+
+       if (stack_valid(color_out))
+               stack_store_float3(stack, color_out, color);
+}
+
+__device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset)
+{
+       uint4 node1 = read_node(kg, offset);
+       uint value_out = node1.y;
+       
+       float3 color = stack_load_float3(stack, color_in);
+       
+       /* Convert to HSV */
+       color = rgb_to_hsv(color);
+
+       if (stack_valid(hue_out)) 
+                       stack_store_float(stack, hue_out, color.x);
+       if (stack_valid(saturation_out)) 
+                       stack_store_float(stack, saturation_out, color.y);
+       if (stack_valid(value_out)) 
+                       stack_store_float(stack, value_out, color.z);
+}
+
+CCL_NAMESPACE_END
+
index e5b3e2b972f4773de09cdb8ad2fd788811d943b1..ecbc43a16dab35480b2d173fab17ab3e0e2bc34e 100644 (file)
@@ -53,6 +53,7 @@ typedef enum NodeType {
        NODE_FRESNEL,
        NODE_WIREFRAME,
        NODE_WAVELENGTH,
+       NODE_BLACKBODY,
        NODE_EMISSION_WEIGHT,
        NODE_TEX_GRADIENT,
        NODE_TEX_VORONOI,
@@ -67,6 +68,7 @@ typedef enum NodeType {
        NODE_SET_BUMP,
        NODE_MATH,
        NODE_VECTOR_MATH,
+       NODE_VECTOR_TRANSFORM,
        NODE_MAPPING,
        NODE_TEX_COORD,
        NODE_TEX_COORD_BUMP_DX,
@@ -81,6 +83,8 @@ typedef enum NodeType {
        NODE_CLOSURE_VOLUME,
        NODE_SEPARATE_RGB,
        NODE_COMBINE_RGB,
+       NODE_SEPARATE_HSV,
+       NODE_COMBINE_HSV,
        NODE_HSV,
        NODE_CAMERA,
        NODE_INVERT,
@@ -153,7 +157,8 @@ typedef enum NodeLightPath {
        NODE_LP_reflection,
        NODE_LP_transmission,
        NODE_LP_backfacing,
-       NODE_LP_ray_length
+       NODE_LP_ray_length,
+       NODE_LP_ray_depth
 } NodeLightPath;
 
 typedef enum NodeLightFalloff {
@@ -225,6 +230,23 @@ typedef enum NodeVectorMath {
        NODE_VECTOR_MATH_NORMALIZE
 } NodeVectorMath;
 
+typedef enum NodeVectorTransformType {
+       NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
+       NODE_VECTOR_TRANSFORM_TYPE_POINT
+} NodeVectorTransformType;
+
+typedef enum NodeVectorTransformConvertFrom {
+       NODE_VECTOR_TRANSFORM_CONVERT_FROM_WORLD,
+       NODE_VECTOR_TRANSFORM_CONVERT_FROM_OBJECT,
+       NODE_VECTOR_TRANSFORM_CONVERT_FROM_CAMERA
+} NodeVectorTransformConvertFrom;
+
+typedef enum NodeVectorTransformConvertTo {
+       NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD,
+       NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT,
+       NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA
+} NodeVectorTransformConvertTo;
+
 typedef enum NodeConvert {
        NODE_CONVERT_FV,
        NODE_CONVERT_FI,
diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h
new file mode 100644 (file)
index 0000000..8b5369a
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2013, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+/* Vector Transform */
+
+__device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+{
+       uint itype, ifrom, ito;
+       uint vector_in, vector_out;
+       
+       decode_node_uchar4(node.y, &itype, &ifrom, &ito, NULL);
+       decode_node_uchar4(node.z, &vector_in, &vector_out, NULL, NULL);
+       
+       float3 in = stack_load_float3(stack, vector_in);
+       
+       NodeVectorTransformType type = (NodeVectorTransformType)itype;
+       NodeVectorTransformConvertFrom from = (NodeVectorTransformConvertFrom)ifrom;
+       NodeVectorTransformConvertTo to = (NodeVectorTransformConvertTo)ito;
+       
+       Transform tfm;
+       int is_object = (sd->object != ~0);
+       
+       /* From world */
+       if(from == NODE_VECTOR_TRANSFORM_CONVERT_FROM_WORLD) {
+               if(to == NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA) {
+                       tfm = kernel_data.cam.worldtocamera;
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               in = transform_direction(&tfm, in);
+                       else
+                               in = transform_point(&tfm, in);
+               }
+               else if (to == NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT && is_object) {
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               object_inverse_dir_transform(kg, sd, &in);
+                       else
+                               object_inverse_position_transform(kg, sd, &in);
+               }
+       }
+       
+       /* From camera */
+       else if (from == NODE_VECTOR_TRANSFORM_CONVERT_FROM_CAMERA) {
+               if(to == NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT) {
+                       tfm = kernel_data.cam.cameratoworld;
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               in = transform_direction(&tfm, in);
+                       else
+                               in = transform_point(&tfm, in);
+               }
+               if(to == NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT && is_object) {
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               object_inverse_dir_transform(kg, sd, &in);
+                       else
+                               object_inverse_position_transform(kg, sd, &in);
+               }
+       }
+       
+       /* From object */
+       else if(from == NODE_VECTOR_TRANSFORM_CONVERT_FROM_OBJECT) {
+               if((to == NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA) && is_object) {
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               object_dir_transform(kg, sd, &in);
+                       else
+                               object_position_transform(kg, sd, &in);
+               }
+               if(to == NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA) {
+                       tfm = kernel_data.cam.worldtocamera;
+                       if(type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR)
+                               in = transform_direction(&tfm, in);
+                       else
+                               in = transform_point(&tfm, in);
+               }
+       }
+       
+       /* Output */    
+       if(stack_valid(vector_out)) {
+                       stack_store_float3(stack, vector_out, in);
+       }
+}
+
+CCL_NAMESPACE_END
+
index f3f230c29dcf8cd524da1ece00931a9da0189eaf..0cf29435a8c3ab4e13648b87e7000c927f2efef6 100644 (file)
@@ -16,6 +16,7 @@ set(INC_SYS
 set(SRC
        attribute.cpp
        background.cpp
+       blackbody.cpp
        buffers.cpp
        bssrdf.cpp
        camera.cpp
@@ -43,6 +44,7 @@ set(SRC
 set(SRC_HEADERS
        attribute.h
        background.h
+       blackbody.h
        buffers.h
        bssrdf.h
        camera.h
diff --git a/intern/cycles/render/blackbody.cpp b/intern/cycles/render/blackbody.cpp
new file mode 100644 (file)
index 0000000..4673689
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Adapted from Open Shading Language with this license:
+ *
+ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+ * All Rights Reserved.
+ *
+ * Modifications Copyright 2013, Blender Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sony Pictures Imageworks nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "blackbody.h"
+#include "util_color.h"
+#include "util_math.h"
+
+#include "kernel_types.h"
+
+CCL_NAMESPACE_BEGIN
+
+vector<float> blackbody_table()
+{
+       /* quoted from OSLs opcolor.cpp
+       In order to speed up the blackbody computation, we have a table
+       storing the precomputed BB values for a range of temperatures.  Less
+       than BB_DRAPER always returns 0.  Greater than BB_MAX_TABLE_RANGE
+       does the full computation, we think it'll be rare to inquire higher
+       temperatures.
+
+       Since the bb function is so nonlinear, we actually space the table
+       entries nonlinearly, with the relationship between the table index i
+       and the temperature T as follows:
+       i = ((T-Draper)/spacing)^(1/xpower)
+       T = pow(i, xpower) * spacing + Draper
+       And furthermore, we store in the table the true value raised ^(1/5).
+       I tuned this a bit, and with the current values we can have all
+       blackbody results accurate to within 0.1% with a table size of 317
+       (about 5 KB of data).
+       */
+
+       const float cie_colour_match[81][3] = {
+               {0.0014,0.0000,0.0065}, {0.0022,0.0001,0.0105}, {0.0042,0.0001,0.0201},
+               {0.0076,0.0002,0.0362}, {0.0143,0.0004,0.0679}, {0.0232,0.0006,0.1102},
+               {0.0435,0.0012,0.2074}, {0.0776,0.0022,0.3713}, {0.1344,0.0040,0.6456},
+               {0.2148,0.0073,1.0391}, {0.2839,0.0116,1.3856}, {0.3285,0.0168,1.6230},
+               {0.3483,0.0230,1.7471}, {0.3481,0.0298,1.7826}, {0.3362,0.0380,1.7721},
+               {0.3187,0.0480,1.7441}, {0.2908,0.0600,1.6692}, {0.2511,0.0739,1.5281},
+               {0.1954,0.0910,1.2876}, {0.1421,0.1126,1.0419}, {0.0956,0.1390,0.8130},
+               {0.0580,0.1693,0.6162}, {0.0320,0.2080,0.4652}, {0.0147,0.2586,0.3533},
+               {0.0049,0.3230,0.2720}, {0.0024,0.4073,0.2123}, {0.0093,0.5030,0.1582},
+               {0.0291,0.6082,0.1117}, {0.0633,0.7100,0.0782}, {0.1096,0.7932,0.0573},
+               {0.1655,0.8620,0.0422}, {0.2257,0.9149,0.0298}, {0.2904,0.9540,0.0203},
+               {0.3597,0.9803,0.0134}, {0.4334,0.9950,0.0087}, {0.5121,1.0000,0.0057},
+               {0.5945,0.9950,0.0039}, {0.6784,0.9786,0.0027}, {0.7621,0.9520,0.0021},
+               {0.8425,0.9154,0.0018}, {0.9163,0.8700,0.0017}, {0.9786,0.8163,0.0014},
+               {1.0263,0.7570,0.0011}, {1.0567,0.6949,0.0010}, {1.0622,0.6310,0.0008},
+               {1.0456,0.5668,0.0006}, {1.0026,0.5030,0.0003}, {0.9384,0.4412,0.0002},
+               {0.8544,0.3810,0.0002}, {0.7514,0.3210,0.0001}, {0.6424,0.2650,0.0000},
+               {0.5419,0.2170,0.0000}, {0.4479,0.1750,0.0000}, {0.3608,0.1382,0.0000},
+               {0.2835,0.1070,0.0000}, {0.2187,0.0816,0.0000}, {0.1649,0.0610,0.0000},
+               {0.1212,0.0446,0.0000}, {0.0874,0.0320,0.0000}, {0.0636,0.0232,0.0000},
+               {0.0468,0.0170,0.0000}, {0.0329,0.0119,0.0000}, {0.0227,0.0082,0.0000},
+               {0.0158,0.0057,0.0000}, {0.0114,0.0041,0.0000}, {0.0081,0.0029,0.0000},
+               {0.0058,0.0021,0.0000}, {0.0041,0.0015,0.0000}, {0.0029,0.0010,0.0000},
+               {0.0020,0.0007,0.0000}, {0.0014,0.0005,0.0000}, {0.0010,0.0004,0.0000},
+               {0.0007,0.0002,0.0000}, {0.0005,0.0002,0.0000}, {0.0003,0.0001,0.0000},
+               {0.0002,0.0001,0.0000}, {0.0002,0.0001,0.0000}, {0.0001,0.0000,0.0000},
+               {0.0001,0.0000,0.0000}, {0.0001,0.0000,0.0000}, {0.0000,0.0000,0.0000}
+       };
+
+       const double c1 = 3.74183e-16; // 2*pi*h*c^2, W*m^2
+       const double c2 = 1.4388e-2;   // h*c/k, m*K
+                                                                  // h is Planck's const, k is Boltzmann's
+       const float dlambda = 5.0f * 1e-9;  // in meters
+
+       /* Blackbody table from 800 to 12k Kelvin (319 entries (317+2 offset) * 3) */
+       vector<float> blackbody_table(956);
+
+       float X, Y, Z;
+
+       /* ToDo: bring this back to what OSL does with the lastTemperature limit ? */
+       for (int i = 0;  i <= 317;  ++i) {
+               float Temperature = powf (float(i), BB_TABLE_XPOWER) * BB_TABLE_SPACING + BB_DRAPPER;
+               X = 0;
+               Y = 0;
+               Z = 0;
+
+               /* from OSL "spectrum_to_XYZ" */
+               for (int n = 0; n < 81; ++n) {
+                       float lambda = 380.0f + 5.0f * n;
+                       double wlm = lambda * 1e-9;   // Wavelength in meters
+                       // N.B. spec_intens returns result in W/m^2 but it's a differential,
+                       // needs to be scaled by dlambda!
+                       float spec_intens = float((c1 * powf(wlm,-5.0)) / (expf(c2 / (wlm * Temperature)) -1.0f));
+                       float Me = spec_intens * dlambda;
+
+                       X += Me * cie_colour_match[n][0];
+                       Y += Me * cie_colour_match[n][1];
+                       Z += Me * cie_colour_match[n][2];
+               }
+               
+               /* Convert from xyz color space */
+               float3 col = xyz_to_rgb(X, Y, Z);
+
+               /* Clamp to zero if values are smaller */
+               col = max(col, make_float3(0.0f, 0.0f, 0.0f));
+
+               col.x = powf(col.x, 1.0f / BB_TABLE_YPOWER);
+               col.y = powf(col.y, 1.0f / BB_TABLE_YPOWER);
+               col.z = powf(col.z, 1.0f / BB_TABLE_YPOWER);
+
+               /* Store in table in RRRGGGBBB format */
+               blackbody_table[i] = col.x;
+               blackbody_table[i+319*1] = col.y;
+               blackbody_table[i+319*2] = col.z;       
+       }
+
+       return blackbody_table;
+}
+CCL_NAMESPACE_END
diff --git a/intern/cycles/render/blackbody.h b/intern/cycles/render/blackbody.h
new file mode 100644 (file)
index 0000000..a177238
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __BLACKBODY_H__
+#define __BLACKBODY_H__
+
+#include "util_vector.h"
+
+CCL_NAMESPACE_BEGIN
+
+vector<float> blackbody_table();
+
+CCL_NAMESPACE_END
+
+#endif /* __BLACKBODY_H__ */
index 2a16b7b6c217b9948f16f99a6cb8adef0f01871d..4b48ee1d2c9fa988bd8228b076d230d24c0ee753 100644 (file)
@@ -98,6 +98,9 @@ void Pass::add(PassType type, vector<Pass>& passes)
                case PASS_TRANSMISSION_COLOR:
                        pass.components = 4;
                        break;
+               case PASS_SUBSURFACE_COLOR:
+                       pass.components = 4;
+                       break;
                case PASS_DIFFUSE_INDIRECT:
                        pass.components = 4;
                        pass.exposure = true;
@@ -113,6 +116,11 @@ void Pass::add(PassType type, vector<Pass>& passes)
                        pass.exposure = true;
                        pass.divide_type = PASS_TRANSMISSION_COLOR;
                        break;
+               case PASS_SUBSURFACE_INDIRECT:
+                       pass.components = 4;
+                       pass.exposure = true;
+                       pass.divide_type = PASS_SUBSURFACE_COLOR;
+                       break;
                case PASS_DIFFUSE_DIRECT:
                        pass.components = 4;
                        pass.exposure = true;
@@ -128,6 +136,11 @@ void Pass::add(PassType type, vector<Pass>& passes)
                        pass.exposure = true;
                        pass.divide_type = PASS_TRANSMISSION_COLOR;
                        break;
+               case PASS_SUBSURFACE_DIRECT:
+                       pass.components = 4;
+                       pass.exposure = true;
+                       pass.divide_type = PASS_SUBSURFACE_COLOR;
+                       break;
 
                case PASS_EMISSION:
                        pass.components = 4;
@@ -327,6 +340,10 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
                                kfilm->pass_transmission_color = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
                                break;
+                       case PASS_SUBSURFACE_COLOR:
+                               kfilm->pass_subsurface_color = kfilm->pass_stride;
+                               kfilm->use_light_pass = 1;
+                               break;
                        case PASS_DIFFUSE_INDIRECT:
                                kfilm->pass_diffuse_indirect = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
@@ -339,6 +356,10 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
                                kfilm->pass_transmission_indirect = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
                                break;
+                       case PASS_SUBSURFACE_INDIRECT:
+                               kfilm->pass_subsurface_indirect = kfilm->pass_stride;
+                               kfilm->use_light_pass = 1;
+                               break;
                        case PASS_DIFFUSE_DIRECT:
                                kfilm->pass_diffuse_direct = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
@@ -351,6 +372,10 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
                                kfilm->pass_transmission_direct = kfilm->pass_stride;
                                kfilm->use_light_pass = 1;
                                break;
+                       case PASS_SUBSURFACE_DIRECT:
+                               kfilm->pass_subsurface_direct = kfilm->pass_stride;
+                               kfilm->use_light_pass = 1;
+                               break;
 
                        case PASS_EMISSION:
                                kfilm->pass_emission = kfilm->pass_stride;
index 90e4760ba1c24832375245d8fd95f8cfdd4dd016..da8ed987346f93283e411e215ec5a77b33d9aa44 100644 (file)
@@ -189,6 +189,7 @@ public:
        virtual bool has_surface_emission() { return false; }
        virtual bool has_surface_transparent() { return false; }
        virtual bool has_surface_bssrdf() { return false; }
+       virtual bool has_converter_blackbody() { return false; }
 
        vector<ShaderInput*> inputs;
        vector<ShaderOutput*> outputs;
index 8e844bc788eff0004156a42b059f216bfc86b12e..65521103df19ea618af663e62e7898c65fd4f46b 100644 (file)
@@ -61,11 +61,16 @@ void ImageManager::set_osl_texture_system(void *texture_system)
        osl_texture_system = texture_system;
 }
 
-void ImageManager::set_extended_image_limits(void)
+void ImageManager::set_extended_image_limits(const DeviceInfo& info)
 {
-       tex_num_images = TEX_EXTENDED_NUM_IMAGES;
-       tex_num_float_images = TEX_EXTENDED_NUM_FLOAT_IMAGES;
-       tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START;
+       if(info.type == DEVICE_CPU) {
+               tex_num_images = TEX_EXTENDED_NUM_IMAGES_CPU;
+               tex_num_float_images = TEX_EXTENDED_NUM_FLOAT_IMAGES;
+               tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START;
+       }
+       else if ((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && info.extended_images) {
+               tex_num_images = TEX_EXTENDED_NUM_IMAGES_GPU;
+       }
 }
 
 bool ImageManager::set_animation_frame_update(int frame)
index b20ff23fbbb7e0c185cc92b675837fbe7441b551..276420abea1665cc570ccaa4f3b43cccb9d4e9a6 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef __IMAGE_H__
 #define __IMAGE_H__
 
+#include "device.h"
 #include "device_memory.h"
 
 #include "util_string.h"
 
 CCL_NAMESPACE_BEGIN
 
+/* Normal Image amount */
 #define TEX_NUM_IMAGES                 95
 #define TEX_IMAGE_BYTE_START   TEX_NUM_FLOAT_IMAGES
 
+/* Extended Image amount*/
 #define TEX_EXTENDED_NUM_FLOAT_IMAGES  5
-#define TEX_EXTENDED_NUM_IMAGES                        512
 #define TEX_EXTENDED_IMAGE_BYTE_START  TEX_EXTENDED_NUM_FLOAT_IMAGES
+#define TEX_EXTENDED_NUM_IMAGES_CPU            512
+#define TEX_EXTENDED_NUM_IMAGES_GPU            145
 
 /* color to use when textures are not found */
 #define TEX_IMAGE_MISSING_R 1
@@ -60,7 +64,7 @@ public:
 
        void set_osl_texture_system(void *texture_system);
        void set_pack_images(bool pack_images_);
-       void set_extended_image_limits(void);
+       void set_extended_image_limits(const DeviceInfo& info);
        bool set_animation_frame_update(int frame);
 
        bool need_update;
index 029b948332af8e42ec762b0e00c123778e1b6507..faaaf61b2be1b9a4cd9da474acd5d648084281a8 100644 (file)
@@ -2064,6 +2064,7 @@ LightPathNode::LightPathNode()
        add_output("Is Reflection Ray", SHADER_SOCKET_FLOAT);
        add_output("Is Transmission Ray", SHADER_SOCKET_FLOAT);
        add_output("Ray Length", SHADER_SOCKET_FLOAT);
+       add_output("Ray Depth", SHADER_SOCKET_FLOAT);
 }
 
 void LightPathNode::compile(SVMCompiler& compiler)
@@ -2118,6 +2119,12 @@ void LightPathNode::compile(SVMCompiler& compiler)
                compiler.stack_assign(out);
                compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_length, out->stack_offset);
        }
+       
+       out = output("Ray Depth");
+       if(!out->links.empty()) {
+               compiler.stack_assign(out);
+               compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_depth, out->stack_offset);
+       }
 
 }
 
@@ -2644,6 +2651,37 @@ void CombineRGBNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_combine_rgb");
 }
 
+/* Combine HSV */
+CombineHSVNode::CombineHSVNode()
+: ShaderNode("combine_hsv")
+{
+       add_input("H", SHADER_SOCKET_FLOAT);
+       add_input("S", SHADER_SOCKET_FLOAT);
+       add_input("V", SHADER_SOCKET_FLOAT);
+       add_output("Color", SHADER_SOCKET_COLOR);
+}
+
+void CombineHSVNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *hue_in = input("H");
+       ShaderInput *saturation_in = input("S");
+       ShaderInput *value_in = input("V");
+       ShaderOutput *color_out = output("Color");
+
+       compiler.stack_assign(color_out);
+       compiler.stack_assign(hue_in);
+       compiler.stack_assign(saturation_in);
+       compiler.stack_assign(value_in);
+       
+       compiler.add_node(NODE_COMBINE_HSV, hue_in->stack_offset, saturation_in->stack_offset, value_in->stack_offset);
+       compiler.add_node(NODE_COMBINE_HSV, color_out->stack_offset);
+}
+
+void CombineHSVNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_combine_hsv");
+}
+
 /* Gamma */
 GammaNode::GammaNode()
 : ShaderNode("gamma")
@@ -2737,7 +2775,39 @@ void SeparateRGBNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_separate_rgb");
 }
 
-/* Separate RGB */
+/* Separate HSV */
+SeparateHSVNode::SeparateHSVNode()
+: ShaderNode("separate_rgb")
+{
+       add_input("Color", SHADER_SOCKET_COLOR);
+       add_output("H", SHADER_SOCKET_FLOAT);
+       add_output("S", SHADER_SOCKET_FLOAT);
+       add_output("V", SHADER_SOCKET_FLOAT);
+}
+
+void SeparateHSVNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *color_in = input("Color");
+       ShaderOutput *hue_out = output("H");
+       ShaderOutput *saturation_out = output("S");
+       ShaderOutput *value_out = output("V");
+
+       compiler.stack_assign(color_in);
+       compiler.stack_assign(hue_out);
+       compiler.stack_assign(saturation_out);
+       compiler.stack_assign(value_out);
+       
+       compiler.add_node(NODE_SEPARATE_HSV, color_in->stack_offset, hue_out->stack_offset, saturation_out->stack_offset);
+       compiler.add_node(NODE_SEPARATE_HSV, value_out->stack_offset);
+
+}
+
+void SeparateHSVNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_separate_hsv");
+}
+
+/* Hue Saturation Value */
 HSVNode::HSVNode()
 : ShaderNode("hsv")
 {
@@ -2986,6 +3056,30 @@ void WavelengthNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_wavelength");
 }
 
+/* Blackbody */
+
+BlackbodyNode::BlackbodyNode()
+: ShaderNode("Blackbody")
+{
+       add_input("Temperature", SHADER_SOCKET_FLOAT, 1200.0f);
+       add_output("Color", SHADER_SOCKET_COLOR);
+}
+
+void BlackbodyNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *temperature_in = input("Temperature");
+       ShaderOutput *color_out = output("Color");
+
+       compiler.stack_assign(temperature_in);
+       compiler.stack_assign(color_out);
+       compiler.add_node(NODE_BLACKBODY, temperature_in->stack_offset, color_out->stack_offset);
+}
+
+void BlackbodyNode::compile(OSLCompiler& compiler)
+{
+       compiler.add(this, "node_blackbody");
+}
+
 /* Output */
 
 OutputNode::OutputNode()
@@ -3138,6 +3232,76 @@ void VectorMathNode::compile(OSLCompiler& compiler)
        compiler.add(this, "node_vector_math");
 }
 
+/* VectorTransform */
+
+VectorTransformNode::VectorTransformNode()
+: ShaderNode("vector_transform")
+{
+       type = ustring("Vector");
+       convert_from = ustring("world");
+       convert_to = ustring("object");
+
+       add_input("Vector", SHADER_SOCKET_VECTOR);
+       add_output("Vector",  SHADER_SOCKET_VECTOR);
+}
+
+static ShaderEnum vector_transform_type_init()
+{
+       ShaderEnum enm;
+
+       enm.insert("Vector", NODE_VECTOR_TRANSFORM_TYPE_VECTOR);
+       enm.insert("Point", NODE_VECTOR_TRANSFORM_TYPE_POINT);
+
+       return enm;
+}
+
+static ShaderEnum vector_transform_convert_from_init()
+{
+       ShaderEnum enm;
+
+       enm.insert("world", NODE_VECTOR_TRANSFORM_CONVERT_FROM_WORLD);
+       enm.insert("object", NODE_VECTOR_TRANSFORM_CONVERT_FROM_OBJECT);
+       enm.insert("camera", NODE_VECTOR_TRANSFORM_CONVERT_FROM_CAMERA);
+
+       return enm;
+}
+
+static ShaderEnum vector_transform_convert_to_init()
+{
+       ShaderEnum enm;
+
+       enm.insert("world", NODE_VECTOR_TRANSFORM_CONVERT_TO_WORLD);
+       enm.insert("object", NODE_VECTOR_TRANSFORM_CONVERT_TO_OBJECT);
+       enm.insert("camera", NODE_VECTOR_TRANSFORM_CONVERT_TO_CAMERA);
+
+       return enm;
+}
+
+ShaderEnum VectorTransformNode::type_enum = vector_transform_type_init();
+ShaderEnum VectorTransformNode::convert_from_enum = vector_transform_convert_from_init();
+ShaderEnum VectorTransformNode::convert_to_enum = vector_transform_convert_to_init();
+
+void VectorTransformNode::compile(SVMCompiler& compiler)
+{
+       ShaderInput *vector_in = input("Vector");
+       ShaderOutput *vector_out = output("Vector");
+
+       compiler.stack_assign(vector_in);
+       compiler.stack_assign(vector_out);
+
+       compiler.add_node(NODE_VECTOR_TRANSFORM,
+               compiler.encode_uchar4(type_enum[type], convert_from_enum[convert_from], convert_to_enum[convert_to]),
+               compiler.encode_uchar4(vector_in->stack_offset, vector_out->stack_offset));
+}
+
+void VectorTransformNode::compile(OSLCompiler& compiler)
+{
+       compiler.parameter("type", type);
+       compiler.parameter("convert_from", convert_from);
+       compiler.parameter("convert_to", convert_to);
+       compiler.add(this, "node_vector_transform");
+}
+
 /* BumpNode */
 
 BumpNode::BumpNode()
index 78920d589ed16530ebdf00dbd42d1d3b5207f664..ed4d24c774a645855758311bfc84979a5df8150e 100644 (file)
@@ -407,6 +407,11 @@ public:
        SHADER_NODE_CLASS(CombineRGBNode)
 };
 
+class CombineHSVNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(CombineHSVNode)
+};
+
 class GammaNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(GammaNode)
@@ -422,6 +427,11 @@ public:
        SHADER_NODE_CLASS(SeparateRGBNode)
 };
 
+class SeparateHSVNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(SeparateHSVNode)
+};
+
 class HSVNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(HSVNode)
@@ -462,6 +472,13 @@ public:
        SHADER_NODE_CLASS(WavelengthNode)
 };
 
+class BlackbodyNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(BlackbodyNode)
+       
+       bool has_converter_blackbody() { return true; }
+};
+
 class MathNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(MathNode)
@@ -487,6 +504,19 @@ public:
        static ShaderEnum type_enum;
 };
 
+class VectorTransformNode : public ShaderNode {
+public:
+       SHADER_NODE_CLASS(VectorTransformNode)
+
+       ustring type;
+       ustring convert_from;
+       ustring convert_to;
+       
+       static ShaderEnum type_enum;
+       static ShaderEnum convert_from_enum;
+       static ShaderEnum convert_to_enum;
+};
+
 class BumpNode : public ShaderNode {
 public:
        SHADER_NODE_CLASS(BumpNode)
index a6dca62ffd0ada5fc4eec5fe3e2e0191d7834e38..feffa2a797196d4ff910fe891d22c3ec3478460b 100644 (file)
@@ -63,8 +63,8 @@ Scene::Scene(const SceneParams& params_, const DeviceInfo& device_info_)
        else
                shader_manager = ShaderManager::create(this, SceneParams::SVM);
 
-       if (device_info_.type == DEVICE_CPU)
-               image_manager->set_extended_image_limits();
+       /* Extended Image limits for CPU and Kepler GPUs */
+       image_manager->set_extended_image_limits(device_info_);
 }
 
 Scene::~Scene()
index 0790d4159c5a12a9e60033342833aa048917bece..8f5bc4ead950092ed939aae90cdeb4492a7caddf 100644 (file)
@@ -105,8 +105,8 @@ public:
        /* integrator */
        device_vector<uint> sobol_directions;
 
-       /* images */
-       device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES];
+       /* CPU images */
+       device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES_CPU];
        device_vector<float4> tex_float_image[TEX_EXTENDED_NUM_FLOAT_IMAGES];
 
        /* opencl images */
index 21b43380f2cf951496b6ac451ff3f36aa7dea1c8..72a0645c779eea96d0a67775123e4bf3d8b29dfe 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "background.h"
 #include "bssrdf.h"
+#include "blackbody.h"
 #include "device.h"
 #include "graph.h"
 #include "light.h"
@@ -51,6 +52,7 @@ Shader::Shader()
        has_surface_transparent = false;
        has_surface_emission = false;
        has_surface_bssrdf = false;
+       has_converter_blackbody = false;
        has_volume = false;
        has_displacement = false;
 
@@ -127,6 +129,7 @@ ShaderManager::ShaderManager()
 {
        need_update = true;
        bssrdf_table_offset = TABLE_OFFSET_INVALID;
+       blackbody_table_offset = TABLE_OFFSET_INVALID;
 }
 
 ShaderManager::~ShaderManager()
@@ -218,6 +221,7 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
        uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
        uint i = 0;
        bool has_surface_bssrdf = false;
+       bool has_converter_blackbody = false;
 
        foreach(Shader *shader, scene->shaders) {
                uint flag = 0;
@@ -232,6 +236,8 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
                        flag |= SD_HOMOGENEOUS_VOLUME;
                if(shader->has_surface_bssrdf)
                        has_surface_bssrdf = true;
+               if(shader->has_converter_blackbody)
+                       has_converter_blackbody = true;
 
                shader_flag[i++] = flag;
                shader_flag[i++] = shader->pass_id;
@@ -257,6 +263,21 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
                scene->lookup_tables->remove_table(bssrdf_table_offset);
                bssrdf_table_offset = TABLE_OFFSET_INVALID;
        }
+
+       /* blackbody lookup table */
+       KernelBLACKBODY *kblackbody = &dscene->data.blackbody;
+       
+       if(has_converter_blackbody && blackbody_table_offset == TABLE_OFFSET_INVALID) {
+               vector<float> table = blackbody_table();
+               blackbody_table_offset = scene->lookup_tables->add_table(dscene, table);
+               
+               kblackbody->table_offset = (int)blackbody_table_offset;
+       }
+       else if(!has_converter_blackbody && blackbody_table_offset != TABLE_OFFSET_INVALID) {
+               scene->lookup_tables->remove_table(blackbody_table_offset);
+               blackbody_table_offset = TABLE_OFFSET_INVALID;
+       }
+
 }
 
 void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene)
@@ -266,6 +287,11 @@ void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scen
                bssrdf_table_offset = TABLE_OFFSET_INVALID;
        }
 
+       if(blackbody_table_offset != TABLE_OFFSET_INVALID) {
+               scene->lookup_tables->remove_table(blackbody_table_offset);
+               blackbody_table_offset = TABLE_OFFSET_INVALID;
+       }
+
        device->tex_free(dscene->shader_flag);
        dscene->shader_flag.clear();
 }
index 8810017068bff577f6354b12cb933caf73a1af0a..d7eac603fa65cbf0c1696ae772d8db793d46a1c9 100644 (file)
@@ -77,6 +77,7 @@ public:
        bool has_volume;
        bool has_displacement;
        bool has_surface_bssrdf;
+       bool has_converter_blackbody;
 
        /* requested mesh attributes */
        AttributeRequestSet attributes;
@@ -142,6 +143,7 @@ protected:
        AttributeIDMap unique_attribute_id;
 
        size_t bssrdf_table_offset;
+       size_t blackbody_table_offset;
 };
 
 CCL_NAMESPACE_END
index 3e211a3ee24f723aab7a4a2172518fe094f8af11..30105af291027f41f902a17d3f3ec23c1976de5b 100644 (file)
@@ -389,6 +389,11 @@ void SVMCompiler::generate_svm_nodes(const set<ShaderNode*>& nodes, set<ShaderNo
                nodes_done = true;
 
                foreach(ShaderNode *node, nodes) {
+
+                       /* Detect if we have a blackbody converter, to prepare lookup table */
+                       if(node->has_converter_blackbody())
+                               current_shader->has_converter_blackbody = true;
+                       
                        if(done.find(node) == done.end()) {
                                bool inputs_done = true;
 
@@ -672,6 +677,7 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
        shader->has_surface_emission = false;
        shader->has_surface_transparent = false;
        shader->has_surface_bssrdf = false;
+       shader->has_converter_blackbody = false;
        shader->has_volume = false;
        shader->has_displacement = false;
 
index 9551fad2fac3dc8888220ecd910dc0fed4b2540f..01d903c457be96f487850b4d298b5b15ae53d824 100644 (file)
Binary files a/release/datafiles/splash.png and b/release/datafiles/splash.png differ
index c604d16829ce6a5106e895002102e33bd2a83707..8b58493fe3a4a1b8e404ee214d1610104aabbab8 100644 (file)
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
index af966fa106e87890034650e34a676587cc4f1fec..91090dc2c75dbd59a261281b8b792629c7113d21 100644 (file)
@@ -218,6 +218,7 @@ shader_node_categories = [
         NodeItem("ShaderNodeNormalMap"),
         NodeItem("ShaderNodeNormal"),
         NodeItem("ShaderNodeVectorCurve"),
+        NodeItem("ShaderNodeVectorTransform"),
         ]),
     ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
         NodeItem("ShaderNodeMath"),
@@ -226,7 +227,10 @@ shader_node_categories = [
         NodeItem("ShaderNodeVectorMath"),
         NodeItem("ShaderNodeSeparateRGB"),
         NodeItem("ShaderNodeCombineRGB"),
+        NodeItem("ShaderNodeSeparateHSV"),
+        NodeItem("ShaderNodeCombineHSV"),
         NodeItem("ShaderNodeWavelength"),
+        NodeItem("ShaderNodeBlackbody"),
         ]),
     ShaderNewNodeCategory("SH_NEW_SCRIPT", "Script", items=[
         NodeItem("ShaderNodeScript"),
index b43747ab33a4cd60c44339d309ed165dd59160b3..71f859cd766c78e448662e78b9534951b4a1daf1 100644 (file)
@@ -742,6 +742,10 @@ struct ShadeResult;
 #define SH_NODE_WIREFRAME                              178
 #define SH_NODE_BSDF_TOON                              179
 #define SH_NODE_WAVELENGTH                             180
+#define SH_NODE_BLACKBODY                              181
+#define SH_NODE_VECT_TRANSFORM                 182
+#define SH_NODE_SEPHSV                                 183
+#define SH_NODE_COMBHSV                                        184
 
 /* custom defines options for Material node */
 #define SH_NODE_MAT_DIFF   1
@@ -802,6 +806,9 @@ void            ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
 #define RRES_OUT_TRANSM_DIRECT         25
 #define RRES_OUT_TRANSM_INDIRECT       26
 #define RRES_OUT_TRANSM_COLOR          27
+#define RRES_OUT_SUBS_DIRECT           28
+#define RRES_OUT_SUBS_INDIRECT         29
+#define RRES_OUT_SUBS_COLOR                    30
 
 /* note: types are needed to restore callbacks, don't change values */
 #define CMP_NODE_VIEWER                201
index 84dfa70abfcb00d89b1dc5465128afd1d6aaec7b..5001aa01653e5b06dd75287db4bd448c50d3c387 100644 (file)
@@ -3406,6 +3406,7 @@ static void registerShaderNodes(void)
        register_node_type_sh_rgb();
        register_node_type_sh_wireframe();
        register_node_type_sh_wavelength();
+       register_node_type_sh_blackbody();
        register_node_type_sh_mix_rgb();
        register_node_type_sh_valtorgb();
        register_node_type_sh_rgbtobw();
@@ -3417,11 +3418,14 @@ static void registerShaderNodes(void)
        register_node_type_sh_curve_rgb();
        register_node_type_sh_math();
        register_node_type_sh_vect_math();
+       register_node_type_sh_vect_transform();
        register_node_type_sh_squeeze();
        register_node_type_sh_material_ext();
        register_node_type_sh_invert();
        register_node_type_sh_seprgb();
        register_node_type_sh_combrgb();
+       register_node_type_sh_sephsv();
+       register_node_type_sh_combhsv();
        register_node_type_sh_hue_sat();
 
        register_node_type_sh_attribute();
index 0dcae29bf7fa0f4f070b070139dd73441d802f4f..cf3c0454e6b0103ad61e65918241fceecae5ba06 100644 (file)
@@ -735,6 +735,13 @@ static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), Po
        uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
 }
 
+static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{ 
+       uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+       uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE);
+       uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
+}
+
 static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
        PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
@@ -975,6 +982,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
                case SH_NODE_VECT_MATH: 
                        ntype->uifunc = node_shader_buts_vect_math;
                        break; 
+               case SH_NODE_VECT_TRANSFORM: 
+                       ntype->uifunc = node_shader_buts_vect_transform;
+                       break; 
                case SH_NODE_GEOMETRY:
                        ntype->uifunc = node_shader_buts_geometry;
                        break;
index 2aee5b4846a4cdc7e1207795be13b7b2b7fddf08..5c2e000d24d2ddfbc0f4ab4d088a87299f5c9840 100644 (file)
@@ -2253,7 +2253,8 @@ void node_light_path(
        out float is_singular_ray,
        out float is_reflection_ray,
        out float is_transmission_ray,
-       out float ray_length)
+       out float ray_length,
+       out float ray_depth)
 {
        is_camera_ray = 1.0;
        is_shadow_ray = 0.0;
@@ -2263,6 +2264,7 @@ void node_light_path(
        is_reflection_ray = 0.0;
        is_transmission_ray = 0.0;
        ray_length = 1.0;
+       ray_depth = 0.0;
 }
 
 void node_light_falloff(float strength, float tsmooth, out float quadratic, out float linear, out float constant)
index 8a9a95a9935f4cf7cb2c7aae9c00d71fef081e19..780cc3718656dcb2205eab57146800b30211b351 100644 (file)
@@ -788,6 +788,12 @@ typedef struct NodeShaderAttribute {
        char name[64];
 } NodeShaderAttribute;
 
+typedef struct NodeShaderVectTransform {
+       int type;
+       int convert_from, convert_to;
+       int pad;
+} NodeShaderVectTransform;
+
 /* TEX_output */
 typedef struct TexNodeOutput {
        char name[64];
@@ -869,6 +875,18 @@ typedef struct NodeShaderNormalMap {
 #define SHD_GLOSSY_SHARP       1
 #define SHD_GLOSSY_GGX         2
 
+/* vector transform */
+#define SHD_VECT_TRANSFORM_TYPE_VECTOR 0
+#define SHD_VECT_TRANSFORM_TYPE_POINT  1
+
+#define SHD_VECT_TRANSFORM_FROM_WORLD  0
+#define SHD_VECT_TRANSFORM_FROM_OBJECT 1
+#define SHD_VECT_TRANSFORM_FROM_CAMERA 2
+
+#define SHD_VECT_TRANSFORM_TO_WORLD            0
+#define SHD_VECT_TRANSFORM_TO_OBJECT   1
+#define SHD_VECT_TRANSFORM_TO_CAMERA   2
+
 /* toon modes */
 #define SHD_TOON_DIFFUSE       0
 #define SHD_TOON_GLOSSY                1
index dd194ed389fa6b14f34a67ae262b7ae24cf0858a..5f1fc078adef1893577201275f8ed8f240c32ce6 100644 (file)
@@ -237,6 +237,9 @@ typedef struct SceneRenderLayer {
 #define SCE_PASS_TRANSM_DIRECT         (1<<25)
 #define SCE_PASS_TRANSM_INDIRECT       (1<<26)
 #define SCE_PASS_TRANSM_COLOR          (1<<27)
+#define SCE_PASS_SUBS_DIRECT           (1<<28)
+#define SCE_PASS_SUBS_INDIRECT         (1<<29)
+#define SCE_PASS_SUBS_COLOR                    (1<<30)
 
 /* note, srl->passflag is treestore element 'nr' in outliner, short still... */
 
index c06c0a39f1418b4531be2914064e7715bf65b0ad..4111617085c37e986e84c4fdc81ffb2e575e2317 100644 (file)
@@ -3509,6 +3509,48 @@ static void def_sh_tex_coord(StructRNA *srna)
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+static void def_sh_vect_transform(StructRNA *srna)
+{
+       static EnumPropertyItem prop_vect_type_items[] = {
+               {SHD_VECT_TRANSFORM_TYPE_VECTOR, "VECTOR",  0, "Vector",   ""},
+               {SHD_VECT_TRANSFORM_TYPE_POINT,  "POINT",   0, "Point",    ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       static EnumPropertyItem prop_vect_from_items[] = {
+               {SHD_VECT_TRANSFORM_FROM_WORLD,  "WORLD",   0, "World",    ""},
+               {SHD_VECT_TRANSFORM_FROM_OBJECT, "OBJECT",  0, "Object",   ""},
+               {SHD_VECT_TRANSFORM_FROM_CAMERA, "CAMERA",  0, "Camera",   ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       static EnumPropertyItem prop_vect_to_items[] = {
+               {SHD_VECT_TRANSFORM_TO_WORLD,  "WORLD",   0, "World",    ""},
+               {SHD_VECT_TRANSFORM_TO_OBJECT, "OBJECT",  0, "Object",   ""},
+               {SHD_VECT_TRANSFORM_TO_CAMERA, "CAMERA",  0, "Camera",   ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       PropertyRNA *prop;
+       
+       RNA_def_struct_sdna_from(srna, "NodeShaderVectTransform", "storage");
+       
+       prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_vect_type_items);
+       RNA_def_property_ui_text(prop, "Type", "");
+       RNA_def_property_update(prop, 0, "rna_Node_update");
+       
+       prop = RNA_def_property(srna, "convert_from", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_vect_from_items);
+       RNA_def_property_ui_text(prop, "Convert From", "Space to convert from");
+       RNA_def_property_update(prop, 0, "rna_Node_update");
+       
+       prop = RNA_def_property(srna, "convert_to", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_vect_to_items);
+       RNA_def_property_ui_text(prop, "Convert To", "Space to convert to");
+       RNA_def_property_update(prop, 0, "rna_Node_update");
+}
+
 static void def_sh_tex_wireframe(StructRNA *srna)
 {
        PropertyRNA *prop;
index 64b4e019c27a1a28b211d71079b6951939659472..fe3219ce599b620c51a01b37e50b4bafd5fc310e 100644 (file)
@@ -570,6 +570,9 @@ static void rna_def_render_pass(BlenderRNA *brna)
                {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
                {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
                {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
+               {SCE_PASS_SUBS_DIRECT, "SUBSURFACE_DIRECT", 0, "Subsurface Direct", ""},
+               {SCE_PASS_SUBS_INDIRECT, "SUBSURFACE_INDIRECT", 0, "Subsurface Indirect", ""},
+               {SCE_PASS_SUBS_COLOR, "SUBSURFACE_COLOR", 0, "Subsurface Color", ""},
                {0, NULL, 0, NULL, NULL}
        };
        
index a0e1e29ab55b32aefa3f56dccf339b3f1d93760e..1ad2bfb491a23858d2f173fc227e9b602e773278 100644 (file)
@@ -2555,6 +2555,24 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
        RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass");
        if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       
+       prop = RNA_def_property(srna, "use_pass_subsurface_direct", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBS_DIRECT);
+       RNA_def_property_ui_text(prop, "Subsurface Direct", "Deliver subsurface direct pass");
+       if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+       else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+       prop = RNA_def_property(srna, "use_pass_subsurface_indirect", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBS_INDIRECT);
+       RNA_def_property_ui_text(prop, "Subsurface Indirect", "Deliver subsurface indirect pass");
+       if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+       else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+       prop = RNA_def_property(srna, "use_pass_subsurface_color", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBS_COLOR);
+       RNA_def_property_ui_text(prop, "Subsurface Color", "Deliver subsurface color pass");
+       if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update");
+       else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 }
 
 static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
index cc1a5f8cee9a50679a48bdd4c2a0a7ce178b2f16..64261246e3d31c2b2cda94b9161325a4df439ac1 100644 (file)
@@ -140,13 +140,16 @@ set(SRC
        shader/nodes/node_shader_output.c
        shader/nodes/node_shader_rgb.c
        shader/nodes/node_shader_sepcombRGB.c
+       shader/nodes/node_shader_sepcombHSV.c
        shader/nodes/node_shader_squeeze.c
        shader/nodes/node_shader_texture.c
        shader/nodes/node_shader_valToRgb.c
        shader/nodes/node_shader_value.c
        shader/nodes/node_shader_wireframe.c
        shader/nodes/node_shader_wavelength.c
+       shader/nodes/node_shader_blackbody.c
        shader/nodes/node_shader_vectMath.c
+       shader/nodes/node_shader_vectTransform.c
        shader/nodes/node_shader_add_shader.c
        shader/nodes/node_shader_ambient_occlusion.c
        shader/nodes/node_shader_attribute.c
index edb0ba6f4759a203d45954628588f640738fbb5f..ec39d81618dd3d1f57f40e5376fd3d15005af13e 100644 (file)
@@ -70,6 +70,8 @@ void register_node_type_sh_material_ext(void);
 void register_node_type_sh_invert(void);
 void register_node_type_sh_seprgb(void);
 void register_node_type_sh_combrgb(void);
+void register_node_type_sh_sephsv(void);
+void register_node_type_sh_combhsv(void);
 void register_node_type_sh_hue_sat(void);
 void register_node_type_sh_tex_brick(void);
 
@@ -81,6 +83,7 @@ void register_node_type_sh_object_info(void);
 void register_node_type_sh_fresnel(void);
 void register_node_type_sh_wireframe(void);
 void register_node_type_sh_wavelength(void);
+void register_node_type_sh_blackbody(void);
 void register_node_type_sh_layer_weight(void);
 void register_node_type_sh_tex_coord(void);
 void register_node_type_sh_particle_info(void);
@@ -88,6 +91,7 @@ void register_node_type_sh_hair_info(void);
 void register_node_type_sh_script(void);
 void register_node_type_sh_normal_map(void);
 void register_node_type_sh_tangent(void);
+void register_node_type_sh_vect_transform(void);
 
 void register_node_type_sh_ambient_occlusion(void);
 void register_node_type_sh_background(void);
index 69f2a0ae95568e892783df072e923d0301241c29..0b526fcde0ec6be2df24f871afa18f0e6c6500d3 100644 (file)
@@ -97,6 +97,7 @@ DefNode( ShaderNode,     SH_NODE_PARTICLE_INFO,      0,                      "PA
 DefNode( ShaderNode,     SH_NODE_HAIR_INFO,          0,                      "HAIR_INFO",          HairInfo,         "Hair Info",         ""       )
 DefNode( ShaderNode,     SH_NODE_WIREFRAME,          def_sh_tex_wireframe,   "WIREFRAME",          Wireframe,        "Wireframe",         ""       )
 DefNode( ShaderNode,     SH_NODE_WAVELENGTH,         0,                      "WAVELENGTH",         Wavelength,       "Wavelength",        ""       )
+DefNode( ShaderNode,     SH_NODE_BLACKBODY,          0,                      "BLACKBODY",          Blackbody,        "Blackbody",         ""       )
 DefNode( ShaderNode,     SH_NODE_BUMP,               def_sh_bump,            "BUMP",               Bump,             "Bump",              ""       )
 DefNode( ShaderNode,     SH_NODE_NORMAL_MAP,         def_sh_normal_map,      "NORMAL_MAP",         NormalMap,        "Normal Map",        ""       )
 DefNode( ShaderNode,     SH_NODE_TANGENT,            def_sh_tangent,         "TANGENT",            Tangent,          "Tangent",           ""       )
@@ -113,6 +114,9 @@ DefNode( ShaderNode,     SH_NODE_TEX_VORONOI,        def_sh_tex_voronoi,     "TE
 DefNode( ShaderNode,     SH_NODE_TEX_CHECKER,        def_sh_tex_checker,     "TEX_CHECKER",        TexChecker,       "Checker Texture",   ""       )
 DefNode( ShaderNode,     SH_NODE_TEX_BRICK,          def_sh_tex_brick,       "TEX_BRICK",          TexBrick,         "Brick Texture",     ""       )
 DefNode( ShaderNode,     SH_NODE_TEX_COORD,          def_sh_tex_coord,       "TEX_COORD",          TexCoord,         "Texture Coordinate",""       )
+DefNode( ShaderNode,     SH_NODE_VECT_TRANSFORM,     def_sh_vect_transform,  "VECT_TRANSFORM",     VectorTransform,  "Vector Transform",  ""       )
+DefNode( ShaderNode,     SH_NODE_SEPHSV,             0,                      "SEPHSV",             SeparateHSV,      "Separate HSV",      ""       )
+DefNode( ShaderNode,     SH_NODE_COMBHSV,            0,                      "COMBHSV",            CombineHSV,       "Combine HSV",       ""       )
 
 DefNode( CompositorNode, CMP_NODE_VIEWER,         def_cmp_viewer,         "VIEWER",         Viewer,           "Viewer",            ""              )
 DefNode( CompositorNode, CMP_NODE_RGB,            0,                      "RGB",            RGB,              "RGB",               ""              )
index 0d68b999eb2a2c0c28af87ad618a250cab74d8e3..5c656352a3c61ad9779d51f0ef8296486da2e46b 100644 (file)
@@ -72,6 +72,9 @@ static bNodeSocketTemplate cmp_node_rlayers_out[] = {
        {       SOCK_RGBA, 0, N_("Transmission Direct"),        0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       SOCK_RGBA, 0, N_("Transmission Indirect"),      0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       SOCK_RGBA, 0, N_("Transmission Color"),         0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 0, N_("Subsurface Direct"),          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 0, N_("Subsurface Indirect"),        0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_RGBA, 0, N_("Subsurface Color"),           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       -1, 0, ""       }
 };
 
@@ -152,6 +155,13 @@ static void cmp_node_image_add_render_pass_outputs(bNodeTree *ntree, bNode *node
                cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_TRANSM_INDIRECT, RRES_OUT_TRANSM_INDIRECT);
        if (passflag & SCE_PASS_TRANSM_COLOR)
                cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_TRANSM_COLOR, RRES_OUT_TRANSM_COLOR);
+               
+       if (passflag & SCE_PASS_SUBS_DIRECT)
+               cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_SUBS_DIRECT, RRES_OUT_SUBS_DIRECT);
+       if (passflag & SCE_PASS_SUBS_INDIRECT)
+               cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_SUBS_INDIRECT, RRES_OUT_SUBS_INDIRECT);
+       if (passflag & SCE_PASS_SUBS_COLOR)
+               cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_SUBS_COLOR, RRES_OUT_SUBS_COLOR);
 }
 
 static void cmp_node_image_add_multilayer_outputs(bNodeTree *ntree, bNode *node, RenderLayer *rl)
@@ -414,6 +424,9 @@ void node_cmp_rlayers_force_hidden_passes(bNode *node)
        set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT,    SCE_PASS_TRANSM_DIRECT);
        set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT,  SCE_PASS_TRANSM_INDIRECT);
        set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR,     SCE_PASS_TRANSM_COLOR);
+       set_output_visible(node, passflag, RRES_OUT_SUBS_DIRECT,      SCE_PASS_SUBS_DIRECT);
+       set_output_visible(node, passflag, RRES_OUT_SUBS_INDIRECT,    SCE_PASS_SUBS_INDIRECT);
+       set_output_visible(node, passflag, RRES_OUT_SUBS_COLOR,       SCE_PASS_SUBS_COLOR);
 }
 
 static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)
diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
new file mode 100644 (file)
index 0000000..af89a95
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../node_shader_util.h"
+
+/* **************** Blackbody ******************** */
+static bNodeSocketTemplate sh_node_blackbody_in[] = {
+       {       SOCK_FLOAT, 1, N_("Temperature"),       1500.0f, 0.0f, 0.0f, 0.0f, 800.0f, 12000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_blackbody_out[] = {
+       {       SOCK_RGBA, 0, N_("Color")},
+       {       -1, 0, ""       }
+};
+
+/* node type definition */
+void register_node_type_sh_blackbody(void)
+{
+       static bNodeType ntype;
+
+       sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTOR, 0);
+       node_type_compatibility(&ntype, NODE_NEW_SHADING);
+       node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
+       node_type_socket_templates(&ntype, sh_node_blackbody_in, sh_node_blackbody_out);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+
+       nodeRegisterType(&ntype);
+}
index 63713eb1e020bd69c073b372b73e084f9a79c8a0..9d769b284b1e26d06ae534d49e944288571b400e 100644 (file)
@@ -38,6 +38,7 @@ static bNodeSocketTemplate sh_node_light_path_out[] = {
        {       SOCK_FLOAT, 0, N_("Is Reflection Ray"),         0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       SOCK_FLOAT, 0, N_("Is Transmission Ray"),       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       SOCK_FLOAT, 0, N_("Ray Length"),                        0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, N_("Ray Depth"),                         0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
        {       -1, 0, ""       }
 };
 
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
new file mode 100644 (file)
index 0000000..707e295
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/shader/nodes/node_shader_sepcombHSV.c
+ *  \ingroup shdnodes
+ */
+
+
+#include "node_shader_util.h"
+
+/* **************** SEPARATE HSV ******************** */
+static bNodeSocketTemplate sh_node_sephsv_in[] = {
+       {       SOCK_RGBA, 1, N_("Color"),                      0.8f, 0.8f, 0.8f, 1.0f},
+       {       -1, 0, ""       }
+};
+static bNodeSocketTemplate sh_node_sephsv_out[] = {
+       {       SOCK_FLOAT, 0, N_("H")},
+       {       SOCK_FLOAT, 0, N_("S")},
+       {       SOCK_FLOAT, 0, N_("V")},
+       {       -1, 0, ""       }
+};
+
+void register_node_type_sh_sephsv(void)
+{
+       static bNodeType ntype;
+
+       sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
+       node_type_compatibility(&ntype, NODE_NEW_SHADING);
+       node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
+
+       nodeRegisterType(&ntype);
+}
+
+
+/* **************** COMBINE HSV ******************** */
+static bNodeSocketTemplate sh_node_combhsv_in[] = {
+       {       SOCK_FLOAT, 1, N_("H"),                 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+       {       SOCK_FLOAT, 1, N_("S"),                 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+       {       SOCK_FLOAT, 1, N_("V"),                 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+       {       -1, 0, ""       }
+};
+static bNodeSocketTemplate sh_node_combhsv_out[] = {
+       {       SOCK_RGBA, 0, N_("Color")},
+       {       -1, 0, ""       }
+};
+
+void register_node_type_sh_combhsv(void)
+{
+       static bNodeType ntype;
+
+       sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
+       node_type_compatibility(&ntype, NODE_NEW_SHADING);
+       node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
+
+       nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
new file mode 100644 (file)
index 0000000..40c70b9
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/shader/nodes/node_shader_vectTransform.c
+ *  \ingroup shdnodes
+ */
+ #include "../node_shader_util.h"
+
+/* **************** Vector Transform ******************** */ 
+static bNodeSocketTemplate sh_node_vect_transform_in[] = {
+       { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+       { -1, 0, "" }
+};
+
+static bNodeSocketTemplate sh_node_vect_transform_out[] = {
+       { SOCK_VECTOR, 0, N_("Vector")},
+       { -1, 0, "" }
+};
+
+static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node)
+{
+       NodeShaderVectTransform *vect = MEM_callocN(sizeof(NodeShaderVectTransform), "NodeShaderVectTransform");
+       
+       /* Convert World into Object Space per default */
+       vect->convert_to = 1;
+       
+       node->storage = vect;
+}
+
+void register_node_type_sh_vect_transform(void)
+{
+       static bNodeType ntype;
+
+       sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_CONVERTOR, 0);
+       node_type_compatibility(&ntype, NODE_NEW_SHADING);
+       node_type_init(&ntype, node_shader_init_vect_transform);
+       node_type_socket_templates(&ntype, sh_node_vect_transform_in, sh_node_vect_transform_out);
+       node_type_storage(&ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage);
+
+       nodeRegisterType(&ntype);
+}
index f719e09769d32cd3f4fdef985ddef46b290b0ced..c5c85f665f0fb6f9b2c557d608f516b7190fbd80 100644 (file)
@@ -279,6 +279,24 @@ static const char *get_pass_name(int passtype, int channel)
                if (channel == 1) return "TransCol.G";
                return "TransCol.B";
        }
+       if (passtype == SCE_PASS_SUBS_DIRECT) {
+               if (channel == -1) return "SubsDir";
+               if (channel == 0) return "SubsDir.R";
+               if (channel == 1) return "SubsDir.G";
+               return "SubsDir.B";
+       }
+       if (passtype == SCE_PASS_SUBS_INDIRECT) {
+               if (channel == -1) return "SubsInd";
+               if (channel == 0) return "SubsInd.R";
+               if (channel == 1) return "SubsInd.G";
+               return "SubsInd.B";
+       }
+       if (passtype == SCE_PASS_SUBS_COLOR) {
+               if (channel == -1) return "SubsCol";
+               if (channel == 0) return "SubsCol.R";
+               if (channel == 1) return "SubsCol.G";
+               return "SubsCol.B";
+       }
        return "Unknown";
 }
 
@@ -368,6 +386,15 @@ static int passtype_from_name(const char *str)
 
        if (strcmp(str, "TransCol") == 0)
                return SCE_PASS_TRANSM_COLOR;
+               
+       if (strcmp(str, "SubsDir") == 0)
+               return SCE_PASS_SUBS_DIRECT;
+
+       if (strcmp(str, "SubsInd") == 0)
+               return SCE_PASS_SUBS_INDIRECT;
+
+       if (strcmp(str, "SubsCol") == 0)
+               return SCE_PASS_SUBS_COLOR;
 
        return 0;
 }
@@ -538,6 +565,12 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
                        render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_INDIRECT);
                if (srl->passflag  & SCE_PASS_TRANSM_COLOR)
                        render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_COLOR);
+               if (srl->passflag  & SCE_PASS_SUBS_DIRECT)
+                       render_layer_add_pass(rr, rl, 3, SCE_PASS_SUBS_DIRECT);
+               if (srl->passflag  & SCE_PASS_SUBS_INDIRECT)
+                       render_layer_add_pass(rr, rl, 3, SCE_PASS_SUBS_INDIRECT);
+               if (srl->passflag  & SCE_PASS_SUBS_COLOR)
+                       render_layer_add_pass(rr, rl, 3, SCE_PASS_SUBS_COLOR);
        }
        /* sss, previewrender and envmap don't do layers, so we make a default one */
        if (rr->layers.first == NULL && !(layername && layername[0])) {