Commit: 52a59e7cbdf46dc8f05d3f58b40652844ac5fdb1
Author: Nicholas Bishop
Date:   Mon Jan 19 16:02:52 2015 +0100
Branches: cycles-ptex-12
https://developer.blender.org/rB52a59e7cbdf46dc8f05d3f58b40652844ac5fdb1

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 ed0be4d..3ea80a5 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -2261,6 +2261,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;
 }
@@ -2273,6 +2274,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);
                }
        }
 
@@ -2376,6 +2379,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..3358d1a 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_TESSFACE_PTEX, "");
        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,

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to