[Bf-blender-cvs] [698ecda] cycles-ptex-08: Tweak texture-coord node to add Ptex UVs

Nicholas Bishop noreply at git.blender.org
Tue Jan 20 13:57:04 CET 2015


Commit: 698ecdaaf4d34dfcc7f186e6425f515f3b42b092
Author: Nicholas Bishop
Date:   Mon Jan 19 16:02:52 2015 +0100
Branches: cycles-ptex-08
https://developer.blender.org/rB698ecdaaf4d34dfcc7f186e6425f515f3b42b092

Tweak texture-coord node to add Ptex UVs

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

M	intern/cycles/render/nodes.cpp
M	source/blender/nodes/shader/nodes/node_shader_tex_coord.c

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

diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 625b829..24ed237 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -2256,6 +2256,7 @@ TextureCoordinateNode::TextureCoordinateNode()
 	add_output("Camera", SHADER_SOCKET_POINT);
 	add_output("Window", SHADER_SOCKET_POINT);
 	add_output("Reflection", SHADER_SOCKET_NORMAL);
+	add_output("PtexUV", SHADER_SOCKET_POINT);
 
 	from_dupli = false;
 }
@@ -2268,6 +2269,8 @@ void TextureCoordinateNode::attributes(Shader *shader, AttributeRequestSet *attr
 				attributes->add(ATTR_STD_GENERATED);
 			if(!output("UV")->links.empty())
 				attributes->add(ATTR_STD_UV);
+			if(!output("PtexUV")->links.empty())
+				attributes->add(ATTR_STD_PTEX_UV);
 		}
 	}
 
@@ -2371,6 +2374,14 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
 			compiler.add_node(texco_node, NODE_TEXCO_REFLECTION, out->stack_offset);
 		}
 	}
+
+	out = output("PtexUV");
+	if(!out->links.empty()) {
+		int attr = compiler.attribute(ATTR_STD_PTEX_UV);
+		compiler.stack_assign(out);
+		compiler.add_node(attr_node, attr, out->stack_offset,
+						  NODE_ATTR_FLOAT3);
+	}
 }
 
 void TextureCoordinateNode::compile(OSLCompiler& compiler)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
index 85eca6a..bba9ea3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -39,6 +39,7 @@ static bNodeSocketTemplate sh_node_tex_coord_out[] = {
 	{	SOCK_VECTOR, 0, N_("Camera"),			0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 	{	SOCK_VECTOR, 0, N_("Window"),			0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 	{	SOCK_VECTOR, 0, N_("Reflection"),		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+	{	SOCK_VECTOR, 0, N_("PtexUV"),			0.0f, 0.0f, 0.0f, 0.0f, -1.0f, FLT_MAX},
 	{	-1, 0, ""	}
 };
 
@@ -46,12 +47,13 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNod
 {
 	GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
 	GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
+	GPUNodeLink *ptex = GPU_attribute(CD_PTEX_TESSFACE, "");
 	GPUMatType type = GPU_Material_get_type(mat);
 	
 	if (type == GPU_MATERIAL_TYPE_MESH) {
 		return GPU_stack_link(mat, "node_tex_coord", in, out,
 		                      GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
-		                      GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), orco, mtface);
+		                      GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), orco, mtface, ptex);
 	}
 	else {
 		return GPU_stack_link(mat, "node_tex_coord_background", in, out,




More information about the Bf-blender-cvs mailing list