Merged revision(s) 57587-57670 from trunk/blender into soc-2013-dingto
authorThomas Dinges <blender@dingto.org>
Sun, 23 Jun 2013 18:04:13 +0000 (18:04 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 23 Jun 2013 18:04:13 +0000 (18:04 +0000)
44 files changed:
intern/cycles/blender/addon/ui.py
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_shader.h
intern/cycles/kernel/kernel_textures.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/shaders/CMakeLists.txt
intern/cycles/kernel/shaders/node_blackbody.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_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/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/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/makesdna/DNA_node_types.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/nodes/CMakeLists.txt
source/blender/nodes/NOD_shader.h
source/blender/nodes/NOD_static_types.h
source/blender/nodes/shader/nodes/node_shader_blackbody.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_vectTransform.c [new file with mode: 0644]

index 273b099a99d5dde7bea8857c25833e9dd8f6095f..f90881b9338a91f625332f905a6217a48d6b186b 100644 (file)
@@ -51,20 +51,17 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
 
         scene = context.scene
         cscene = scene.cycles
-        device_type = context.user_preferences.system.compute_device_type
 
         split = layout.split()
 
         col = split.column()
-        sub = col.column()
-        sub.active = (device_type == 'NONE' or cscene.device == 'CPU')
-        sub.prop(cscene, "progressive")
+        col.prop(cscene, "progressive")
 
         sub = col.column(align=True)
         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()
             col.label(text="Samples:")
             sub = col.column(align=True)
@@ -610,7 +607,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)
 
@@ -629,7 +625,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()
@@ -817,7 +813,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()
 
@@ -825,7 +820,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 923f9b1e726d2ed3a029f815fcac6ca7fbd4eef9..a1aeceeb2166193b0e4aabf95314538163d49a1d 100644 (file)
@@ -250,6 +250,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 +408,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 72ed1b84915b4ebf0289b2bc3e79891ad0e7d650..be5f0692dbde6e1cbdee5587a4d71683bdef8416 100644 (file)
@@ -385,7 +385,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use
        params.background = background;
 
        /* samples */
-       if(get_boolean(cscene, "progressive") == 0 && params.device.type == DEVICE_CPU) {
+       if(get_boolean(cscene, "progressive") == 0) {
                if(background) {
                        params.samples = get_int(cscene, "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 95df2e216081e02e357cf69cd96f68e76f9f37d7..e0e06683883e54a29bb58d75fd967b182eaa683a 100644 (file)
@@ -340,6 +340,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 6b0c9120bd9af0c081d41f5941582ab9cf89c079..b7ec9235d68cca2a81b0e038509a9f29b18dd2df 100644 (file)
@@ -1035,6 +1035,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..184aaecc9017fe4e2cecbbeab94fd6dda320c10d 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
@@ -104,6 +105,7 @@ set(SRC_SVM_HEADERS
        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 039981a031a4c0ecf4fcbd94d9d450ee23b756c1..ca4d878daa05553286d734b673fb1fa86f411348 100644 (file)
@@ -931,8 +931,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 3bd0d5c3561250177a759b21a82d953482a52674..348e8b8a5f1f1866e44781f612b1b4810560779e 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
 
@@ -807,6 +814,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 +829,7 @@ typedef struct KernelData {
        KernelBVH bvh;
        KernelCurves curve_kernel_data;
        KernelBSSRDF bssrdf;
+       KernelBLACKBODY blackbody;
 } KernelData;
 
 CCL_NAMESPACE_END
index f2beb3da9c03922beddceb2a4d750729d72f69d8..db20dd43ca747b7c70af9b1b357a43b1ebb63b33 100644 (file)
@@ -64,10 +64,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_vector_transform.osl b/intern/cycles/kernel/shaders/node_vector_transform.osl
new file mode 100644 (file)
index 0000000..ae0cb1c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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))
+{
+       /* OSL uses lower case variable names here */
+       string from = "world";
+       string to = "object";
+       
+       if (convert_from == "Object")
+               from = "object";
+       else if (convert_from == "Camera")
+               from = "camera";
+               
+       if (convert_to == "World")
+               to = "world";
+       else if (convert_to == "Camera")
+               to = "camera";
+       
+       if (type == "Vector") {
+               VectorOut = transform(from, to, VectorIn);
+       }
+       else if (type == "Point") {
+               point Point = point(VectorIn[0], VectorIn[1], VectorIn[2]);
+               VectorOut = transform(from, to, Point);
+       }
+}
+
index e5df880b5967f6ed0e7610f14b7b51f04dac3e4c..20dba59d2d0d917509055bd4e5a2518de833ecf5 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"
@@ -176,6 +177,7 @@ CCL_NAMESPACE_END
 #include "svm_voronoi.h"
 #include "svm_checker.h"
 #include "svm_brick.h"
+#include "svm_vector_transform.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -366,6 +368,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 +383,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..46b2f91
--- /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 (317*3+3) */
+               const int lookuptablesize = 954;
+               const float lookuptablesizef = 954.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 + 317.0f*1.0f)/lookuptablesizef;
+               float G = lookup_table_read(kg, lutval, blackbody_table_offset, lookuptablesize);
+               lutval = (t + 317.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);
+
+               /* Luminance */
+               float l = linear_rgb_to_gray(make_float3(R, G, B));
+
+               color_rgb = make_float3(R, G, B);
+               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 e5b3e2b972f4773de09cdb8ad2fd788811d943b1..9d9cb71f0f9ce48461c4a243ff3100064437fe7e 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,
@@ -225,6 +227,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..b3268ba
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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;
+       
+       float3 out = make_float3(0.0f, 0.0f, 0.0f);
+       
+       decode_node_uchar4(node.y, &itype, &ifrom, &ito, NULL);
+       decode_node_uchar4(node.z, &vector_in, &vector_out, NULL, NULL);
+       
+       NodeVectorTransformType type = (NodeVectorTransformType)itype;
+       NodeVectorTransformConvertFrom from = (NodeVectorTransformConvertFrom)ifrom;
+       NodeVectorTransformConvertTo to = (NodeVectorTransformConvertTo)ito;
+       
+       float3 vec_in = stack_load_float3(stack, vector_in);
+       
+       if(stack_valid(vector_out))
+               stack_store_float3(stack, vector_out, out);
+}
+
+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..75b515a
--- /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 (317 entries) */
+       vector<float> blackbody_table(317*3+3);
+
+       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+317*1] = col.y;
+               blackbody_table[i+317*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 5c4a44af3fc0cbe8cc92c28f70ee1fff7f47c7f4..4d1d45ee924962b24aa52e28ae40082acc874e74 100644 (file)
@@ -188,6 +188,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 3672b89382526fef2d64fb62f584c2537cc920df..038b9c24b8a4f59bf99ab9971407520d001f9e1f 100644 (file)
@@ -2983,6 +2983,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()
@@ -3135,6 +3159,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 f19e07429067db1882780bc77d7566b4485f50e8..7290465739080a485855278c765981a54d176248 100644 (file)
@@ -462,6 +462,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 +494,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 545a765cc22be94d9097115a1c7075374f413c6f..be50279ba741a6437d1ceaf09973a2ae9e53655b 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 da6c3566f6990dca8cc6814a438cfa69b5bf3640..76b5b2baaa62b2dcb932de6d4113f5fe95738d86 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "bssrdf.h"
+#include "blackbody.h"
 #include "device.h"
 #include "graph.h"
 #include "light.h"
@@ -50,6 +51,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;
 
@@ -126,6 +128,7 @@ ShaderManager::ShaderManager()
 {
        need_update = true;
        bssrdf_table_offset = TABLE_OFFSET_INVALID;
+       blackbody_table_offset = TABLE_OFFSET_INVALID;
 }
 
 ShaderManager::~ShaderManager()
@@ -217,6 +220,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;
@@ -231,6 +235,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;
@@ -256,6 +262,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)
@@ -265,6 +286,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 c604d16829ce6a5106e895002102e33bd2a83707..e7177159fae6e18edebabcb49aecd633b843b404 100644 (file)
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
index fe9e06301f3fa5ffe0c628c9f51825f7cefd7074..8bf7cbf2696062fb9dc017e3c8e00f0d05711a50 100644 (file)
@@ -210,6 +210,7 @@ shader_node_categories = [
         NodeItem("ShaderNodeNormalMap"),
         NodeItem("ShaderNodeNormal"),
         NodeItem("ShaderNodeVectorCurve"),
+        NodeItem("ShaderNodeVectorTransform"),
         ]),
     ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
         NodeItem("ShaderNodeMath"),
