diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-08-20 02:49:10 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-08-20 02:49:10 +0300 |
commit | 5e59b5ea7645c284acf557ada16b42930e76afb5 (patch) | |
tree | c7576ca008fde872bd9b9028dcbe3e45ff7b53de /intern | |
parent | af0e775c525c638a5a40e7767ee74cf5a305c044 (diff) | |
parent | 962153dbedb8d6355624516847926df221d9ce63 (diff) |
Merge branch 'master' into cycles_procedural_api
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_triangle.h | 14 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/node_texture_coordinate.osl | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_tex_coord.h | 4 | ||||
-rw-r--r-- | intern/cycles/render/geometry.cpp | 5 |
6 files changed, 38 insertions, 5 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 24819bacbb5..de7b2761d00 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1020,13 +1020,21 @@ static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_ input = node->input(name.c_str()); if (!input) { - /* Different internal numbering of two sockets with same name. */ + /* Different internal numbering of two sockets with same name. + * Note that the Blender convention for unique socket names changed + * from . to _ at some point, so we check both to handle old files. */ if (string_endswith(name, "_001")) { string_replace(name, "_001", "2"); } + else if (string_endswith(name, ".001")) { + string_replace(name, ".001", "2"); + } else if (string_endswith(name, "_002")) { string_replace(name, "_002", "3"); } + else if (string_endswith(name, ".002")) { + string_replace(name, ".002", "3"); + } else { name += "1"; } diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index da89592c2ea..3cf75b338dc 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -246,7 +246,11 @@ static inline string image_user_file_path(BL::ImageUser &iuser, string filepath_str = string(filepath); if (load_tiled && ima.source() == BL::Image::source_TILED) { - string_replace(filepath_str, "1001", "<UDIM>"); + string udim; + if (ima.tiles.length() > 0) { + udim = to_string(ima.tiles[0].number()); + } + string_replace(filepath_str, udim, "<UDIM>"); } return filepath_str; } diff --git a/intern/cycles/kernel/geom/geom_triangle.h b/intern/cycles/kernel/geom/geom_triangle.h index 208338a934b..1e7fbd9c7fb 100644 --- a/intern/cycles/kernel/geom/geom_triangle.h +++ b/intern/cycles/kernel/geom/geom_triangle.h @@ -107,6 +107,20 @@ triangle_smooth_normal(KernelGlobals *kg, float3 Ng, int prim, float u, float v) return is_zero(N) ? Ng : N; } +ccl_device_inline float3 +triangle_smooth_normal_unnormalized(KernelGlobals *kg, float3 Ng, int prim, float u, float v) +{ + /* load triangle vertices */ + const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim); + float3 n0 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x)); + float3 n1 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y)); + float3 n2 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z)); + + float3 N = (1.0f - u - v) * n2 + u * n0 + v * n1; + + return is_zero(N) ? Ng : N; +} + /* Ray differentials on triangle */ ccl_device_inline void triangle_dPdudv(KernelGlobals *kg, diff --git a/intern/cycles/kernel/shaders/node_texture_coordinate.osl b/intern/cycles/kernel/shaders/node_texture_coordinate.osl index ac05e984af2..9cdb925dbfa 100644 --- a/intern/cycles/kernel/shaders/node_texture_coordinate.osl +++ b/intern/cycles/kernel/shaders/node_texture_coordinate.osl @@ -58,7 +58,9 @@ shader node_texture_coordinate( getattribute("geom:uv", UV); } else { - getattribute("geom:generated", Generated); + if (!getattribute("geom:generated", Generated)) { + Generated = transform("object", P); + } getattribute("geom:uv", UV); } diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 126fa53122e..fec6a2cc27f 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -267,7 +267,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st if (space == NODE_NORMAL_MAP_TANGENT) { /* tangent space */ - if (sd->object == OBJECT_NONE || (sd->prim & PRIMITIVE_ALL_TRIANGLE) == 0) { + if (sd->object == OBJECT_NONE || (sd->type & PRIMITIVE_ALL_TRIANGLE) == 0) { /* Fallback to unperturbed normal. */ stack_store_float3(stack, normal_offset, sd->N); return; @@ -289,7 +289,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st float3 normal; if (sd->shader & SHADER_SMOOTH_NORMAL) { - normal = triangle_smooth_normal(kg, sd->Ng, sd->prim, sd->u, sd->v); + normal = triangle_smooth_normal_unnormalized(kg, sd->Ng, sd->prim, sd->u, sd->v); } else { normal = sd->Ng; diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp index b0e118dd127..726d80260a2 100644 --- a/intern/cycles/render/geometry.cpp +++ b/intern/cycles/render/geometry.cpp @@ -809,6 +809,11 @@ void GeometryManager::device_update_attributes(Device *device, Mesh *mesh = static_cast<Mesh *>(geom); Attribute *subd_attr = mesh->subd_attributes.find(req); + /* Vertex normals are stored in DeviceScene.tri_vnormal. */ + if (subd_attr && subd_attr->std == ATTR_STD_VERTEX_NORMAL) { + continue; + } + update_attribute_element_size(mesh, subd_attr, ATTR_PRIM_SUBD, |