Cycles: image texture node now uses UV as default texture coordinate,
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 12 Oct 2011 16:01:37 +0000 (16:01 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 12 Oct 2011 16:01:37 +0000 (16:01 +0000)
instead of generated.

intern/cycles/render/graph.cpp
intern/cycles/render/graph.h
intern/cycles/render/nodes.cpp

index 54acc6e14cdded93ff7c088e994b09e8aaf24d28..cdded403cbe0d72bd5db91d10e04c1fd78220c1c 100644 (file)
@@ -117,9 +117,14 @@ ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type)
 
 void ShaderNode::attributes(AttributeRequestSet *attributes)
 {
-       foreach(ShaderInput *input, inputs)
-               if(!input->link && input->default_value == ShaderInput::TEXTURE_COORDINATE)
-                       attributes->add(Attribute::STD_GENERATED);
+       foreach(ShaderInput *input, inputs) {
+               if(!input->link) {
+                       if(input->default_value == ShaderInput::TEXTURE_GENERATED)
+                               attributes->add(Attribute::STD_GENERATED);
+                       else if(input->default_value == ShaderInput::TEXTURE_UV)
+                               attributes->add(Attribute::STD_UV);
+               }
+       }
 }
 
 /* Graph */
@@ -347,12 +352,18 @@ void ShaderGraph::default_inputs(bool do_osl)
        foreach(ShaderNode *node, nodes) {
                foreach(ShaderInput *input, node->inputs) {
                        if(!input->link && !(input->osl_only && !do_osl)) {
-                               if(input->default_value == ShaderInput::TEXTURE_COORDINATE) {
+                               if(input->default_value == ShaderInput::TEXTURE_GENERATED) {
                                        if(!texco)
                                                texco = new TextureCoordinateNode();
 
                                        connect(texco->output("Generated"), input);
                                }
+                               else if(input->default_value == ShaderInput::TEXTURE_UV) {
+                                       if(!texco)
+                                               texco = new TextureCoordinateNode();
+
+                                       connect(texco->output("UV"), input);
+                               }
                                else if(input->default_value == ShaderInput::INCOMING) {
                                        if(!geom)
                                                geom = new GeometryNode();
index a79a68da358dee6be6d0a3525c33c4897feb10c5..2a2df5e1377c5e8c1b43d64f0c4456d6905ee1fe 100644 (file)
@@ -96,7 +96,8 @@ protected:
 class ShaderInput {
 public:
        enum DefaultValue {
-               TEXTURE_COORDINATE,
+               TEXTURE_GENERATED,
+               TEXTURE_UV,
                INCOMING,
                NORMAL,
                POSITION,
index 1d21e43217a80660523594c00c5f3ec623e3bf62..88be4b6d26f017a0fbc7b216619c6e7a20773693 100644 (file)
@@ -47,7 +47,7 @@ ImageTextureNode::ImageTextureNode()
        filename = "";
        color_space = ustring("sRGB");
 
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV);
        add_output("Color", SHADER_SOCKET_COLOR);
        add_output("Alpha", SHADER_SOCKET_FLOAT);
 }
@@ -285,7 +285,7 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
 NoiseTextureNode::NoiseTextureNode()
 : ShaderNode("noise_texture")
 {
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
        add_output("Color", SHADER_SOCKET_COLOR);
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
@@ -350,7 +350,7 @@ BlendTextureNode::BlendTextureNode()
        progression = ustring("Linear");
        axis = ustring("Horizontal");
 
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
 
@@ -402,7 +402,7 @@ CloudsTextureNode::CloudsTextureNode()
        depth = 2;
 
        add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Color", SHADER_SOCKET_COLOR);
        add_output("Fac", SHADER_SOCKET_FLOAT);
@@ -479,7 +479,7 @@ VoronoiTextureNode::VoronoiTextureNode()
        add_input("Weight3", SHADER_SOCKET_FLOAT, 0.0f);
        add_input("Weight4", SHADER_SOCKET_FLOAT, 0.0f);
        add_input("Exponent", SHADER_SOCKET_FLOAT, 2.5f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Color", SHADER_SOCKET_COLOR);
        add_output("Fac", SHADER_SOCKET_FLOAT);
@@ -557,7 +557,7 @@ MusgraveTextureNode::MusgraveTextureNode()
        add_input("Offset", SHADER_SOCKET_FLOAT, 0.0f);
        add_input("Gain", SHADER_SOCKET_FLOAT, 1.0f);
        add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
@@ -641,7 +641,7 @@ MarbleTextureNode::MarbleTextureNode()
 
        add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
        add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
@@ -684,7 +684,7 @@ MagicTextureNode::MagicTextureNode()
        depth = 2;
 
        add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
        add_output("Color", SHADER_SOCKET_COLOR);
 }
 
@@ -734,7 +734,7 @@ StucciTextureNode::StucciTextureNode()
 
        add_input("Size", SHADER_SOCKET_FLOAT, 1.0f);
        add_input("Turbulence", SHADER_SOCKET_FLOAT, 1.0f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
@@ -780,7 +780,7 @@ DistortedNoiseTextureNode::DistortedNoiseTextureNode()
 
        add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
        add_input("Distortion", SHADER_SOCKET_FLOAT, 1.0f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }
@@ -840,7 +840,7 @@ WoodTextureNode::WoodTextureNode()
 
        add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
        add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
-       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_COORDINATE);
+       add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
 
        add_output("Fac", SHADER_SOCKET_FLOAT);
 }