diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-07 21:05:21 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | b0aa42e3970b1a68ee48748140bec9584c7c9437 (patch) | |
tree | 7a87786400f0f408ff6e4e62d9418fa20a5ce868 /intern | |
parent | 72fa68e73b69aca46925c6b0ef4ac0c35c065f3b (diff) |
Code refactor: nodify Cycles integrator.
Differential Revision: https://developer.blender.org/D2016
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 64 | ||||
-rw-r--r-- | intern/cycles/render/integrator.cpp | 129 | ||||
-rw-r--r-- | intern/cycles/render/integrator.h | 7 |
3 files changed, 66 insertions, 134 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index ab081a7edfe..c2636a0e8c5 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -20,6 +20,8 @@ #include <algorithm> #include <iterator> +#include "node_xml.h" + #include "background.h" #include "camera.h" #include "film.h" @@ -48,7 +50,7 @@ CCL_NAMESPACE_BEGIN /* XML reading state */ -struct XMLReadState { +struct XMLReadState : public XMLReader { Scene *scene; /* scene pointer */ Transform tfm; /* current transform state */ bool smooth; /* smooth normal state */ @@ -289,58 +291,6 @@ static void xml_read_film(const XMLReadState& state, pugi::xml_node node) xml_read_float(&film->filter_width, node, "filter_width"); } -/* Integrator */ - -static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) -{ - Integrator *integrator = state.scene->integrator; - - /* Branched Path */ - bool branched = false; - xml_read_bool(&branched, node, "branched"); - - if(branched) { - integrator->method = Integrator::BRANCHED_PATH; - - xml_read_int(&integrator->diffuse_samples, node, "diffuse_samples"); - xml_read_int(&integrator->glossy_samples, node, "glossy_samples"); - xml_read_int(&integrator->transmission_samples, node, "transmission_samples"); - xml_read_int(&integrator->ao_samples, node, "ao_samples"); - xml_read_int(&integrator->mesh_light_samples, node, "mesh_light_samples"); - xml_read_int(&integrator->subsurface_samples, node, "subsurface_samples"); - xml_read_int(&integrator->volume_samples, node, "volume_samples"); - xml_read_bool(&integrator->sample_all_lights_direct, node, "sample_all_lights_direct"); - xml_read_bool(&integrator->sample_all_lights_indirect, node, "sample_all_lights_indirect"); - } - - /* Bounces */ - xml_read_int(&integrator->min_bounce, node, "min_bounce"); - xml_read_int(&integrator->max_bounce, node, "max_bounce"); - - xml_read_int(&integrator->max_diffuse_bounce, node, "max_diffuse_bounce"); - xml_read_int(&integrator->max_glossy_bounce, node, "max_glossy_bounce"); - xml_read_int(&integrator->max_transmission_bounce, node, "max_transmission_bounce"); - xml_read_int(&integrator->max_volume_bounce, node, "max_volume_bounce"); - - /* Transparency */ - xml_read_int(&integrator->transparent_min_bounce, node, "transparent_min_bounce"); - xml_read_int(&integrator->transparent_max_bounce, node, "transparent_max_bounce"); - xml_read_bool(&integrator->transparent_shadows, node, "transparent_shadows"); - - /* Volume */ - xml_read_float(&integrator->volume_step_size, node, "volume_step_size"); - xml_read_int(&integrator->volume_max_steps, node, "volume_max_steps"); - - /* Various Settings */ - xml_read_bool(&integrator->caustics_reflective, node, "caustics_reflective"); - xml_read_bool(&integrator->caustics_refractive, node, "caustics_refractive"); - xml_read_float(&integrator->filter_glossy, node, "filter_glossy"); - - xml_read_int(&integrator->seed, node, "seed"); - xml_read_float(&integrator->sample_clamp_direct, node, "sample_clamp_direct"); - xml_read_float(&integrator->sample_clamp_indirect, node, "sample_clamp_indirect"); -} - /* Camera */ static void xml_read_camera(const XMLReadState& state, pugi::xml_node node) @@ -1229,16 +1179,16 @@ static void xml_read_state(XMLReadState& state, pugi::xml_node node) /* Scene */ -static void xml_read_include(const XMLReadState& state, const string& src); +static void xml_read_include(XMLReadState& state, const string& src); -static void xml_read_scene(const XMLReadState& state, pugi::xml_node scene_node) +static void xml_read_scene(XMLReadState& state, pugi::xml_node scene_node) { for(pugi::xml_node node = scene_node.first_child(); node; node = node.next_sibling()) { if(string_iequals(node.name(), "film")) { xml_read_film(state, node); } else if(string_iequals(node.name(), "integrator")) { - xml_read_integrator(state, node); + xml_read_node(state, state.scene->integrator, node); } else if(string_iequals(node.name(), "camera")) { xml_read_camera(state, node); @@ -1283,7 +1233,7 @@ static void xml_read_scene(const XMLReadState& state, pugi::xml_node scene_node) /* Include */ -static void xml_read_include(const XMLReadState& state, const string& src) +static void xml_read_include(XMLReadState& state, const string& src) { /* open XML document */ pugi::xml_document doc; diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index fd4f34c8990..a136e9ad76b 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -27,48 +27,62 @@ CCL_NAMESPACE_BEGIN -Integrator::Integrator() +NODE_DEFINE(Integrator) { - min_bounce = 2; - max_bounce = 7; - - max_diffuse_bounce = max_bounce; - max_glossy_bounce = max_bounce; - max_transmission_bounce = max_bounce; - max_volume_bounce = max_bounce; - - transparent_min_bounce = min_bounce; - transparent_max_bounce = max_bounce; - transparent_shadows = false; - - volume_max_steps = 1024; - volume_step_size = 0.1f; - - caustics_reflective = true; - caustics_refractive = true; - filter_glossy = 0.0f; - seed = 0; - layer_flag = ~0; - sample_clamp_direct = 0.0f; - sample_clamp_indirect = 0.0f; - motion_blur = false; - - aa_samples = 0; - diffuse_samples = 1; - glossy_samples = 1; - transmission_samples = 1; - ao_samples = 1; - mesh_light_samples = 1; - subsurface_samples = 1; - volume_samples = 1; - - sample_all_lights_direct = true; - sample_all_lights_indirect = true; - - method = PATH; - - sampling_pattern = SAMPLING_PATTERN_SOBOL; + NodeType *type = NodeType::add("integrator", create); + + SOCKET_INT(min_bounce, "Min Bounce", 2); + SOCKET_INT(max_bounce, "Max Bounce", 7); + + SOCKET_INT(max_diffuse_bounce, "Max Diffuse Bounce", 7); + SOCKET_INT(max_glossy_bounce, "Max Glossy Bounce", 7); + SOCKET_INT(max_transmission_bounce, "Max Transmission Bounce", 7); + SOCKET_INT(max_volume_bounce, "Max Volume Bounce", 7); + + SOCKET_INT(transparent_min_bounce, "Transparent Min Bounce", 2); + SOCKET_INT(transparent_max_bounce, "Transparent Max Bounce", 7); + SOCKET_BOOLEAN(transparent_shadows, "Transparent Shadows", false); + + SOCKET_INT(volume_max_steps, "Volume Max Steps", 1024); + SOCKET_FLOAT(volume_step_size, "Volume Step Size", 0.1f); + + SOCKET_BOOLEAN(caustics_reflective, "Reflective Caustics", true); + SOCKET_BOOLEAN(caustics_refractive, "Refractive Caustics", true); + SOCKET_FLOAT(filter_glossy, "Filter Glossy", 0.0f); + SOCKET_INT(seed, "Seed", 0); + SOCKET_INT(layer_flag, "Layer Flag", ~0); + SOCKET_FLOAT(sample_clamp_direct, "Sample Clamp Direct", 0.0f); + SOCKET_FLOAT(sample_clamp_indirect, "Sample Clamp Indirect", 0.0f); + SOCKET_BOOLEAN(motion_blur, "Motion Blur", false); + + SOCKET_INT(aa_samples, "AA Samples", 0); + SOCKET_INT(diffuse_samples, "Diffuse Samples", 1); + SOCKET_INT(glossy_samples, "Glossy Samples", 1); + SOCKET_INT(transmission_samples, "Transmission Samples", 1); + SOCKET_INT(ao_samples, "AO Samples", 1); + SOCKET_INT(mesh_light_samples, "Mesh Light Samples", 1); + SOCKET_INT(subsurface_samples, "Subsurface Samples", 1); + SOCKET_INT(volume_samples, "Volume Samples", 1); + + SOCKET_BOOLEAN(sample_all_lights_direct, "Sample All Lights Direct", true); + SOCKET_BOOLEAN(sample_all_lights_indirect, "Sample All Lights Indirect", true); + + static NodeEnum method_enum; + method_enum.insert("path", PATH); + method_enum.insert("branched_path", BRANCHED_PATH); + SOCKET_ENUM(method, "Method", method_enum, PATH); + + static NodeEnum sampling_pattern_enum; + sampling_pattern_enum.insert("sobol", SAMPLING_PATTERN_SOBOL); + sampling_pattern_enum.insert("cmj", SAMPLING_PATTERN_CMJ); + SOCKET_ENUM(sampling_pattern, "Sampling Pattern", sampling_pattern_enum, SAMPLING_PATTERN_SOBOL); + + return type; +} +Integrator::Integrator() +: Node(node_type) +{ need_update = true; } @@ -192,41 +206,6 @@ void Integrator::device_free(Device *device, DeviceScene *dscene) dscene->sobol_directions.clear(); } -bool Integrator::modified(const Integrator& integrator) -{ - return !(min_bounce == integrator.min_bounce && - max_bounce == integrator.max_bounce && - max_diffuse_bounce == integrator.max_diffuse_bounce && - max_glossy_bounce == integrator.max_glossy_bounce && - max_transmission_bounce == integrator.max_transmission_bounce && - max_volume_bounce == integrator.max_volume_bounce && - transparent_min_bounce == integrator.transparent_min_bounce && - transparent_max_bounce == integrator.transparent_max_bounce && - transparent_shadows == integrator.transparent_shadows && - volume_max_steps == integrator.volume_max_steps && - volume_step_size == integrator.volume_step_size && - caustics_reflective == integrator.caustics_reflective && - caustics_refractive == integrator.caustics_refractive && - filter_glossy == integrator.filter_glossy && - layer_flag == integrator.layer_flag && - seed == integrator.seed && - sample_clamp_direct == integrator.sample_clamp_direct && - sample_clamp_indirect == integrator.sample_clamp_indirect && - method == integrator.method && - aa_samples == integrator.aa_samples && - diffuse_samples == integrator.diffuse_samples && - glossy_samples == integrator.glossy_samples && - transmission_samples == integrator.transmission_samples && - ao_samples == integrator.ao_samples && - mesh_light_samples == integrator.mesh_light_samples && - subsurface_samples == integrator.subsurface_samples && - volume_samples == integrator.volume_samples && - motion_blur == integrator.motion_blur && - sampling_pattern == integrator.sampling_pattern && - sample_all_lights_direct == integrator.sample_all_lights_direct && - sample_all_lights_indirect == integrator.sample_all_lights_indirect); -} - void Integrator::tag_update(Scene *scene) { foreach(Shader *shader, scene->shaders) { diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h index bb4e9c7056f..7d2cda3e116 100644 --- a/intern/cycles/render/integrator.h +++ b/intern/cycles/render/integrator.h @@ -19,14 +19,18 @@ #include "kernel_types.h" +#include "node.h" + CCL_NAMESPACE_BEGIN class Device; class DeviceScene; class Scene; -class Integrator { +class Integrator : public Node { public: + NODE_DECLARE; + int min_bounce; int max_bounce; @@ -83,7 +87,6 @@ public: void device_update(Device *device, DeviceScene *dscene, Scene *scene); void device_free(Device *device, DeviceScene *dscene); - bool modified(const Integrator& integrator); void tag_update(Scene *scene); }; |