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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-01-15 20:35:05 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-01-15 20:35:05 +0400
commit6adfd91657e07e5b749fb3a7aaeeeec88fb15d04 (patch)
tree32232a0280a212d0438cb3219079a61e89632a16 /intern/cycles/render/object.cpp
parent51f36ac80ab3dbb9a34cacdcb0eda5371793b16f (diff)
Fix #33830: cycles normal mapping was not quite correct, was not correctly
respecting the assumption that normal and tangent are interpolated without normalization.
Diffstat (limited to 'intern/cycles/render/object.cpp')
-rw-r--r--intern/cycles/render/object.cpp30
1 files changed, 4 insertions, 26 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index a89f8afd251..8d8087266c1 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -91,38 +91,16 @@ void Object::apply_transform()
for(size_t i = 0; i < mesh->curve_keys.size(); i++)
mesh->curve_keys[i].co = transform_point(&tfm, mesh->curve_keys[i].co);
- Attribute *attr_tangent = mesh->curve_attributes.find(ATTR_STD_CURVE_TANGENT);
- Attribute *attr_fN = mesh->attributes.find(ATTR_STD_FACE_NORMAL);
- Attribute *attr_vN = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
-
- Transform ntfm = transform_transpose(transform_inverse(tfm));
+ /* store matrix to transform later. when accessing these as attributes we
+ * do not want the transform to be applied for consistency between static
+ * and dynamic BVH, so we do it on packing. */
+ mesh->transform_normal = transform_transpose(transform_inverse(tfm));
/* we keep normals pointing in same direction on negative scale, notify
* mesh about this in it (re)calculates normals */
if(transform_negative_scale(tfm))
mesh->transform_negative_scaled = true;
- if(attr_fN) {
- float3 *fN = attr_fN->data_float3();
-
- for(size_t i = 0; i < mesh->triangles.size(); i++)
- fN[i] = transform_direction(&ntfm, fN[i]);
- }
-
- if(attr_vN) {
- float3 *vN = attr_vN->data_float3();
-
- for(size_t i = 0; i < mesh->verts.size(); i++)
- vN[i] = transform_direction(&ntfm, vN[i]);
- }
-
- if(attr_tangent) {
- float3 *tangent = attr_tangent->data_float3();
-
- for(size_t i = 0; i < mesh->curve_keys.size(); i++)
- tangent[i] = transform_direction(&tfm, tangent[i]);
- }
-
if(bounds.valid()) {
mesh->compute_bounds();
compute_bounds(false, 0.0f);