diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-08 01:18:32 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | 8708eee988cffaaaac0357efce3590da7ef76053 (patch) | |
tree | 14dd4c0b72abe091fd8a218b7fe304dcf804cf6d /intern/cycles/render | |
parent | d8e0651c91099a657aea20e3bfc087e228406237 (diff) |
Code refactor: nodify Cycles shader and lights.
Differential Revision: https://developer.blender.org/D2016
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/background.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/render/background.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 61 | ||||
-rw-r--r-- | intern/cycles/render/light.h | 8 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 30 | ||||
-rw-r--r-- | intern/cycles/render/shader.h | 8 |
6 files changed, 75 insertions, 37 deletions
diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp index 28ca04fe615..6f8d1d1d461 100644 --- a/intern/cycles/render/background.cpp +++ b/intern/cycles/render/background.cpp @@ -40,13 +40,14 @@ NODE_DEFINE(Background) SOCKET_INT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY); SOCKET_BOOLEAN(transparent, "Transparent", false); + SOCKET_NODE(shader, "Shader", &Shader::node_type); + return type; } Background::Background() : Node(node_type) { - shader = NULL; need_update = true; } diff --git a/intern/cycles/render/background.h b/intern/cycles/render/background.h index ae2ffe2b078..843655b00a1 100644 --- a/intern/cycles/render/background.h +++ b/intern/cycles/render/background.h @@ -25,8 +25,8 @@ CCL_NAMESPACE_BEGIN class Device; class DeviceScene; -class Shader; class Scene; +class Shader; class Background : public Node { public: diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 91a9f22276f..c20bf6b5e9e 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -100,38 +100,53 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res /* Light */ -Light::Light() +NODE_DEFINE(Light) { - type = LIGHT_POINT; + NodeType* type = NodeType::add("light", create); + + static NodeEnum type_enum; + type_enum.insert("point", LIGHT_POINT); + type_enum.insert("background", LIGHT_BACKGROUND); + type_enum.insert("area", LIGHT_AREA); + type_enum.insert("spot", LIGHT_SPOT); + SOCKET_ENUM(type, "Type", type_enum, LIGHT_POINT); + + SOCKET_POINT(co, "Co", make_float3(0.0f, 0.0f, 0.0f)); + + SOCKET_VECTOR(dir, "Dir", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_FLOAT(size, "Size", 0.0f); - co = make_float3(0.0f, 0.0f, 0.0f); + SOCKET_VECTOR(axisu, "Axis U", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_FLOAT(sizeu, "Size U", 1.0f); + SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f)); + SOCKET_FLOAT(sizev, "Size V", 1.0f); - dir = make_float3(0.0f, 0.0f, 0.0f); - size = 0.0f; + SOCKET_INT(map_resolution, "Map Resolution", 512); - axisu = make_float3(0.0f, 0.0f, 0.0f); - sizeu = 1.0f; - axisv = make_float3(0.0f, 0.0f, 0.0f); - sizev = 1.0f; + SOCKET_FLOAT(spot_angle, "Spot Angle", M_PI_4_F); + SOCKET_FLOAT(spot_smooth, "Spot Smooth", 0.0f); - map_resolution = 512; + SOCKET_BOOLEAN(cast_shadow, "Cast Shadow", true); + SOCKET_BOOLEAN(use_mis, "Use Mis", false); + SOCKET_BOOLEAN(use_diffuse, "Use Diffuse", true); + SOCKET_BOOLEAN(use_glossy, "Use Glossy", true); + SOCKET_BOOLEAN(use_transmission, "Use Transmission", true); + SOCKET_BOOLEAN(use_scatter, "Use Scatter", true); - spot_angle = M_PI_4_F; - spot_smooth = 0.0f; + SOCKET_INT(samples, "Samples", 1); + SOCKET_INT(max_bounces, "Max Bounces", 1024); - cast_shadow = true; - use_mis = false; - use_diffuse = true; - use_glossy = true; - use_transmission = true; - use_scatter = true; + SOCKET_BOOLEAN(is_portal, "Is Portal", false); + SOCKET_BOOLEAN(is_enabled, "Is Enabled", true); - shader = NULL; - samples = 1; - max_bounces = 1024; + SOCKET_NODE(shader, "Shader", &Shader::node_type); - is_portal = false; - is_enabled = true; + return type; +} + +Light::Light() +: Node(node_type) +{ } void Light::tag_update(Scene *scene) diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h index 24ca0157eba..2f1df1c9417 100644 --- a/intern/cycles/render/light.h +++ b/intern/cycles/render/light.h @@ -19,6 +19,8 @@ #include "kernel_types.h" +#include "node.h" + #include "util_types.h" #include "util_vector.h" @@ -27,11 +29,13 @@ CCL_NAMESPACE_BEGIN class Device; class DeviceScene; class Progress; -class Shader; class Scene; +class Shader; -class Light { +class Light : public Node { public: + NODE_DECLARE; + Light(); LightType type; diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 1453958a0aa..b140af66b5b 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -131,20 +131,36 @@ static void beckmann_table_build(vector<float>& table) /* Shader */ +NODE_DEFINE(Shader) +{ + NodeType* type = NodeType::add("shader", create); + + SOCKET_BOOLEAN(use_mis, "Use MIS", true); + SOCKET_BOOLEAN(use_transparent_shadow, "Use Transparent Shadow", true); + SOCKET_BOOLEAN(heterogeneous_volume, "Heterogeneous Volume", true); + + static NodeEnum volume_sampling_method_enum; + volume_sampling_method_enum.insert("distance", VOLUME_SAMPLING_DISTANCE); + volume_sampling_method_enum.insert("equiangular", VOLUME_SAMPLING_EQUIANGULAR); + volume_sampling_method_enum.insert("multiple_importance", VOLUME_SAMPLING_MULTIPLE_IMPORTANCE); + SOCKET_ENUM(volume_sampling_method, "Volume Sampling Method", volume_sampling_method_enum, VOLUME_SAMPLING_DISTANCE); + + static NodeEnum volume_interpolation_method_enum; + volume_interpolation_method_enum.insert("linear", VOLUME_INTERPOLATION_LINEAR); + volume_interpolation_method_enum.insert("cubic", VOLUME_INTERPOLATION_CUBIC); + SOCKET_ENUM(volume_interpolation_method, "Volume Interpolation Method", volume_interpolation_method_enum, VOLUME_INTERPOLATION_LINEAR); + + return type; +} + Shader::Shader() +: Node(node_type) { - name = ""; pass_id = 0; graph = NULL; graph_bump = NULL; - use_mis = true; - use_transparent_shadow = true; - heterogeneous_volume = true; - volume_sampling_method = VOLUME_SAMPLING_DISTANCE; - volume_interpolation_method = VOLUME_INTERPOLATION_LINEAR; - has_surface = false; has_surface_transparent = false; has_surface_emission = false; diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 4a1502cb86d..dc57ed4e4eb 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -26,6 +26,8 @@ #include "attribute.h" #include "kernel_types.h" +#include "node.h" + #include "util_map.h" #include "util_param.h" #include "util_string.h" @@ -70,10 +72,10 @@ enum VolumeInterpolation { * volume and displacement, that the shader manager will compile and execute * separately. */ -class Shader { +class Shader : public Node { public: - /* name */ - string name; + NODE_DECLARE; + int pass_id; /* shader graph */ |