Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2021-08-18 00:24:46 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2021-08-18 22:12:39 +0300
commitb8ecdbcd964a7e78d7e077ef84a914b1374ae076 (patch)
tree589d69109b3f70d219ef14a040bc717381266c85 /intern/cycles/kernel/svm
parente5f8db92b696a36e919eb6ac3125190d9e2202d9 (diff)
Cycles: avoid copying vertex normals attribute twice to the devices
Vertex normals are needed for normals maps and therefore are packed and send to the device alongside the other float3 attributes. However, we already pack and send vertex normals through `DeviceScene.tri_vnormal`. This removes the packing of vertex normals from the attributes buffer, and reuses `tri_vnormal` in the kernel for normals lookup for normal maps, which reduces memory usage a bit, and speeds up device updates. This also fixes potential missing normals updates following rB12a06292af86, since the need for vertex normals for normals maps was overlooked. Reviewed By: brecht Differential Revision: https://developer.blender.org/D12237
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index fc46bb584be..09ea11ee3ed 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) {
+ if (sd->object == OBJECT_NONE || (sd->prim & PRIMITIVE_ALL_TRIANGLE) == 0) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -276,10 +276,8 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
/* first try to get tangent attribute */
const AttributeDescriptor attr = find_attribute(kg, sd, node.z);
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
- const AttributeDescriptor attr_normal = find_attribute(kg, sd, ATTR_STD_VERTEX_NORMAL);
- if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND ||
- attr_normal.offset == ATTR_STD_NOT_FOUND) {
+ if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND) {
/* Fallback to unperturbed normal. */
stack_store_float3(stack, normal_offset, sd->N);
return;
@@ -291,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 = primitive_surface_attribute_float3(kg, sd, attr_normal, NULL, NULL);
+ normal = triangle_smooth_normal_unnormalized(kg, sd->Ng, sd->prim, sd->u, sd->v);
}
else {
normal = sd->Ng;