Fix performance issue in OSL geometry node, compiler fails to optimize out the
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 2 Dec 2012 08:25:40 +0000 (08:25 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 2 Dec 2012 08:25:40 +0000 (08:25 +0000)
tangent computation, tweaked the code so this works.

intern/cycles/kernel/shaders/node_geometry.osl

index 3940b98eec13633197002a8b84945880141d0016..5a784f951bb6dbc6731a6d1c6b8c5803a70e1228 100644 (file)
@@ -51,7 +51,12 @@ shader node_geometry(
 
        /* try to create spherical tangent from generated coordinates */
        if (getattribute("geom:generated", generated)) {
-               vector T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
+               matrix project = matrix(0.0, 1.0, 0.0, 0.0,
+                                 -1.0, 0.0, 0.0, 0.0,
+                                                 0.0, 0.0, 0.0, 0.0,
+                                                 0.5, -0.5, 0.0, 1.0);
+
+               vector T = transform(project, generated);
                T = transform("object", "world", T);
                Tangent = cross(Normal, normalize(cross(T, Normal)));
        }