[Bf-blender-cvs] [5545fa2] temp-cycles-microdisplacement: Fix OSL not finding attributes on subdivision meshes

Mai Lavelle noreply at git.blender.org
Sun Jul 10 05:31:17 CEST 2016


Commit: 5545fa2488df9b285898688f5ed6b26784394a04
Author: Mai Lavelle
Date:   Fri Jul 1 19:06:32 2016 -0400
Branches: temp-cycles-microdisplacement
https://developer.blender.org/rB5545fa2488df9b285898688f5ed6b26784394a04

Fix OSL not finding attributes on subdivision meshes

===================================================================

M	intern/cycles/kernel/geom/geom_attribute.h
M	intern/cycles/kernel/osl/osl_services.cpp

===================================================================

diff --git a/intern/cycles/kernel/geom/geom_attribute.h b/intern/cycles/kernel/geom/geom_attribute.h
index 9ec81f8..4cfae40 100644
--- a/intern/cycles/kernel/geom/geom_attribute.h
+++ b/intern/cycles/kernel/geom/geom_attribute.h
@@ -27,6 +27,22 @@ CCL_NAMESPACE_BEGIN
 
 ccl_device_inline int subd_triangle_patch(KernelGlobals *kg, const ShaderData *sd);
 
+ccl_device_inline uint attribute_primitive_type(KernelGlobals *kg, const ShaderData *sd)
+{
+#ifdef __HAIR__
+	if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+		return ATTR_PRIM_CURVE;
+	}
+	else
+#endif
+	if(subd_triangle_patch(kg, sd) != ~0) {
+		return ATTR_PRIM_SUBD;
+	}
+	else {
+		return ATTR_PRIM_TRIANGLE;
+	}
+}
+
 /* Find attribute based on ID */
 
 ccl_device_inline int find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id, AttributeElement *elem)
@@ -36,12 +52,7 @@ ccl_device_inline int find_attribute(KernelGlobals *kg, const ShaderData *sd, ui
 
 	/* for SVM, find attribute by unique id */
 	uint attr_offset = ccl_fetch(sd, object)*kernel_data.bvh.attributes_map_stride;
-#ifdef __HAIR__
-	attr_offset = (ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE)? attr_offset + ATTR_PRIM_CURVE: attr_offset;
-#endif
-	if(ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE && subd_triangle_patch(kg, sd) != ~0) {
-		attr_offset += ATTR_PRIM_SUBD;
-	}
+	attr_offset += attribute_primitive_type(kg, sd);
 	uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
 	
 	while(attr_map.x != id) {
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index ebe739e..2209e2c 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -786,7 +786,7 @@ bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, ustring
                                       TypeDesc type, ustring name, void *val)
 {
 	KernelGlobals *kg = sd->osl_globals;
-	bool is_curve;
+	int prim_type = 0;
 	int object;
 
 	/* lookup of attribute on another object */
@@ -797,18 +797,17 @@ bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, ustring
 			return false;
 
 		object = it->second;
-		is_curve = false;
 	}
 	else {
 		object = sd->object;
-		is_curve = (sd->type & PRIMITIVE_ALL_CURVE) != 0;
+		prim_type = attribute_primitive_type(kg, sd);
 
 		if(object == OBJECT_NONE)
 			return get_background_attribute(kg, sd, name, type, derivatives, val);
 	}
 
 	/* find attribute on object */
-	object = object*ATTR_PRIM_TYPES + (is_curve == true);
+	object = object*ATTR_PRIM_TYPES + prim_type;
 	OSLGlobals::AttributeMap& attribute_map = kg->osl->attribute_map[object];
 	OSLGlobals::AttributeMap::iterator it = attribute_map.find(name);




More information about the Bf-blender-cvs mailing list