From 80e137e826cac408e66d79d16db44d732e117b01 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 May 2014 16:39:28 +0200 Subject: [PATCH] Fix T39946: OSL + tangent space normal maps not working in Cycles. --- intern/cycles/kernel/osl/osl_services.cpp | 13 ++++++++++++- intern/cycles/kernel/osl/osl_services.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index f33d032b9d3..54894ea19eb 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -59,6 +59,7 @@ CCL_NAMESPACE_BEGIN /* static ustrings */ ustring OSLRenderServices::u_distance("distance"); ustring OSLRenderServices::u_index("index"); +ustring OSLRenderServices::u_world("world"); ustring OSLRenderServices::u_camera("camera"); ustring OSLRenderServices::u_screen("screen"); ustring OSLRenderServices::u_raster("raster"); @@ -209,6 +210,10 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from, float ti COPY_MATRIX44(&result, &tfm); return true; } + else if (from == u_world) { + result.makeIdentity(); + return true; + } return false; } @@ -237,6 +242,10 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to, fl COPY_MATRIX44(&result, &tfm); return true; } + else if (to == u_world) { + result.makeIdentity(); + return true; + } return false; } @@ -781,7 +790,9 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri if (attr.elem != ATTR_ELEMENT_OBJECT) { /* triangle and vertex attributes */ - if(!get_mesh_element_attribute(kg, sd, attr, type, derivatives, val)) + if(get_mesh_element_attribute(kg, sd, attr, type, derivatives, val)) + return true; + else return get_mesh_attribute(kg, sd, attr, type, derivatives, val); } else { diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h index 54ddd7a98b4..069722d81b6 100644 --- a/intern/cycles/kernel/osl/osl_services.h +++ b/intern/cycles/kernel/osl/osl_services.h @@ -116,6 +116,7 @@ public: static ustring u_distance; static ustring u_index; + static ustring u_world; static ustring u_camera; static ustring u_screen; static ustring u_raster;