@@ -219,6 +220,7 @@ shader_node_categories = [
         NodeItem("ShaderNodeSeparateRGB"),
         NodeItem("ShaderNodeCombineRGB"),
         NodeItem("ShaderNodeWavelength"),
+        NodeItem("ShaderNodeBlackbody"),
         ]),
     ShaderNewNodeCategory("SH_NEW_SCRIPT", "Script", items=[
         NodeItem("ShaderNodeScript"),
index b43747ab33a4cd60c44339d309ed165dd59160b3..5f84450045f051a5a4e4e5d806b6c9775065f57d 100644 (file)
@@ -742,6 +742,8 @@ 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
 
 /* custom defines options for Material node */
 #define SH_NODE_MAT_DIFF   1
index 152d74f2ad6523fb97aff7aba99ae12bfd3028d4..14be1cef8cc6f9103b8354a1b19864cd85e0eaa2 100644 (file)
@@ -3407,6 +3407,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();
@@ -3418,6 +3419,7 @@ 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();
index d39695f54b7e4b93e64a7c8c300cf7ed2e755e66..82104d2c83792ee40922d1a117528eb8e51d3177 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");
@@ -969,6 +976,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 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 bc3984e2a0d3bdd4a2fe8ab6642e3a60b995b93f..5d77f7d13904604acd851619ada28a2f14ea12cc 100644 (file)
@@ -3482,6 +3482,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 cc1a5f8cee9a50679a48bdd4c2a0a7ce178b2f16..3241f98ad1eda396174a6dab9de8399747a0f47b 100644 (file)
@@ -146,7 +146,9 @@ set(SRC
        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..a8c77a9baed54ba6408a8f1b8f1d41c89729ce94 100644 (file)
@@ -81,6 +81,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 +89,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 8e3896f40f79920f9a7d66bba3c948052ae5fb10..f94e6fc9f5271b9bc380b33a2a6c0f52e067d3ee 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,7 @@ 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( CompositorNode, CMP_NODE_VIEWER,         def_cmp_viewer,         "VIEWER",         Viewer,           "Viewer",            ""              )
 DefNode( CompositorNode, CMP_NODE_RGB,            0,                      "RGB",            RGB,              "RGB",               ""              )
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);
+}
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);
+}