diff options
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/camera.cpp | 35 | ||||
-rw-r--r-- | intern/cycles/render/camera.h | 14 | ||||
-rw-r--r-- | intern/cycles/render/film.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/render/graph.cpp | 23 | ||||
-rw-r--r-- | intern/cycles/render/image.cpp | 9 | ||||
-rw-r--r-- | intern/cycles/render/image.h | 7 | ||||
-rw-r--r-- | intern/cycles/render/integrator.cpp | 1 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh_displace.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 61 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/render/svm.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/tile.cpp | 2 |
14 files changed, 126 insertions, 57 deletions
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index df2a1d348d6..88ff7fbb70a 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -29,6 +29,7 @@ CCL_NAMESPACE_BEGIN Camera::Camera() { shuttertime = 1.0f; + motion_position = MOTION_POSITION_CENTER; aperturesize = 0.0f; focaldistance = 10.0f; @@ -53,6 +54,7 @@ Camera::Camera() longitude_min = -M_PI_F; longitude_max = M_PI_F; fov = M_PI_4_F; + fov_pre = fov_post = fov; sensorwidth = 0.036f; sensorheight = 0.024f; @@ -91,19 +93,26 @@ Camera::~Camera() void Camera::compute_auto_viewplane() { - float aspect = (float)width/(float)height; - - if(width >= height) { - viewplane.left = -aspect; - viewplane.right = aspect; - viewplane.bottom = -1.0f; + if(type == CAMERA_PANORAMA) { + viewplane.left = 0.0f; + viewplane.right = 1.0f; + viewplane.bottom = 0.0f; viewplane.top = 1.0f; } else { - viewplane.left = -1.0f; - viewplane.right = 1.0f; - viewplane.bottom = -1.0f/aspect; - viewplane.top = 1.0f/aspect; + float aspect = (float)width/(float)height; + if(width >= height) { + viewplane.left = -aspect; + viewplane.right = aspect; + viewplane.bottom = -1.0f; + viewplane.top = 1.0f; + } + else { + viewplane.left = -1.0f; + viewplane.right = 1.0f; + viewplane.bottom = -1.0f/aspect; + viewplane.top = 1.0f/aspect; + } } } @@ -417,9 +426,9 @@ BoundBox Camera::viewplane_bounds_get() BoundBox bounds = BoundBox::empty; if(type == CAMERA_PANORAMA) { - bounds.grow(make_float3(cameratoworld.w.x, - cameratoworld.w.y, - cameratoworld.w.z)); + bounds.grow(make_float3(cameratoworld.x.w, + cameratoworld.y.w, + cameratoworld.z.w)); } else { bounds.grow(transform_raster_to_world(0.0f, 0.0f)); diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index 1bedb051112..53bd4f0bc14 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -32,12 +32,24 @@ class Scene; /* Camera * * The camera parameters are quite standard, tested to be both compatible with - * Renderman, and Blender after remapping. */ + * Renderman, and Blender after remapping. + */ class Camera { public: + /* Specifies an offset for the shutter's time interval. */ + enum MotionPosition { + /* Shutter opens at the current frame. */ + MOTION_POSITION_START, + /* Shutter is fully open at the current frame. */ + MOTION_POSITION_CENTER, + /* Shutter closes at the current frame. */ + MOTION_POSITION_END, + }; + /* motion blur */ float shuttertime; + MotionPosition motion_position; /* depth of field */ float focaldistance; diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 7282b04a22e..58080289633 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -144,7 +144,13 @@ void Pass::add(PassType type, vector<Pass>& passes) pass.exposure = false; break; case PASS_LIGHT: - /* ignores */ + /* This isn't a real pass, used by baking to see whether + * light data is needed or not. + * + * Set components to 0 so pass sort below happens in a + * determined way. + */ + pass.components = 0; break; #ifdef WITH_CYCLES_DEBUG case PASS_BVH_TRAVERSAL_STEPS: diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index e0537101247..f5ff091623b 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -336,6 +336,8 @@ void ShaderGraph::remove_unneeded_nodes() vector<bool> removed(num_node_ids, false); bool any_node_removed = false; + ShaderNode *geom = NULL; + /* find and unlink proxy nodes */ foreach(ShaderNode *node, nodes) { if(node->special_type == SHADER_SPECIAL_TYPE_PROXY) { @@ -423,12 +425,19 @@ void ShaderGraph::remove_unneeded_nodes() BumpNode *bump = static_cast<BumpNode*>(node); if(bump->outputs[0]->links.size()) { - /* Height input not connected */ - /* ToDo: Strength zero? */ - if(!bump->inputs[0]->link) { + /* Height inputs is not connected. */ + /* TODO(sergey): Ignore bump with zero strength. */ + if(bump->inputs[0]->link == NULL) { vector<ShaderInput*> inputs = bump->outputs[0]->links; - - relink(bump->inputs, inputs, NULL); + if(bump->inputs[4]->link == NULL) { + if(geom == NULL) { + geom = new GeometryNode(); + } + relink(bump->inputs, inputs, geom->output("Normal")); + } + else { + relink(bump->inputs, inputs, bump->input("Normal")->link); + } removed[bump->id] = true; any_node_removed = true; } @@ -511,6 +520,10 @@ void ShaderGraph::remove_unneeded_nodes() nodes = newnodes; } + + if(geom != NULL) { + add(geom); + } } void ShaderGraph::break_cycles(ShaderNode *node, vector<bool>& visited, vector<bool>& on_stack) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 7bceb8a8bfa..486ae5b597f 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -69,6 +69,9 @@ void ImageManager::set_extended_image_limits(const DeviceInfo& info) else if((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && info.extended_images) { tex_num_images = TEX_EXTENDED_NUM_IMAGES_GPU; } + else if(info.pack_images) { + tex_num_images = TEX_PACKED_NUM_IMAGES; + } } bool ImageManager::set_animation_frame_update(int frame) @@ -447,6 +450,9 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img) /* read RGBA pixels */ uchar *pixels = (uchar*)tex_img.resize(width, height, depth); + if(pixels == NULL) { + return false; + } bool cmyk = false; if(in) { @@ -570,6 +576,9 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_ /* read RGBA pixels */ float *pixels = (float*)tex_img.resize(width, height, depth); + if(pixels == NULL) { + return false; + } bool cmyk = false; if(in) { diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index bcc58ae951b..c79c152afde 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -40,6 +40,13 @@ CCL_NAMESPACE_BEGIN #define TEX_EXTENDED_NUM_IMAGES_CPU 1024 #define TEX_EXTENDED_IMAGE_BYTE_START TEX_EXTENDED_NUM_FLOAT_IMAGES +/* Limitations for packed images. + * + * Technically number of textures is unlimited, but it should in + * fact be in sync with CPU limitations. + */ +#define TEX_PACKED_NUM_IMAGES 1024 + /* color to use when textures are not found */ #define TEX_IMAGE_MISSING_R 1 #define TEX_IMAGE_MISSING_G 0 diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 465d7ea02c6..9f8d5b50ccd 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -100,6 +100,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene * transparent shaders in the scene. Otherwise we can disable it * to improve performance a bit. */ if(transparent_shadows) { + kintegrator->transparent_shadows = false; foreach(Shader *shader, scene->shaders) { /* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */ if((shader->has_surface_transparent && shader->use_transparent_shadow) || shader->has_volume) { diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 45685fe5927..57f194651f8 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -513,7 +513,6 @@ void Mesh::compute_bvh(SceneParams *params, Progress *progress, int n, int total progress->set_status(msg, "Building BVH"); BVHParams bparams; - bparams.use_cache = params->use_bvh_cache; bparams.use_spatial_split = params->use_bvh_spatial_split; bparams.use_qbvh = params->use_qbvh; @@ -1084,7 +1083,6 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene * bparams.top_level = true; bparams.use_qbvh = scene->params.use_qbvh; bparams.use_spatial_split = scene->params.use_bvh_spatial_split; - bparams.use_cache = scene->params.use_bvh_cache; delete bvh; bvh = BVH::create(bparams, scene->objects); diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp index 1ba0c7f7291..801fffc774c 100644 --- a/intern/cycles/render/mesh_displace.cpp +++ b/intern/cycles/render/mesh_displace.cpp @@ -78,7 +78,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me int prim = mesh->tri_offset + i; float u, v; - switch (j) { + switch(j) { case 0: u = 1.0f; v = 0.0f; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7ed07ab6453..7ac872b8416 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -182,6 +182,21 @@ static ShaderEnum image_projection_init() return enm; } +static const char* get_osl_interpolation_parameter(InterpolationType interpolation) +{ + switch(interpolation) { + case INTERPOLATION_CLOSEST: + return "closest"; + case INTERPOLATION_CUBIC: + return "cubic"; + case INTERPOLATION_SMART: + return "smart"; + case INTERPOLATION_LINEAR: + default: + return "linear"; + } +} + ShaderEnum ImageTextureNode::color_space_enum = color_space_init(); ShaderEnum ImageTextureNode::projection_enum = image_projection_init(); @@ -362,22 +377,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler) compiler.parameter("projection_blend", projection_blend); compiler.parameter("is_float", is_float); compiler.parameter("use_alpha", !alpha_out->links.empty()); - - switch (interpolation) { - case INTERPOLATION_CLOSEST: - compiler.parameter("interpolation", "closest"); - break; - case INTERPOLATION_CUBIC: - compiler.parameter("interpolation", "cubic"); - break; - case INTERPOLATION_SMART: - compiler.parameter("interpolation", "smart"); - break; - case INTERPOLATION_LINEAR: - default: - compiler.parameter("interpolation", "linear"); - break; - } + compiler.parameter("interpolation", get_osl_interpolation_parameter(interpolation)); switch(extension) { case EXTENSION_EXTEND: @@ -421,6 +421,7 @@ EnvironmentTextureNode::EnvironmentTextureNode() filename = ""; builtin_data = NULL; color_space = ustring("Color"); + interpolation = INTERPOLATION_LINEAR; projection = ustring("Equirectangular"); animated = false; @@ -434,7 +435,7 @@ EnvironmentTextureNode::~EnvironmentTextureNode() if(image_manager) { image_manager->remove_image(filename, builtin_data, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT); } } @@ -477,7 +478,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) 0, is_float_bool, is_linear, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT, use_alpha); is_float = (int)is_float_bool; @@ -546,7 +547,7 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler) 0, is_float_bool, is_linear, - INTERPOLATION_LINEAR, + interpolation, EXTENSION_REPEAT, use_alpha); is_float = (int)is_float_bool; @@ -564,6 +565,9 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler) compiler.parameter("color_space", "Linear"); else compiler.parameter("color_space", "sRGB"); + + compiler.parameter("interpolation", get_osl_interpolation_parameter(interpolation)); + compiler.parameter("is_float", is_float); compiler.parameter("use_alpha", !alpha_out->links.empty()); compiler.add(this, "node_environment_texture"); @@ -1381,7 +1385,7 @@ PointDensityTextureNode::~PointDensityTextureNode() image_manager->remove_image(filename, builtin_data, interpolation, - EXTENSION_REPEAT); + EXTENSION_CLIP); } } @@ -1413,10 +1417,10 @@ void PointDensityTextureNode::compile(SVMCompiler& compiler) image_manager = compiler.image_manager; - if (use_density || use_color) { - if (use_density) + if(use_density || use_color) { + if(use_density) compiler.stack_assign(density_out); - if (use_color) + if(use_color) compiler.stack_assign(color_out); if(slot == -1) { @@ -1425,7 +1429,7 @@ void PointDensityTextureNode::compile(SVMCompiler& compiler) false, 0, is_float, is_linear, interpolation, - EXTENSION_REPEAT, + EXTENSION_CLIP, true); } @@ -1466,14 +1470,14 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler) image_manager = compiler.image_manager; - if (use_density || use_color) { + if(use_density || use_color) { if(slot == -1) { bool is_float, is_linear; slot = image_manager->add_image(filename, builtin_data, false, 0, is_float, is_linear, interpolation, - EXTENSION_REPEAT, + EXTENSION_CLIP, true); } @@ -1484,7 +1488,7 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler) compiler.parameter("mapping", transform_transpose(tfm)); compiler.parameter("use_mapping", 1); } - switch (interpolation) { + switch(interpolation) { case INTERPOLATION_CLOSEST: compiler.parameter("interpolation", "closest"); break; @@ -1675,7 +1679,7 @@ void ConvertNode::compile(SVMCompiler& compiler) compiler.stack_assign(in); compiler.stack_assign(out); - compiler.add_node(NODE_VALUE_V, in->stack_offset); + compiler.add_node(NODE_VALUE_V, out->stack_offset); compiler.add_node(NODE_VALUE_V, in->value); } } @@ -2354,6 +2358,7 @@ HairBsdfNode::HairBsdfNode() add_input("Offset", SHADER_SOCKET_FLOAT); add_input("RoughnessU", SHADER_SOCKET_FLOAT); add_input("RoughnessV", SHADER_SOCKET_FLOAT); + add_input("Tangent", SHADER_SOCKET_VECTOR); } void HairBsdfNode::compile(SVMCompiler& compiler) diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 5065e68345a..39709c26398 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -116,6 +116,7 @@ public: void *builtin_data; ustring color_space; ustring projection; + InterpolationType interpolation; bool animated; static ShaderEnum color_space_enum; diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 31be2a3d3f4..aba3e7237d2 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -18,6 +18,7 @@ #include "camera.h" #include "device.h" #include "graph.h" +#include "integrator.h" #include "light.h" #include "mesh.h" #include "nodes.h" @@ -338,6 +339,7 @@ void ShaderManager::device_update_common(Device *device, uint *shader_flag = dscene->shader_flag.resize(shader_flag_size); uint i = 0; bool has_volumes = false; + bool has_transparent_shadow = false; foreach(Shader *shader, scene->shaders) { uint flag = 0; @@ -355,8 +357,8 @@ void ShaderManager::device_update_common(Device *device, flag |= SD_HAS_ONLY_VOLUME; /* todo: this could check more fine grained, to skip useless volumes - * enclosed inside an opaque bsdf, although we still need to handle - * the case with camera inside volumes too */ + * enclosed inside an opaque bsdf. + */ flag |= SD_HAS_TRANSPARENT_SHADOW; } if(shader->heterogeneous_volume && shader->has_heterogeneous_volume) @@ -382,6 +384,8 @@ void ShaderManager::device_update_common(Device *device, shader_flag[i++] = flag; shader_flag[i++] = shader->pass_id; + + has_transparent_shadow |= (flag & SD_HAS_TRANSPARENT_SHADOW); } device->tex_alloc("__shader_flag", dscene->shader_flag); @@ -404,6 +408,10 @@ void ShaderManager::device_update_common(Device *device, /* integrator */ KernelIntegrator *kintegrator = &dscene->data.integrator; kintegrator->use_volumes = has_volumes; + /* TODO(sergey): De-duplicate with flags set in integrator.cpp. */ + if(scene->integrator->transparent_shadows) { + kintegrator->transparent_shadows = has_transparent_shadow; + } } void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene) diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index d0bd34915df..e81b2f3a827 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -121,7 +121,7 @@ int SVMCompiler::stack_size(ShaderSocketType type) { int size = 0; - switch (type) { + switch(type) { case SHADER_SOCKET_FLOAT: case SHADER_SOCKET_INT: size = 1; @@ -624,7 +624,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty ShaderNode *node = graph->output(); ShaderInput *clin = NULL; - switch (type) { + switch(type) { case SHADER_TYPE_SURFACE: clin = node->input("Surface"); break; @@ -654,7 +654,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty if(clin->link) { bool generate = false; - switch (type) { + switch(type) { case SHADER_TYPE_SURFACE: /* generate surface shader */ generate = true; shader->has_surface = true; diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index 7e68ce84d94..1bec39431d8 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -199,7 +199,7 @@ list<Tile>::iterator TileManager::next_background_tile(int device, TileOrder til int64_t distx = cordx; int64_t disty = cordy; - switch (tile_order) { + switch(tile_order) { case TILE_CENTER: distx = centx - (cur_tile.x + (cur_tile.w / 2)); disty = centy - (cur_tile.y + (cur_tile.h / 2)); |