diff options
Diffstat (limited to 'intern/cycles/app')
-rw-r--r-- | intern/cycles/app/cycles_server.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/app/cycles_standalone.cpp | 28 | ||||
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 126 |
3 files changed, 130 insertions, 27 deletions
diff --git a/intern/cycles/app/cycles_server.cpp b/intern/cycles/app/cycles_server.cpp index 3d5b237eec1..4ef9cd070bb 100644 --- a/intern/cycles/app/cycles_server.cpp +++ b/intern/cycles/app/cycles_server.cpp @@ -24,6 +24,7 @@ #include "util_stats.h" #include "util_string.h" #include "util_task.h" +#include "util_logging.h" using namespace ccl; @@ -66,7 +67,7 @@ int main(int argc, const char **argv) exit(EXIT_FAILURE); } - if (debug) { + if(debug) { util_logging_start(); util_logging_verbosity_set(verbosity); } diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 42c339f56e5..b0d49d6ee72 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -21,6 +21,7 @@ #include "device.h" #include "scene.h" #include "session.h" +#include "integrator.h" #include "util_args.h" #include "util_foreach.h" @@ -124,7 +125,7 @@ static void scene_init() xml_read_file(options.scene, options.filepath.c_str()); /* Camera width/height override? */ - if (!(options.width == 0 || options.height == 0)) { + if(!(options.width == 0 || options.height == 0)) { options.scene->camera->width = options.width; options.scene->camera->height = options.height; } @@ -272,6 +273,7 @@ static void keyboard(unsigned char key) else if(key == 'i') options.interactive = !(options.interactive); + /* Navigation */ else if(options.interactive && (key == 'w' || key == 'a' || key == 's' || key == 'd')) { Transform matrix = options.session->scene->camera->matrix; float3 translate; @@ -294,6 +296,25 @@ static void keyboard(unsigned char key) options.session->reset(session_buffer_params(), options.session_params.samples); } + + /* Set Max Bounces */ + else if(options.interactive && (key == '0' || key == '1' || key == '2' || key == '3')) { + int bounce; + switch(key) { + case '0': bounce = 0; break; + case '1': bounce = 1; break; + case '2': bounce = 2; break; + case '3': bounce = 3; break; + default: bounce = 0; break; + } + + options.session->scene->integrator->max_bounce = bounce; + + /* Update and Reset */ + options.session->scene->integrator->need_update = true; + + options.session->reset(session_buffer_params(), options.session_params.samples); + } } #endif @@ -367,7 +388,7 @@ static void options_parse(int argc, const char **argv) exit(EXIT_FAILURE); } - if (debug) { + if(debug) { util_logging_start(); util_logging_verbosity_set(verbosity); } @@ -377,7 +398,8 @@ static void options_parse(int argc, const char **argv) printf("Devices:\n"); foreach(DeviceInfo& info, devices) { - printf(" %s%s\n", + printf(" %-10s%s%s\n", + Device::string_from_type(info.type).c_str(), info.description.c_str(), (info.display_device)? " (display)": ""); } diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 05e34387eb7..edea8cd0ec4 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -20,6 +20,7 @@ #include <algorithm> #include <iterator> +#include "background.h" #include "camera.h" #include "film.h" #include "graph.h" @@ -55,6 +56,16 @@ struct XMLReadState { string base; /* base path to current file*/ float dicing_rate; /* current dicing rate */ Mesh::DisplacementMethod displacement_method; + + XMLReadState() + : scene(NULL), + smooth(false), + shader(0), + dicing_rate(0.0f), + displacement_method(Mesh::DISPLACE_BUMP) + { + tfm = transform_identity(); + } }; /* Attribute Reading */ @@ -225,21 +236,21 @@ static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *na if(attr) { string value = attr.value(); - if (string_iequals(value, "float")) + if(string_iequals(value, "float")) return SHADER_SOCKET_FLOAT; - else if (string_iequals(value, "int")) + else if(string_iequals(value, "int")) return SHADER_SOCKET_INT; - else if (string_iequals(value, "color")) + else if(string_iequals(value, "color")) return SHADER_SOCKET_COLOR; - else if (string_iequals(value, "vector")) + else if(string_iequals(value, "vector")) return SHADER_SOCKET_VECTOR; - else if (string_iequals(value, "point")) + else if(string_iequals(value, "point")) return SHADER_SOCKET_POINT; - else if (string_iequals(value, "normal")) + else if(string_iequals(value, "normal")) return SHADER_SOCKET_NORMAL; - else if (string_iequals(value, "closure color")) + else if(string_iequals(value, "closure color")) return SHADER_SOCKET_CLOSURE; - else if (string_iequals(value, "string")) + else if(string_iequals(value, "string")) return SHADER_SOCKET_STRING; else fprintf(stderr, "Unknown shader socket type \"%s\" for attribute \"%s\".\n", value.c_str(), name); @@ -381,6 +392,10 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug for(pugi::xml_node node = graph_node.first_child(); node; node = node.next_sibling()) { ShaderNode *snode = NULL; + /* ToDo: Add missing nodes + * RGBCurvesNode, VectorCurvesNode, RGBRampNode and ConvertNode (RGB -> BW). + */ + if(string_iequals(node.name(), "image_texture")) { ImageTextureNode *img = new ImageTextureNode(); @@ -391,6 +406,8 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug xml_read_enum(&img->projection, ImageTextureNode::projection_enum, node, "projection"); xml_read_float(&img->projection_blend, node, "projection_blend"); + /* ToDo: Interpolation */ + snode = img; } else if(string_iequals(node.name(), "environment_texture")) { @@ -419,25 +436,25 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug * Socket names must be stored in the extra lists instead. */ /* read input values */ for(pugi::xml_node param = node.first_child(); param; param = param.next_sibling()) { - if (string_iequals(param.name(), "input")) { + if(string_iequals(param.name(), "input")) { string name; - if (!xml_read_string(&name, param, "name")) + if(!xml_read_string(&name, param, "name")) continue; ShaderSocketType type = xml_read_socket_type(param, "type"); - if (type == SHADER_SOCKET_UNDEFINED) + if(type == SHADER_SOCKET_UNDEFINED) continue; osl->input_names.push_back(ustring(name)); osl->add_input(osl->input_names.back().c_str(), type); } - else if (string_iequals(param.name(), "output")) { + else if(string_iequals(param.name(), "output")) { string name; - if (!xml_read_string(&name, param, "name")) + if(!xml_read_string(&name, param, "name")) continue; ShaderSocketType type = xml_read_socket_type(param, "type"); - if (type == SHADER_SOCKET_UNDEFINED) + if(type == SHADER_SOCKET_UNDEFINED) continue; osl->output_names.push_back(ustring(name)); @@ -493,10 +510,6 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug xml_read_int(&magic->depth, node, "depth"); snode = magic; } - else if(string_iequals(node.name(), "noise_texture")) { - NoiseTextureNode *dist = new NoiseTextureNode(); - snode = dist; - } else if(string_iequals(node.name(), "wave_texture")) { WaveTextureNode *wave = new WaveTextureNode(); xml_read_enum(&wave->type, WaveTextureNode::type_enum, node, "type"); @@ -507,6 +520,11 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug xml_read_float3(&normal->direction, node, "direction"); snode = normal; } + else if(string_iequals(node.name(), "bump")) { + BumpNode *bump = new BumpNode(); + xml_read_bool(&bump->invert, node, "invert"); + snode = bump; + } else if(string_iequals(node.name(), "mapping")) { snode = new MappingNode(); } @@ -561,6 +579,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug else if(string_iequals(node.name(), "background")) { snode = new BackgroundNode(); } + else if(string_iequals(node.name(), "holdout")) { + snode = new HoldoutNode(); + } else if(string_iequals(node.name(), "absorption_volume")) { snode = new AbsorptionVolumeNode(); } @@ -569,7 +590,14 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug } else if(string_iequals(node.name(), "subsurface_scattering")) { SubsurfaceScatteringNode *sss = new SubsurfaceScatteringNode(); - //xml_read_enum(&sss->falloff, SubsurfaceScatteringNode::falloff_enum, node, "falloff"); + + string falloff; + xml_read_string(&falloff, node, "falloff"); + if(falloff == "cubic") + sss->closure = CLOSURE_BSSRDF_CUBIC_ID; + else + sss->closure = CLOSURE_BSSRDF_GAUSSIAN_ID; + snode = sss; } else if(string_iequals(node.name(), "geometry")) { @@ -613,6 +641,7 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug snode = new InvertNode(); } else if(string_iequals(node.name(), "mix")) { + /* ToDo: Tag Mix case for optimization */ MixNode *mix = new MixNode(); xml_read_enum(&mix->type, MixNode::type_enum, node, "type"); xml_read_bool(&mix->use_clamp, node, "use_clamp"); @@ -637,10 +666,10 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug snode = new SeparateHSVNode(); } else if(string_iequals(node.name(), "combine_xyz")) { - snode = new CombineHSVNode(); + snode = new CombineXYZNode(); } else if(string_iequals(node.name(), "separate_xyz")) { - snode = new SeparateHSVNode(); + snode = new SeparateXYZNode(); } else if(string_iequals(node.name(), "hsv")) { snode = new HSVNode(); @@ -822,6 +851,15 @@ static void xml_read_shader(const XMLReadState& state, pugi::xml_node node) static void xml_read_background(const XMLReadState& state, pugi::xml_node node) { + /* Background Settings */ + Background *bg = state.scene->background; + + xml_read_float(&bg->ao_distance, node, "ao_distance"); + xml_read_float(&bg->ao_factor, node, "ao_factor"); + + xml_read_bool(&bg->transparent, node, "transparent"); + + /* Background Shader */ Shader *shader = state.scene->shaders[state.scene->default_background]; xml_read_bool(&shader->heterogeneous_volume, node, "heterogeneous_volume"); @@ -868,6 +906,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node) /* read vertices and polygons, RIB style */ vector<float3> P; + vector<float> UV; vector<int> verts, nverts; xml_read_float3_array(P, node, "P"); @@ -939,6 +978,31 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node) index_offset += nverts[i]; } + + if(xml_read_float_array(UV, node, "UV")) { + ustring name = ustring("UVMap"); + Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name); + float3 *fdata = attr->data_float3(); + + /* loop over the triangles */ + index_offset = 0; + for(size_t i = 0; i < nverts.size(); i++) { + for(int j = 0; j < nverts[i]-2; j++) { + int v0 = verts[index_offset]; + int v1 = verts[index_offset + j + 1]; + int v2 = verts[index_offset + j + 2]; + + assert(v0*2+1 < (int)UV.size()); + assert(v1*2+1 < (int)UV.size()); + assert(v2*2+1 < (int)UV.size()); + + fdata[0] = make_float3(UV[v0*2], UV[v0*2+1], 0.0); + fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0); + fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0); + fdata += 3; + } + } + } } /* temporary for test compatibility */ @@ -1028,13 +1092,28 @@ static void xml_read_light(const XMLReadState& state, pugi::xml_node node) xml_read_float(&light->sizev, node, "sizev"); xml_read_float3(&light->axisu, node, "axisu"); xml_read_float3(&light->axisv, node, "axisv"); - + + /* Portal? (Area light only) */ + xml_read_bool(&light->is_portal, node, "is_portal"); + /* Generic */ xml_read_float(&light->size, node, "size"); xml_read_float3(&light->dir, node, "dir"); xml_read_float3(&light->co, node, "P"); light->co = transform_point(&state.tfm, light->co); + /* Settings */ + xml_read_bool(&light->cast_shadow, node, "cast_shadow"); + xml_read_bool(&light->use_mis, node, "use_mis"); + xml_read_int(&light->samples, node, "samples"); + xml_read_int(&light->max_bounces, node, "max_bounces"); + + /* Ray Visibility */ + xml_read_bool(&light->use_diffuse, node, "use_diffuse"); + xml_read_bool(&light->use_glossy, node, "use_glossy"); + xml_read_bool(&light->use_transmission, node, "use_transmission"); + xml_read_bool(&light->use_scatter, node, "use_scatter"); + state.scene->lights.push_back(light); } @@ -1178,7 +1257,8 @@ static void xml_read_include(const XMLReadState& state, const string& src) XMLReadState substate = state; substate.base = path_dirname(path); - xml_read_scene(substate, doc); + pugi::xml_node cycles = doc.child("cycles"); + xml_read_scene(substate, cycles); } else { fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description()); |