Cycles: add location/rotate/scale and XYZ mapping options for all texture nodes,
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 4 Nov 2011 20:58:00 +0000 (20:58 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 4 Nov 2011 20:58:00 +0000 (20:58 +0000)
to reduce the amount of nodes needed to set up a simple texture.

These are currently editable in the texture properties tab, still need to make
them available in the node editor. Projection and color modification options will
be added later, they're not implemented yet but allocated already to avoid
version patches later.

Also an issue with the XYZ mapping is that when you set one to None, texture and
material draw mode doesn't draw the image texture well, OpenGL doesn't seem to
like the degenerate texture matrix?

38 files changed:
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_shader.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
source/blender/blenkernel/BKE_texture.h
source/blender/blenkernel/intern/texture.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_uvedit.h
source/blender/editors/interface/interface_node.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_texture_types.h
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture.c
source/blender/nodes/composite/nodes/node_composite_mapValue.c
source/blender/nodes/shader/node_shader_util.c
source/blender/nodes/shader/node_shader_util.h
source/blender/nodes/shader/nodes/node_shader_mapping.c
source/blender/nodes/shader/nodes/node_shader_tex_blend.c
source/blender/nodes/shader/nodes/node_shader_tex_clouds.c
source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c
source/blender/nodes/shader/nodes/node_shader_tex_environment.c
source/blender/nodes/shader/nodes/node_shader_tex_image.c
source/blender/nodes/shader/nodes/node_shader_tex_magic.c
source/blender/nodes/shader/nodes/node_shader_tex_marble.c
source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
source/blender/nodes/shader/nodes/node_shader_tex_noise.c
source/blender/nodes/shader/nodes/node_shader_tex_sky.c
source/blender/nodes/shader/nodes/node_shader_tex_stucci.c
source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
source/blender/nodes/shader/nodes/node_shader_tex_wood.c

index ca077a50ad6d1ccdb11cfe31aae8068cadba256e..49193ecb1956d2d8186f8f8bf7525676900031fb 100644 (file)
@@ -311,7 +311,7 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         ob = context.object
     @classmethod
     def poll(cls, context):
         ob = context.object
-        return ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
+        return CyclesButtonsPanel.poll(context) and ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
 
     def draw(self, context):
         layout = self.layout
 
     def draw(self, context):
         layout = self.layout
@@ -604,23 +604,64 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
 
     def draw(self, context):
         layout = self.layout
-        layout.label("Texture coordinate mapping goes here.");
-        layout.label("Translate, rotate, scale, projection, XYZ.")
 
 
-class CyclesTexture_PT_color(CyclesButtonsPanel, Panel):
+        tex = context.texture
+        node = context.texture_node
+
+        mapping = node.texture_mapping
+
+        row = layout.row()
+
+        row.column().prop(mapping, "location")
+        row.column().prop(mapping, "rotation")
+        row.column().prop(mapping, "scale")
+
+        layout.label(text="Projection:")
+
+        row = layout.row()
+        row.prop(mapping, "mapping_x", text="")
+        row.prop(mapping, "mapping_y", text="")
+        row.prop(mapping, "mapping_z", text="")
+
+class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
     bl_label = "Color"
     bl_context = "texture"
     bl_label = "Color"
     bl_context = "texture"
+    bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
     def poll(cls, context):
         tex = context.texture
         node = context.texture_node
 
     @classmethod
     def poll(cls, context):
         tex = context.texture
         node = context.texture_node
-        return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
+        return False
+        #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
 
     def draw(self, context):
         layout = self.layout
-        layout.label("Color modification options go here.");
-        layout.label("Ramp, brightness, contrast, saturation.")
+
+        tex = context.texture
+        node = context.texture_node
+
+        mapping = node.color_mapping
+
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Blend:")
+        col.prop(mapping, "blend_type", text="")
+        col.prop(mapping, "blend_factor", text="Factor")
+        col.prop(mapping, "blend_color", text="")
+
+        col = split.column()
+        col.label(text="Adjust:")
+        col.prop(mapping, "brightness")
+        col.prop(mapping, "contrast")
+        col.prop(mapping, "saturation")
+
+        layout.separator()
+
+        layout.prop(mapping, "use_color_ramp", text="Ramp")
+        if mapping.use_color_ramp:
+            layout.template_color_ramp(mapping, "color_ramp", expand=True)
 
 def draw_device(self, context):
     scene = context.scene
 
 def draw_device(self, context):
     scene = context.scene
index ed84777de7cbec57527203ac1ace22d345b63aa5..48bdcd88c9daea4dafac723c9a231288aecd337c 100644 (file)
@@ -97,6 +97,17 @@ static float get_node_output_value(BL::Node b_node, const string& name)
        return sock.default_value();
 }
 
        return sock.default_value();
 }
 
+static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
+{
+       mapping->translation = get_float3(b_mapping.location());
+       mapping->rotation = get_float3(b_mapping.rotation())*(M_PI/180.0f); /* in degrees! */
+       mapping->scale = get_float3(b_mapping.scale());
+
+       mapping->x_mapping = (TextureMapping::Mapping)b_mapping.mapping_x();
+       mapping->y_mapping = (TextureMapping::Mapping)b_mapping.mapping_y();
+       mapping->z_mapping = (TextureMapping::Mapping)b_mapping.mapping_z();
+}
+
 static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *b_group_node, BL::ShaderNode b_node)
 {
        ShaderNode *node = NULL;
 static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *b_group_node, BL::ShaderNode b_node)
 {
        ShaderNode *node = NULL;
@@ -163,10 +174,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        BL::ShaderNodeMapping b_mapping_node(b_node);
                        MappingNode *mapping = new MappingNode();
 
                        BL::ShaderNodeMapping b_mapping_node(b_node);
                        MappingNode *mapping = new MappingNode();
 
-                       TextureMapping *tex_mapping = &mapping->tex_mapping;
-                       tex_mapping->translation = get_float3(b_mapping_node.location());
-                       tex_mapping->rotation = get_float3(b_mapping_node.rotation());
-                       tex_mapping->scale = get_float3(b_mapping_node.scale());
+                       get_tex_mapping(&mapping->tex_mapping, b_mapping_node.mapping());
 
                        node = mapping;
                        break;
 
                        node = mapping;
                        break;
@@ -293,6 +301,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        if(b_image)
                                image->filename = blender_absolute_path(b_data, b_image, b_image.filepath());
                        image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
                        if(b_image)
                                image->filename = blender_absolute_path(b_data, b_image, b_image.filepath());
                        image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
+                       get_tex_mapping(&image->tex_mapping, b_image_node.texture_mapping());
                        node = image;
                        break;
                }
                        node = image;
                        break;
                }
@@ -303,11 +312,15 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        if(b_image)
                                env->filename = blender_absolute_path(b_data, b_image, b_image.filepath());
                        env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
                        if(b_image)
                                env->filename = blender_absolute_path(b_data, b_image, b_image.filepath());
                        env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
+                       get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
                        node = env;
                        break;
                }
                case BL::ShaderNode::type_TEX_NOISE: {
                        node = env;
                        break;
                }
                case BL::ShaderNode::type_TEX_NOISE: {
-                       node = new NoiseTextureNode();
+                       BL::ShaderNodeTexNoise b_noise_node(b_node);
+                       NoiseTextureNode *noise = new NoiseTextureNode();
+                       get_tex_mapping(&noise->tex_mapping, b_noise_node.texture_mapping());
+                       node = noise;
                        break;
                }
                case BL::ShaderNode::type_TEX_BLEND: {
                        break;
                }
                case BL::ShaderNode::type_TEX_BLEND: {
@@ -315,6 +328,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        BlendTextureNode *blend = new BlendTextureNode();
                        blend->progression = BlendTextureNode::progression_enum[(int)b_blend_node.progression()];
                        blend->axis = BlendTextureNode::axis_enum[(int)b_blend_node.axis()];
                        BlendTextureNode *blend = new BlendTextureNode();
                        blend->progression = BlendTextureNode::progression_enum[(int)b_blend_node.progression()];
                        blend->axis = BlendTextureNode::axis_enum[(int)b_blend_node.axis()];
+                       get_tex_mapping(&blend->tex_mapping, b_blend_node.texture_mapping());
                        node = blend;
                        break;
                }
                        node = blend;
                        break;
                }
@@ -323,6 +337,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
                        voronoi->distance_metric = VoronoiTextureNode::distance_metric_enum[(int)b_voronoi_node.distance_metric()];
                        voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
                        voronoi->distance_metric = VoronoiTextureNode::distance_metric_enum[(int)b_voronoi_node.distance_metric()];
                        voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
+                       get_tex_mapping(&voronoi->tex_mapping, b_voronoi_node.texture_mapping());
                        node = voronoi;
                        break;
                }
                        node = voronoi;
                        break;
                }
@@ -330,6 +345,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        BL::ShaderNodeTexMagic b_magic_node(b_node);
                        MagicTextureNode *magic = new MagicTextureNode();
                        magic->depth = b_magic_node.turbulence_depth();
                        BL::ShaderNodeTexMagic b_magic_node(b_node);
                        MagicTextureNode *magic = new MagicTextureNode();
                        magic->depth = b_magic_node.turbulence_depth();
+                       get_tex_mapping(&magic->tex_mapping, b_magic_node.texture_mapping());
                        node = magic;
                        break;
                }
                        node = magic;
                        break;
                }
@@ -341,6 +357,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        marble->type = MarbleTextureNode::type_enum[(int)b_marble_node.marble_type()];
                        marble->wave = MarbleTextureNode::wave_enum[(int)b_marble_node.wave_type()];
                        marble->hard = b_marble_node.noise_type() == BL::ShaderNodeTexMarble::noise_type_HARD;
                        marble->type = MarbleTextureNode::type_enum[(int)b_marble_node.marble_type()];
                        marble->wave = MarbleTextureNode::wave_enum[(int)b_marble_node.wave_type()];
                        marble->hard = b_marble_node.noise_type() == BL::ShaderNodeTexMarble::noise_type_HARD;
+                       get_tex_mapping(&marble->tex_mapping, b_marble_node.texture_mapping());
                        node = marble;
                        break;
                }
                        node = marble;
                        break;
                }
@@ -350,6 +367,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        clouds->depth = b_clouds_node.turbulence_depth();
                        clouds->basis = CloudsTextureNode::basis_enum[(int)b_clouds_node.noise_basis()];
                        clouds->hard = b_clouds_node.noise_type() == BL::ShaderNodeTexClouds::noise_type_HARD;
                        clouds->depth = b_clouds_node.turbulence_depth();
                        clouds->basis = CloudsTextureNode::basis_enum[(int)b_clouds_node.noise_basis()];
                        clouds->hard = b_clouds_node.noise_type() == BL::ShaderNodeTexClouds::noise_type_HARD;
+                       get_tex_mapping(&clouds->tex_mapping, b_clouds_node.texture_mapping());
                        node = clouds;
                        break;
                }
                        node = clouds;
                        break;
                }
@@ -360,6 +378,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        wood->basis = WoodTextureNode::basis_enum[(int)b_wood_node.noise_basis()];
                        wood->hard = b_wood_node.noise_type() == BL::ShaderNodeTexWood::noise_type_HARD;
                        wood->wave = WoodTextureNode::wave_enum[(int)b_wood_node.wave_type()];
                        wood->basis = WoodTextureNode::basis_enum[(int)b_wood_node.noise_basis()];
                        wood->hard = b_wood_node.noise_type() == BL::ShaderNodeTexWood::noise_type_HARD;
                        wood->wave = WoodTextureNode::wave_enum[(int)b_wood_node.wave_type()];
+                       get_tex_mapping(&wood->tex_mapping, b_wood_node.texture_mapping());
                        node = wood;
                        break;
                }
                        node = wood;
                        break;
                }
@@ -368,6 +387,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
                        musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
                        musgrave->basis = MusgraveTextureNode::basis_enum[(int)b_musgrave_node.noise_basis()];
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
                        musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
                        musgrave->basis = MusgraveTextureNode::basis_enum[(int)b_musgrave_node.noise_basis()];
+                       get_tex_mapping(&musgrave->tex_mapping, b_musgrave_node.texture_mapping());
                        node = musgrave;
                        break;
                }
                        node = musgrave;
                        break;
                }
@@ -377,6 +397,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        stucci->type = StucciTextureNode::type_enum[(int)b_stucci_node.stucci_type()];
                        stucci->basis = StucciTextureNode::basis_enum[(int)b_stucci_node.noise_basis()];
                        stucci->hard = b_stucci_node.noise_type() == BL::ShaderNodeTexStucci::noise_type_HARD;
                        stucci->type = StucciTextureNode::type_enum[(int)b_stucci_node.stucci_type()];
                        stucci->basis = StucciTextureNode::basis_enum[(int)b_stucci_node.noise_basis()];
                        stucci->hard = b_stucci_node.noise_type() == BL::ShaderNodeTexStucci::noise_type_HARD;
+                       get_tex_mapping(&stucci->tex_mapping, b_stucci_node.texture_mapping());
                        node = stucci;
                        break;
                }
                        node = stucci;
                        break;
                }
@@ -385,6 +406,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        DistortedNoiseTextureNode *distnoise = new DistortedNoiseTextureNode();
                        distnoise->basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_basis()];
                        distnoise->distortion_basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_distortion()];
                        DistortedNoiseTextureNode *distnoise = new DistortedNoiseTextureNode();
                        distnoise->basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_basis()];
                        distnoise->distortion_basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_distortion()];
+                       get_tex_mapping(&distnoise->tex_mapping, b_distnoise_node.texture_mapping());
                        node = distnoise;
                        break;
                }
                        node = distnoise;
                        break;
                }
@@ -397,6 +419,7 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
                        SkyTextureNode *sky = new SkyTextureNode();
                        sky->sun_direction = get_float3(b_sky_node.sun_direction());
                        sky->turbidity = b_sky_node.turbidity();
                        SkyTextureNode *sky = new SkyTextureNode();
                        sky->sun_direction = get_float3(b_sky_node.sun_direction());
                        sky->turbidity = b_sky_node.turbidity();
+                       get_tex_mapping(&sky->tex_mapping, b_sky_node.texture_mapping());
                        node = sky;
                        break;
                }
                        node = sky;
                        break;
                }
index 9c72c01417add20dac44a412fd993b05e605d268..56d5bdf77baecec9f50b6ed92db6e1cfb0e5efbe 100644 (file)
@@ -45,11 +45,11 @@ Transform TextureMapping::compute_transform()
        Transform mmat = transform_scale(make_float3(0.0f, 0.0f, 0.0f));
 
        if(x_mapping != NONE)
        Transform mmat = transform_scale(make_float3(0.0f, 0.0f, 0.0f));
 
        if(x_mapping != NONE)
-               mmat[0][x_mapping] = 1.0f;
+               mmat[0][x_mapping-1] = 1.0f;
        if(y_mapping != NONE)
        if(y_mapping != NONE)
-               mmat[1][y_mapping] = 1.0f;
+               mmat[1][y_mapping-1] = 1.0f;
        if(z_mapping != NONE)
        if(z_mapping != NONE)
-               mmat[2][z_mapping] = 1.0f;
+               mmat[2][z_mapping-1] = 1.0f;
 
        Transform smat = transform_scale(scale);
        Transform rmat = transform_euler(rotation);
 
        Transform smat = transform_scale(scale);
        Transform rmat = transform_euler(rotation);
index e11c51b4aafeeb455b65b9589483d0edb9c9cfeb..09b565b5043d0b612f82e9dc8763faebdd883a0b 100644 (file)
@@ -41,7 +41,7 @@ public:
        float3 rotation;
        float3 scale;
 
        float3 rotation;
        float3 scale;
 
-       enum Mapping { X=0, Y=1, Z=2, NONE };
+       enum Mapping { NONE=0, X=1, Y=2, Z=3 };
        Mapping x_mapping, y_mapping, z_mapping;
 
        enum Projection { FLAT, CUBE, TUBE, SPHERE };
        Mapping x_mapping, y_mapping, z_mapping;
 
        enum Projection { FLAT, CUBE, TUBE, SPHERE };
index de72428b3d78e3acdd5b923b3eb8ea9b1af9441a..508fef8d9a42b4b7f82f2a1417bfd70c1740d9a4 100644 (file)
@@ -103,9 +103,12 @@ void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex
 
 int has_current_material_texture(struct Material *ma);
 
 
 int has_current_material_texture(struct Material *ma);
 
-struct TexMapping *add_mapping(void);
-void init_mapping(struct TexMapping *texmap);
+struct TexMapping *add_tex_mapping(void);
+void default_tex_mapping(struct TexMapping *texmap);
+void init_tex_mapping(struct TexMapping *texmap);
 
 
+struct ColorMapping *add_color_mapping(void);
+void default_color_mapping(struct ColorMapping *colormap);
 
 void    BKE_free_envmapdata(struct EnvMap *env);
 void    BKE_free_envmap(struct EnvMap *env);
 
 void    BKE_free_envmapdata(struct EnvMap *env);
 void    BKE_free_envmap(struct EnvMap *env);
index d3bd7d7b766a351b94dc1c47fa3a55e1277ae059..88cf0689a39f25de0155b00953093247b4ce6e9b 100644 (file)
@@ -202,33 +202,96 @@ void free_plugin_tex(PluginTex *pit)
 
 /* ****************** Mapping ******************* */
 
 
 /* ****************** Mapping ******************* */
 
-TexMapping *add_mapping(void)
+TexMapping *add_tex_mapping(void)
 {
 {
-       TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "Tex map");
+       TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "TexMapping");
        
        
+       default_tex_mapping(texmap);
+       
+       return texmap;
+}
+
+void default_tex_mapping(TexMapping *texmap)
+{
+       memset(texmap, 0, sizeof(TexMapping));
+
        texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f;
        texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f;
        unit_m4(texmap->mat);
        texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f;
        texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f;
        unit_m4(texmap->mat);
-       
-       return texmap;
+
+       texmap->projx= PROJ_X;
+       texmap->projy= PROJ_Y;
+       texmap->projz= PROJ_Z;
+       texmap->mapping= MTEX_FLAT;
 }
 
 }
 
-void init_mapping(TexMapping *texmap)
+void init_tex_mapping(TexMapping *texmap)
 {
 {
-       float eul[3], smat[3][3], rmat[3][3], mat[3][3];
-       
-       size_to_mat3( smat,texmap->size);
-       
-       eul[0]= DEG2RADF(texmap->rot[0]);
-       eul[1]= DEG2RADF(texmap->rot[1]);
-       eul[2]= DEG2RADF(texmap->rot[2]);
-       eul_to_mat3( rmat,eul);
+       float eul[3], smat[3][3], rmat[3][3], mat[3][3], proj[3][3];
+
+       if(texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z &&
+          is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) {
+               unit_m4(texmap->mat);
+
+               texmap->flag |= TEXMAP_UNIT_MATRIX;
+       }
+       else {
+               /* axis projection */
+               zero_m3(proj);
+
+               if(texmap->projx != PROJ_N)
+                       proj[texmap->projx-1][0]= 1.0f;
+               if(texmap->projy != PROJ_N)
+                       proj[texmap->projy-1][1]= 1.0f;
+               if(texmap->projz != PROJ_N)
+                       proj[texmap->projz-1][2]= 1.0f;
+
+               /* scale */
+               size_to_mat3(smat, texmap->size);
+               
+               /* rotation */
+               eul[0]= DEG2RADF(texmap->rot[0]);
+               eul[1]= DEG2RADF(texmap->rot[1]);
+               eul[2]= DEG2RADF(texmap->rot[2]);
+               eul_to_mat3( rmat,eul);
+               
+               /* compose it all */
+               mul_m3_m3m3(mat, rmat, smat);
+               mul_m3_m3m3(mat, proj, mat);
+               
+               /* translation */
+               copy_m4_m3(texmap->mat, mat);
+               VECCOPY(texmap->mat[3], texmap->loc);
+
+               texmap->flag &= ~TEXMAP_UNIT_MATRIX;
+       }
+}
+
+ColorMapping *add_color_mapping(void)
+{
+       ColorMapping *colormap= MEM_callocN(sizeof(ColorMapping), "ColorMapping");
        
        
-       mul_m3_m3m3(mat, rmat, smat);
+       default_color_mapping(colormap);
        
        
-       copy_m4_m3(texmap->mat, mat);
-       VECCOPY(texmap->mat[3], texmap->loc);
+       return colormap;
+
+}
+
+void default_color_mapping(ColorMapping *colormap)
+{
+       memset(colormap, 0, sizeof(ColorMapping));
+
+       init_colorband(&colormap->coba, 1);
+
+       colormap->bright= 1.0;
+       colormap->contrast= 1.0;
+       colormap->saturation= 1.0;
 
 
+       colormap->blend_color[0]= 0.8f;
+       colormap->blend_color[1]= 0.8f;
+       colormap->blend_color[2]= 0.8f;
+       colormap->blend_type= MA_RAMP_BLEND;
+       colormap->blend_factor= 0.0f;
 }
 
 /* ****************** COLORBAND ******************* */
 }
 
 /* ****************** COLORBAND ******************* */
index c0d52747d568006de04e62aaa1fabe8d27cb2daa..1c96cd2e05af59619dc0e6915c95c2d3306ab0ec 100644 (file)
@@ -7212,6 +7212,40 @@ static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
        }
 }
 
        }
 }
 
+static void do_version_ntree_tex_mapping_260(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
+{
+       bNode *node;
+
+       for(node=ntree->nodes.first; node; node=node->next) {
+               TexMapping *tex_mapping= NULL;
+               ColorMapping *color_mapping= NULL;
+
+               if(node->type == SH_NODE_MAPPING) {
+                       tex_mapping= node->storage;
+                       tex_mapping->projx= PROJ_X;
+                       tex_mapping->projy= PROJ_Y;
+                       tex_mapping->projz= PROJ_Z;
+               }
+               else if(ELEM7(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_NOISE, SH_NODE_TEX_SKY,
+                       SH_NODE_TEX_BLEND, SH_NODE_TEX_VORONOI, SH_NODE_TEX_MAGIC, SH_NODE_TEX_MARBLE) ||
+                       ELEM6(node->type, SH_NODE_TEX_CLOUDS, SH_NODE_TEX_WOOD, SH_NODE_TEX_MUSGRAVE,
+                       SH_NODE_TEX_STUCCI, SH_NODE_TEX_DISTNOISE, SH_NODE_TEX_ENVIRONMENT)) {
+                       NodeTexBase *base= node->storage;
+
+                       if(node->type == SH_NODE_TEX_NOISE)
+                               node->storage= MEM_callocN(sizeof(NodeTexNoise), "NodeTexNoise");
+
+                       tex_mapping= &base->tex_mapping;
+                       color_mapping= &base->color_mapping;
+
+                       if(is_zero_v3(tex_mapping->size)) {
+                               default_tex_mapping(tex_mapping);
+                               default_color_mapping(color_mapping);
+                       }
+               }
+       }
+}
+
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
@@ -12339,6 +12373,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
                        }
                }
                                        cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
                        }
                }
+
+               {
+                       bNodeTreeType *ntreetype= ntreeGetType(NTREE_SHADER);
+
+                       if(ntreetype && ntreetype->foreach_nodetree)
+                               ntreetype->foreach_nodetree(main, NULL, do_version_ntree_tex_mapping_260);
+               }
        }
 
        /* put compatibility code here until next subversion bump */
        }
 
        /* put compatibility code here until next subversion bump */
index dd46c5cc7e7f1726b89f3500befec880fcdbf54b..0666884351a7520725557ff2745814225db825b6 100644 (file)
@@ -40,6 +40,7 @@ struct Object;
 struct Scene;
 struct SpaceImage;
 struct bContext;
 struct Scene;
 struct SpaceImage;
 struct bContext;
+struct bNode;
 struct wmKeyConfig;
 
 /* uvedit_ops.c */
 struct wmKeyConfig;
 
 /* uvedit_ops.c */
@@ -49,7 +50,7 @@ void ED_keymap_uvedit(struct wmKeyConfig *keyconf);
 void ED_uvedit_assign_image(struct Main *bmain, struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma);
 int ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float *min, float *max);
 
 void ED_uvedit_assign_image(struct Main *bmain, struct Scene *scene, struct Object *obedit, struct Image *ima, struct Image *previma);
 int ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obedit, float *min, float *max);
 
-int ED_object_get_active_image(struct Object *ob, int mat_nr, struct Image **ima, struct ImageUser **iuser);
+int ED_object_get_active_image(struct Object *ob, int mat_nr, struct Image **ima, struct ImageUser **iuser, struct bNode **node);
 void ED_object_assign_active_image(struct Main *bmain, struct Object *ob, int mat_nr, struct Image *ima);
 
 int ED_uvedit_test_silent(struct Object *obedit);
 void ED_object_assign_active_image(struct Main *bmain, struct Object *ob, int mat_nr, struct Image *ima);
 
 int ED_uvedit_test_silent(struct Object *obedit);
index abf12029b2317363afeb93fd636fe474dc85552c..982f33bd60055b4aa524c922d94eb930f3fd8b9c 100644 (file)
@@ -252,6 +252,11 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p)
                                }
                        }
 
                                }
                        }
 
+                       /* also preserve mapping for texture nodes */
+                       if(node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
+                          node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE)
+                               memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase));
+
                        /* remove node */
                        ui_node_remove_linked(ntree, node_prev);
                }
                        /* remove node */
                        ui_node_remove_linked(ntree, node_prev);
                }
index dc6a647cadad506400ca0a553fccb247f5cf1aa3..c8c1f083046f0fc5340b87e2821c9c1d07eaa22f 100644 (file)
@@ -489,7 +489,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index)
 
        if(scene_use_new_shading_nodes(s->scene)) {
                MFace *mf = s->me->mface+face_index;
 
        if(scene_use_new_shading_nodes(s->scene)) {
                MFace *mf = s->me->mface+face_index;
-               ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL);
+               ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL, NULL);
        }
        else {
                MTFace *tf = s->me->mtface+face_index;
        }
        else {
                MTFace *tf = s->me->mtface+face_index;
@@ -505,7 +505,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, int face_index)
 
        if(scene_use_new_shading_nodes(ps->scene)) {
                MFace *mf = ps->dm_mface+face_index;
 
        if(scene_use_new_shading_nodes(ps->scene)) {
                MFace *mf = ps->dm_mface+face_index;
-               ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL);
+               ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL);
        }
        else {
                MTFace *tf = ps->dm_mtface+face_index;
        }
        else {
                MTFace *tf = ps->dm_mtface+face_index;
index a00adec3dc789880b9556e801b0bbd68dc4b3430..e817565c5093cdced00ad37fd478528b723abee3 100644 (file)
@@ -597,7 +597,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
                        EditFace *efa= EM_get_actFace(em, sloppy);
 
                        if(efa)
                        EditFace *efa= EM_get_actFace(em, sloppy);
 
                        if(efa)
-                               ED_object_get_active_image(obedit, efa->mat_nr, &sima->image, NULL);
+                               ED_object_get_active_image(obedit, efa->mat_nr, &sima->image, NULL, NULL);
                }
                else {
                        /* old shading system, we set texface */
                }
                else {
                        /* old shading system, we set texface */
index 533d2555b26dad65c4bc1dc1ab747f20d69d615f..45713ff2a8ff6a78f36d93135c646988bf76957a 100644 (file)
@@ -946,28 +946,29 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA
 
 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 
 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
+       PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping");
        uiLayout *row;
        
        uiItemL(layout, "Translation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        uiLayout *row;
        
        uiItemL(layout, "Translation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "location", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "location", 0, "", ICON_NONE);
        
        uiItemL(layout, "Rotation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        
        uiItemL(layout, "Rotation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "rotation", 0, "", ICON_NONE);
        
        uiItemL(layout, "Scale:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        
        uiItemL(layout, "Scale:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE);
        
 #if 0
        row= uiLayoutRow(layout, 1);
        
 #if 0
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
-       uiItemR(row, ptr, "min", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "use_min", 0, "Min", ICON_NONE);
+       uiItemR(row, &mappingptr, "min", 0, "", ICON_NONE);
        
        row= uiLayoutRow(layout, 1);
        
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
-       uiItemR(row, ptr, "max", 0, "", ICON_NONE);
+       uiItemR(row, &mappingptr, "use_max", 0, "Max", ICON_NONE);
+       uiItemR(row, &mappingptr, "max", 0, "", ICON_NONE);
 #endif 
 }
 
 #endif 
 }
 
index 5b5f79160a1d2e11b197d971197e4a9b43861d7d..a932f1b10d98ffd32109e7e19a9763196ba3ca96 100644 (file)
@@ -108,7 +108,8 @@ void ED_node_changed_update(ID *id, bNode *node)
                        WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id);
        }
        else if(treetype==NTREE_COMPOSIT) {
                        WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id);
        }
        else if(treetype==NTREE_COMPOSIT) {
-               nodeUpdate(edittree, node);
+               if(node)
+                       nodeUpdate(edittree, node);
                /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */
                        
                node= node_tree_get_editgroup(nodetree);
                /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */
                        
                node= node_tree_get_editgroup(nodetree);
index 692d45f8303598bc9558bce1d1d643dbebee7a7e..e23824a221031aff294462e61ded59b0cc84690d 100644 (file)
 
 #include "DNA_material_types.h"
 #include "DNA_meshdata_types.h"
 
 #include "DNA_material_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_types.h"
 #include "DNA_property_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_property_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_view3d_types.h"
-#include "DNA_object_types.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_effect.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_effect.h"
@@ -703,16 +704,19 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
        GPUVertexAttribs *gattribs = attribs;
        Image *ima;
        ImageUser *iuser;
        GPUVertexAttribs *gattribs = attribs;
        Image *ima;
        ImageUser *iuser;
+       bNode *node;
        int texture_set= 0;
 
        /* draw image texture if we find one */
        int texture_set= 0;
 
        /* draw image texture if we find one */
-       if(ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser)) {
+       if(ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node)) {
                /* get openl texture */
                int mipmap= 1;
                int bindcode= (ima)? GPU_verify_image(ima, iuser, 0, 0, mipmap): 0;
                float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
                if(bindcode) {
                /* get openl texture */
                int mipmap= 1;
                int bindcode= (ima)? GPU_verify_image(ima, iuser, 0, 0, mipmap): 0;
                float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
                if(bindcode) {
+                       NodeTexBase *texbase= node->storage;
+
                        /* disable existing material */
                        GPU_disable_material();
                        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
                        /* disable existing material */
                        GPU_disable_material();
                        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
@@ -726,6 +730,10 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
                        glBindTexture(GL_TEXTURE_2D, ima->bindcode);
                        glColor3f(1.0f, 1.0f, 1.0f);
 
                        glBindTexture(GL_TEXTURE_2D, ima->bindcode);
                        glColor3f(1.0f, 1.0f, 1.0f);
 
+                       glMatrixMode(GL_TEXTURE);
+                       glLoadMatrixf(texbase->tex_mapping.mat);
+                       glMatrixMode(GL_MODELVIEW);
+
                        /* use active UV texture layer */
                        memset(gattribs, 0, sizeof(*gattribs));
 
                        /* use active UV texture layer */
                        memset(gattribs, 0, sizeof(*gattribs));
 
@@ -739,6 +747,10 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
        }
 
        if(!texture_set) {
        }
 
        if(!texture_set) {
+               glMatrixMode(GL_TEXTURE);
+               glLoadIdentity();
+               glMatrixMode(GL_MODELVIEW);
+
                /* disable texture */
                glDisable(GL_TEXTURE_2D);
                glDisable(GL_COLOR_MATERIAL);
                /* disable texture */
                glDisable(GL_TEXTURE_2D);
                glDisable(GL_COLOR_MATERIAL);
@@ -834,6 +846,10 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
        glBindTexture(GL_TEXTURE_2D, 0);
        glFrontFace(GL_CCW);
 
        glBindTexture(GL_TEXTURE_2D, 0);
        glFrontFace(GL_CCW);
 
+       glMatrixMode(GL_TEXTURE);
+       glLoadIdentity();
+       glMatrixMode(GL_MODELVIEW);
+
        /* faceselect mode drawing over textured mesh */
        if(!(ob == scene->obedit) && faceselect)
                draw_mesh_face_select(rv3d, ob->data, dm);
        /* faceselect mode drawing over textured mesh */
        if(!(ob == scene->obedit) && faceselect)
                draw_mesh_face_select(rv3d, ob->data, dm);
index 3019dcf1b8daf05c1729c2af881c5d1dd0179410..02653d29a506c261c06cacc839feecb91737ef6f 100644 (file)
@@ -101,7 +101,7 @@ static int is_image_texture_node(bNode *node)
        return ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT);
 }
 
        return ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT);
 }
 
-int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **iuser)
+int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **iuser, bNode **node_r)
 {
        Material *ma= give_current_material(ob, mat_nr);
        bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL;
 {
        Material *ma= give_current_material(ob, mat_nr);
        bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL;
@@ -109,11 +109,13 @@ int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **
        if(node && is_image_texture_node(node)) {
                if(ima) *ima= (Image*)node->id;
                if(iuser) *iuser= NULL;
        if(node && is_image_texture_node(node)) {
                if(ima) *ima= (Image*)node->id;
                if(iuser) *iuser= NULL;
+               if(node_r) *node_r= node;
                return TRUE;
        }
        
        if(ima) *ima= NULL;
        if(iuser) *iuser= NULL;
                return TRUE;
        }
        
        if(ima) *ima= NULL;
        if(iuser) *iuser= NULL;
+       if(node_r) *node_r= node;
 
        return FALSE;
 }
 
        return FALSE;
 }
index 13237495ceaee761bb05aacd94b24948d305b46a..3103bb9b7b35dac8082c937462eea8507d2f04ed 100644 (file)
@@ -35,6 +35,7 @@
 #include "DNA_ID.h"
 #include "DNA_vec_types.h"
 #include "DNA_listBase.h"
 #include "DNA_ID.h"
 #include "DNA_vec_types.h"
 #include "DNA_listBase.h"
+#include "DNA_texture_types.h"
 
 struct ID;
 struct ListBase;
 
 struct ID;
 struct ListBase;
@@ -426,25 +427,39 @@ typedef struct NodeColorspill {
        float uspillr, uspillg, uspillb;
 }NodeColorspill;
 
        float uspillr, uspillg, uspillb;
 }NodeColorspill;
 
+typedef struct NodeTexBase {
+       TexMapping tex_mapping;
+       ColorMapping color_mapping;
+} NodeTexBase;
+
+typedef struct NodeTexNoise {
+       NodeTexBase base;
+} NodeTexNoise;
+
 typedef struct NodeTexSky {
 typedef struct NodeTexSky {
+       NodeTexBase base;
        float sun_direction[3];
        float turbidity;
 } NodeTexSky;
 
 typedef struct NodeTexImage {
        float sun_direction[3];
        float turbidity;
 } NodeTexSky;
 
 typedef struct NodeTexImage {
+       NodeTexBase base;
        int color_space;
 } NodeTexImage;
 
 typedef struct NodeTexEnvironment {
        int color_space;
 } NodeTexImage;
 
 typedef struct NodeTexEnvironment {
+       NodeTexBase base;
        int color_space;
 } NodeTexEnvironment;
 
 typedef struct NodeTexBlend {
        int color_space;
 } NodeTexEnvironment;
 
 typedef struct NodeTexBlend {
+       NodeTexBase base;
        int progression;
        int axis;
 } NodeTexBlend;
 
 typedef struct NodeTexClouds {
        int progression;
        int axis;
 } NodeTexBlend;
 
 typedef struct NodeTexClouds {
+       NodeTexBase base;
        int hard;
        int depth;
        int basis;
        int hard;
        int depth;
        int basis;
@@ -452,16 +467,19 @@ typedef struct NodeTexClouds {
 } NodeTexClouds;
 
 typedef struct NodeTexVoronoi {
 } NodeTexClouds;
 
 typedef struct NodeTexVoronoi {
+       NodeTexBase base;
        int distance_metric;
        int coloring;
 } NodeTexVoronoi;
 
 typedef struct NodeTexMusgrave {
        int distance_metric;
        int coloring;
 } NodeTexVoronoi;
 
 typedef struct NodeTexMusgrave {
+       NodeTexBase base;
        int type;
        int basis;
 } NodeTexMusgrave;
 
 typedef struct NodeTexMarble {
        int type;
        int basis;
 } NodeTexMusgrave;
 
 typedef struct NodeTexMarble {
+       NodeTexBase base;
        int type;
        int wave;
        int basis;
        int type;
        int wave;
        int basis;
@@ -471,11 +489,13 @@ typedef struct NodeTexMarble {
 } NodeTexMarble;
 
 typedef struct NodeTexMagic {
 } NodeTexMarble;
 
 typedef struct NodeTexMagic {
+       NodeTexBase base;
        int depth;
        int pad;
 } NodeTexMagic;
 
 typedef struct NodeTexStucci {
        int depth;
        int pad;
 } NodeTexMagic;
 
 typedef struct NodeTexStucci {
+       NodeTexBase base;
        int type;
        int basis;
        int hard;
        int type;
        int basis;
        int hard;
@@ -483,11 +503,13 @@ typedef struct NodeTexStucci {
 } NodeTexStucci;
 
 typedef struct NodeTexDistortedNoise {
 } NodeTexStucci;
 
 typedef struct NodeTexDistortedNoise {
+       NodeTexBase base;
        int basis;
        int distortion_basis;
 } NodeTexDistortedNoise;
 
 typedef struct NodeTexWood {
        int basis;
        int distortion_basis;
 } NodeTexDistortedNoise;
 
 typedef struct NodeTexWood {
+       NodeTexBase base;
        int type;
        int wave;
        int basis;
        int type;
        int wave;
        int basis;
index 4cf31edb891064f24ec41fb3e33a1a14b3ac0696..1ecca5a0b2a48a9d0a7c1bce559e3b88755c9e13 100644 (file)
@@ -267,11 +267,13 @@ typedef struct Tex {
        
 } Tex;
 
        
 } Tex;
 
-/* used for mapping node. note: rot is in degrees */
+/* used for mapping and texture nodes. note: rot is in degrees */
 
 typedef struct TexMapping {
        float loc[3], rot[3], size[3];
        int flag;
 
 typedef struct TexMapping {
        float loc[3], rot[3], size[3];
        int flag;
+       char projx, projy, projz, mapping;
+       int pad;
        
        float mat[4][4];
        float min[3], max[3];
        
        float mat[4][4];
        float min[3], max[3];
@@ -279,10 +281,24 @@ typedef struct TexMapping {
 
 } TexMapping;
 
 
 } TexMapping;
 
+typedef struct ColorMapping {
+       struct ColorBand coba;
+
+       float bright, contrast, saturation;
+       int flag;
+
+       float blend_color[3];
+       float blend_factor;
+       int blend_type, pad[3];
+} ColorMapping;
+
 /* texmap->flag */
 /* texmap->flag */
-#define TEXMAP_CLIP_MIN        1
-#define TEXMAP_CLIP_MAX        2
+#define TEXMAP_CLIP_MIN                1
+#define TEXMAP_CLIP_MAX                2
+#define TEXMAP_UNIT_MATRIX     4
 
 
+/* colormap->flag */
+#define COLORMAP_USE_RAMP 1
 
 /* **************** TEX ********************* */
 
 
 /* **************** TEX ********************* */
 
index 554325117302e6c8d0b40b690665fb0e7e166dd5..db80f8906fd17eaba9e7690209507b6d25108509 100644 (file)
@@ -446,15 +446,6 @@ static void rna_NodeSocketVector_range(PointerRNA *ptr, float *min, float *max)
        *max = val->max;
 }
 
        *max = val->max;
 }
 
-static void rna_Node_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-       bNode *node= (bNode*)ptr->data;
-
-       init_mapping((TexMapping *)node->storage);
-       
-       rna_Node_update(bmain, scene, ptr);
-}
-
 static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        bNode *node= (bNode*)ptr->data;
 static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        bNode *node= (bNode*)ptr->data;
@@ -1104,48 +1095,12 @@ static void def_sh_material(StructRNA *srna)
 static void def_sh_mapping(StructRNA *srna)
 {
        PropertyRNA *prop;
 static void def_sh_mapping(StructRNA *srna)
 {
        PropertyRNA *prop;
-       
-       RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
 
 
-       prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
-       RNA_def_property_float_sdna(prop, NULL, "loc");
-       RNA_def_property_ui_text(prop, "Location", "Location offset for the input coordinate");
-       RNA_def_property_ui_range(prop, -10.f, 10.f, 0.1f, 2);
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_mapping_update");
-       
-       prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_XYZ); /* Not PROP_EUL, this is already in degrees, not radians */
-       RNA_def_property_float_sdna(prop, NULL, "rot");
-       RNA_def_property_ui_text(prop, "Rotation", "Rotation offset for the input coordinate");
-       RNA_def_property_ui_range(prop, -360.f, 360.f, 1.f, 2);
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_mapping_update");
-       
-       prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
-       RNA_def_property_float_sdna(prop, NULL, "size");
-       RNA_def_property_ui_text(prop, "Scale", "Scale adjustment for the input coordinate");
-       RNA_def_property_ui_range(prop, -10.f, 10.f, 0.1f, 2);
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_mapping_update");
-       
-       prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
-       RNA_def_property_ui_text(prop, "Clamp Minimum", "Clamp the output coordinate to a minimum value");
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-       
-       prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
-       RNA_def_property_float_sdna(prop, NULL, "min");
-       RNA_def_property_ui_text(prop, "Minimum", "Minimum value to clamp coordinate to");
-       RNA_def_property_ui_range(prop, -10.f, 10.f, 0.1f, 2);
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-       
-       prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
-       RNA_def_property_ui_text(prop, "Clamp Maximum", "Clamp the output coordinate to a maximum value");
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-       
-       prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
-       RNA_def_property_float_sdna(prop, NULL, "max");
-       RNA_def_property_ui_text(prop, "Maximum", "Maximum value to clamp coordinate to");
-       RNA_def_property_ui_range(prop, -10.f, 10.f, 0.1f, 2);
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+       prop= RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "storage");
+       RNA_def_property_struct_type(prop, "TexMapping");
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_ui_text(prop, "Mapping", "Texture coordinate mapping settings");
 }
 
 static void def_sh_geometry(StructRNA *srna)
 }
 
 static void def_sh_geometry(StructRNA *srna)
@@ -1177,11 +1132,33 @@ static void def_sh_attribute(StructRNA *srna)
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
+static void def_sh_tex(StructRNA *srna)
+{
+       PropertyRNA *prop;
+
+       prop= RNA_def_property(srna, "texture_mapping", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "base.tex_mapping");
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_ui_text(prop, "Texture Mapping", "Texture coordinate mapping settings");
+
+       prop= RNA_def_property(srna, "color_mapping", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "base.color_mapping");
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_ui_text(prop, "Color Mapping", "Color mapping settings");
+}
+
+static void def_sh_tex_noise(StructRNA *srna)
+{
+       RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage");
+       def_sh_tex(srna);
+}
+
 static void def_sh_tex_sky(StructRNA *srna)
 {
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexSky", "storage");
 static void def_sh_tex_sky(StructRNA *srna)
 {
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexSky", "storage");
+       def_sh_tex(srna);
        
        prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
        RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
        
        prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
        RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
@@ -1209,6 +1186,7 @@ static void def_sh_tex_environment(StructRNA *srna)
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
        RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
        RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_color_space_items);
 
        prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_color_space_items);
@@ -1233,6 +1211,7 @@ static void def_sh_tex_image(StructRNA *srna)
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
        RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
        RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
        RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_color_space_items);
 
        prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, prop_color_space_items);
@@ -1260,6 +1239,7 @@ static void def_sh_tex_blend(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexBlend", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexBlend", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "progression", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "progression");
 
        prop= RNA_def_property(srna, "progression", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "progression");
@@ -1279,6 +1259,7 @@ static void def_sh_tex_clouds(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexClouds", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexClouds", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
@@ -1304,6 +1285,7 @@ static void def_sh_tex_distnoise(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexDistortedNoise", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexDistortedNoise", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
@@ -1323,6 +1305,7 @@ static void def_sh_tex_magic(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMagic", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMagic", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "depth");
 
        prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "depth");
@@ -1342,6 +1325,7 @@ static void def_sh_tex_marble(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMarble", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMarble", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "marble_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
 
        prop= RNA_def_property(srna, "marble_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -1387,6 +1371,7 @@ static void def_sh_tex_musgrave(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMusgrave", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexMusgrave", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
 
        prop= RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -1412,6 +1397,7 @@ static void def_sh_tex_stucci(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexStucci", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexStucci", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "stucci_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
 
        prop= RNA_def_property(srna, "stucci_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -1454,6 +1440,7 @@ static void def_sh_tex_voronoi(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "distance_metric");
 
        prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "distance_metric");
@@ -1480,6 +1467,7 @@ static void def_sh_tex_wood(StructRNA *srna)
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexWood", "storage");
        PropertyRNA *prop;
        
        RNA_def_struct_sdna_from(srna, "NodeTexWood", "storage");
+       def_sh_tex(srna);
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
 
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "basis");
index 6744dc77469301fb0c8045410ac10695e93c34e9..c74d8943bcfebd8810885f9c9c685a87ba520761 100644 (file)
@@ -79,7 +79,7 @@ DefNode( ShaderNode,     SH_NODE_GEOMETRY,           0,                      "GE
 DefNode( ShaderNode,     SH_NODE_LIGHT_PATH,         0,                      "LIGHT_PATH", Light_path, "Light_path", "")
 DefNode( ShaderNode,     SH_NODE_TEX_IMAGE,          def_sh_tex_image,       "TEX_IMAGE", TexImage, "Image Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_ENVIRONMENT,    def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture", "")
 DefNode( ShaderNode,     SH_NODE_LIGHT_PATH,         0,                      "LIGHT_PATH", Light_path, "Light_path", "")
 DefNode( ShaderNode,     SH_NODE_TEX_IMAGE,          def_sh_tex_image,       "TEX_IMAGE", TexImage, "Image Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_ENVIRONMENT,    def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture", "")
-DefNode( ShaderNode,     SH_NODE_TEX_NOISE,          0,                      "TEX_NOISE", TexNoise, "Noise Texture", "")
+DefNode( ShaderNode,     SH_NODE_TEX_NOISE,          def_sh_tex_noise,       "TEX_NOISE", TexNoise, "Noise Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_SKY,            def_sh_tex_sky,         "TEX_SKY", TexSky, "Sky Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_BLEND,          def_sh_tex_blend,       "TEX_BLEND", TexBlend, "Blend Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_CLOUDS,         def_sh_tex_clouds,      "TEX_CLOUDS", TexClouds, "Clouds Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_SKY,            def_sh_tex_sky,         "TEX_SKY", TexSky, "Sky Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_BLEND,          def_sh_tex_blend,       "TEX_BLEND", TexBlend, "Blend Texture", "")
 DefNode( ShaderNode,     SH_NODE_TEX_CLOUDS,         def_sh_tex_clouds,      "TEX_CLOUDS", TexClouds, "Clouds Texture", "")
index 5793a2ba6f14302a5dd777422eff21207fa20628..8315ff4f2c219c009a4055624a098475d0359fb6 100644 (file)
@@ -114,13 +114,14 @@ EnumPropertyItem viewport_shade_items[] = {
 
 #include "BLI_math.h"
 
 
 #include "BLI_math.h"
 
-#include "BKE_screen.h"
 #include "BKE_animsys.h"
 #include "BKE_brush.h"
 #include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_paint.h"
 #include "BKE_animsys.h"
 #include "BKE_brush.h"
 #include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_paint.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
 
 #include "ED_image.h"
 #include "ED_node.h"
 
 #include "ED_image.h"
 #include "ED_node.h"
@@ -458,11 +459,12 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_WIRE);
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_SOLID);
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_TEXTURE);
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_WIRE);
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_SOLID);
        RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_TEXTURE);
-       RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_MATERIAL);
+
+       if(scene_use_new_shading_nodes(scene))
+               RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_MATERIAL);
        
        
-       if(type->view_draw) {
+       if(type->view_draw)
                RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_RENDER);
                RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_RENDER);
-       }
 
        RNA_enum_item_end(&item, &totitem);
        *free= 1;
 
        RNA_enum_item_end(&item, &totitem);
        *free= 1;
index c420ecefdae4df1969710b555df17540f2d98b1b..aac4da9e6f6dd9419511431d86aa29863166f2cd 100644 (file)
@@ -75,6 +75,25 @@ EnumPropertyItem texture_type_items[] = {
        {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - Wave generated bands or rings, with optional noise"},
        {0, NULL, 0, NULL, NULL}};
 
        {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - Wave generated bands or rings, with optional noise"},
        {0, NULL, 0, NULL, NULL}};
 
+EnumPropertyItem blend_type_items[] = {
+       {MTEX_BLEND, "MIX", 0, "Mix", ""},
+       {MTEX_ADD, "ADD", 0, "Add", ""},
+       {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""},
+       {MTEX_MUL, "MULTIPLY", 0, "Multiply", ""},
+       {MTEX_SCREEN, "SCREEN", 0, "Screen", ""},
+       {MTEX_OVERLAY, "OVERLAY", 0, "Overlay", ""},
+       {MTEX_DIFF, "DIFFERENCE", 0, "Difference", ""},
+       {MTEX_DIV, "DIVIDE", 0, "Divide", ""},
+       {MTEX_DARK, "DARKEN", 0, "Darken", ""},
+       {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""},
+       {MTEX_BLEND_HUE, "HUE", 0, "Hue", ""},
+       {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""},
+       {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""},
+       {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""},
+       {MTEX_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, 
+       {MTEX_LIN_LIGHT    , "LINEAR_LIGHT", 0, "Linear Light", ""}, 
+       {0, NULL, 0, NULL, NULL}};
+
 #ifdef RNA_RUNTIME
 
 #include "MEM_guardedalloc.h"
 #ifdef RNA_RUNTIME
 
 #include "MEM_guardedalloc.h"
@@ -131,13 +150,33 @@ static StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
        }
 }
 
        }
 }
 
-static void rna_Texture_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Texture_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
 {
 {
-       Tex *tex= ptr->id.data;
+       ID *id= ptr->id.data;
 
 
-       DAG_id_tag_update(&tex->id, 0);
-       WM_main_add_notifier(NC_TEXTURE, tex);
-       WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, NULL);
+       if(GS(id->name) == ID_TE) {
+               Tex *tex= ptr->id.data;
+
+               DAG_id_tag_update(&tex->id, 0);
+               WM_main_add_notifier(NC_TEXTURE, tex);
+               WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, NULL);
+       }
+       else if(GS(id->name) == ID_NT) {
+               bNodeTree *ntree= ptr->id.data;
+               ED_node_generic_update(bmain, ntree, NULL);
+       }
+}
+
+static void rna_Texture_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       TexMapping *texmap = ptr->data;
+       init_tex_mapping(texmap);
+       rna_Texture_update(bmain, scene, ptr);
+}
+
+static void rna_Color_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       /* nothing to do */
 }
 
 static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 }
 
 static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -400,71 +439,139 @@ static char *rna_VoxelData_path(PointerRNA *UNUSED(ptr))
 
 static void rna_def_texmapping(BlenderRNA *brna)
 {
 
 static void rna_def_texmapping(BlenderRNA *brna)
 {
+       static EnumPropertyItem prop_mapping_items[] = {
+               {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
+               {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
+               {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
+               {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
+               {0, NULL, 0, NULL, NULL}};
+               
+       static EnumPropertyItem prop_xyz_mapping_items[] = {
+               {0, "NONE", 0, "None", ""},
+               {1, "X", 0, "X", ""},
+               {2, "Y", 0, "Y", ""},
+               {3, "Z", 0, "Z", ""},
+               {0, NULL, 0, NULL, NULL}};
+
        StructRNA *srna;
        PropertyRNA *prop;
        
        srna= RNA_def_struct(brna, "TexMapping", NULL);
        StructRNA *srna;
        PropertyRNA *prop;
        
        srna= RNA_def_struct(brna, "TexMapping", NULL);
-       RNA_def_struct_ui_text(srna, "Texture Mapping", "Mapping settings");
+       RNA_def_struct_ui_text(srna, "Texture Mapping", "Texture coordinate mapping settings");
 
        prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
        RNA_def_property_float_sdna(prop, NULL, "loc");
        RNA_def_property_ui_text(prop, "Location", "");
 
        prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
        RNA_def_property_float_sdna(prop, NULL, "loc");
        RNA_def_property_ui_text(prop, "Location", "");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        
-       prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
+       prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_XYZ); /* Not PROP_EUL, this is already in degrees, not radians */
        RNA_def_property_float_sdna(prop, NULL, "rot");
        RNA_def_property_ui_text(prop, "Rotation", "");
        RNA_def_property_float_sdna(prop, NULL, "rot");
        RNA_def_property_ui_text(prop, "Rotation", "");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "size");
        RNA_def_property_ui_text(prop, "Scale", "");
        
        prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "size");
        RNA_def_property_ui_text(prop, "Scale", "");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "min");
        RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
        
        prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "min");
        RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "max");
        RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
        
        prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
        RNA_def_property_float_sdna(prop, NULL, "max");
        RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        prop= RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
        RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
        
        prop= RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
        RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
        
        prop= RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
        RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
        
        prop= RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
        RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
-       RNA_def_property_update(prop, 0, "rna_Texture_update");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
+
+       prop= RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "projx");
+       RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
+       RNA_def_property_ui_text(prop, "X Mapping", "");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
+       
+       prop= RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "projy");
+       RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
+       RNA_def_property_ui_text(prop, "Y Mapping", "");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
+       
+       prop= RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "projz");
+       RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
+       RNA_def_property_ui_text(prop, "Z Mapping", "");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
+
+       prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_mapping_items);
+       RNA_def_property_ui_text(prop, "Mapping", "");
+       RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
 }
 
 }
 
-static void rna_def_mtex(BlenderRNA *brna)
+static void rna_def_colormapping(BlenderRNA *brna)
 {
        StructRNA *srna;
        PropertyRNA *prop;
 {
        StructRNA *srna;
        PropertyRNA *prop;
+       
+       srna= RNA_def_struct(brna, "ColorMapping", NULL);
+       RNA_def_struct_ui_text(srna, "Color Mapping", "Color mapping settings");
 
 
-       static EnumPropertyItem prop_blend_type_items[] = {
-               {MTEX_BLEND, "MIX", 0, "Mix", ""},
-               {MTEX_ADD, "ADD", 0, "Add", ""},
-               {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""},
-               {MTEX_MUL, "MULTIPLY", 0, "Multiply", ""},
-               {MTEX_SCREEN, "SCREEN", 0, "Screen", ""},
-               {MTEX_OVERLAY, "OVERLAY", 0, "Overlay", ""},
-               {MTEX_DIFF, "DIFFERENCE", 0, "Difference", ""},
-               {MTEX_DIV, "DIVIDE", 0, "Divide", ""},
-               {MTEX_DARK, "DARKEN", 0, "Darken", ""},
-               {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""},
-               {MTEX_BLEND_HUE, "HUE", 0, "Hue", ""},
-               {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""},
-               {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""},
-               {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""},
-               {MTEX_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, 
-               {MTEX_LIN_LIGHT    , "LINEAR_LIGHT", 0, "Linear Light", ""}, 
-               {0, NULL, 0, NULL, NULL}};
+       prop= RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMAP_USE_RAMP);
+       RNA_def_property_ui_text(prop, "Use Color Ramp", "Toggle color ramp operations");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
+       RNA_def_property_pointer_sdna(prop, NULL, "coba");
+       RNA_def_property_struct_type(prop, "ColorRamp");
+       RNA_def_property_ui_text(prop, "Color Ramp", "");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "brightness", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "bright");
+       RNA_def_property_range(prop, 0, 2);
+       RNA_def_property_ui_text(prop, "Brightness", "Adjust the brightness of the texture");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0.01, 5);
+       RNA_def_property_ui_text(prop, "Contrast", "Adjust the contrast of the texture");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0, 2);
+       RNA_def_property_ui_text(prop, "Saturation", "Adjust the saturation of colors in the texture");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, blend_type_items);
+       RNA_def_property_ui_text(prop, "Blend Type", "Mode used to mix with texture output color");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "blend_color", PROP_FLOAT, PROP_COLOR);
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Color", "Blend color to mix with texture output color");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+
+       prop= RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_ui_text(prop, "Blend Factor", "");
+       RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
+}
+
+static void rna_def_mtex(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
 
        static EnumPropertyItem output_node_items[] = {
                {0, "DUMMY", 0, "Dummy", ""},
 
        static EnumPropertyItem output_node_items[] = {
                {0, "DUMMY", 0, "Dummy", ""},
@@ -512,7 +619,7 @@ static void rna_def_mtex(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "blendtype");
 
        prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "blendtype");
-       RNA_def_property_enum_items(prop, prop_blend_type_items);
+       RNA_def_property_enum_items(prop, blend_type_items);
        RNA_def_property_ui_text(prop, "Blend Type", "Mode used to apply the texture");
        RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
 
        RNA_def_property_ui_text(prop, "Blend Type", "Mode used to apply the texture");
        RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
 
@@ -1866,6 +1973,7 @@ void RNA_def_texture(BlenderRNA *brna)
        rna_def_mtex(brna);
        rna_def_environment_map(brna);
        rna_def_texmapping(brna);
        rna_def_mtex(brna);
        rna_def_environment_map(brna);
        rna_def_texmapping(brna);
+       rna_def_colormapping(brna);
 }
 
 #endif
 }
 
 #endif
index 81e963d4790bf6cc345688078c407665a7b105c1..6930fbf0664b67c4220d7417b013ceb8cd2f6173 100644 (file)
@@ -79,7 +79,7 @@ static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeS
 
 static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
 
 static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
-       node->storage= add_mapping();
+       node->storage= add_tex_mapping();
 }
 
 void register_node_type_cmp_map_value(ListBase *lb)
 }
 
 void register_node_type_cmp_map_value(ListBase *lb)
index 8c5750f3ae2db0e32c46fc25a9e7d280d2c675d5..468f593773defceec29ea4908415a17f61407f89 100644 (file)
@@ -308,3 +308,24 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
                }
        }
 }
                }
        }
 }
+
+void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *UNUSED(out))
+{
+       NodeTexBase *base= node->storage;
+       TexMapping *texmap= &base->tex_mapping;
+       float domin= (texmap->flag & TEXMAP_CLIP_MIN) != 0;
+       float domax= (texmap->flag & TEXMAP_CLIP_MAX) != 0;
+
+       if(domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) {
+               GPUNodeLink *tmat = GPU_uniform((float*)texmap->mat);
+               GPUNodeLink *tmin = GPU_uniform(texmap->min);
+               GPUNodeLink *tmax = GPU_uniform(texmap->max);
+               GPUNodeLink *tdomin = GPU_uniform(&domin);
+               GPUNodeLink *tdomax = GPU_uniform(&domax);
+
+               GPU_link(mat, "mapping", in[0].link, tmat, tmin, tmax, tdomin, tdomax, &in[0].link);
+       }
+       else
+               printf("skip mapping!\n");
+}
+
index f18310d351d9405a7ccc3c44dc2484723b25317f..19976ada3ec68002a31dcee86cd51c6911f8fb62 100644 (file)
@@ -128,6 +128,7 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns);
 
 void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeStack *ns);
 void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
 
 void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeStack *ns);
 void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
+void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
 
 void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
 
 
 void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
 
index 36ac25dbd4d94f703d801a623e1f301b3ef57ef4..2eff74651effc7ee34d0afe76ae17fc68420dde1 100644 (file)
@@ -67,9 +67,9 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack
 }
 
 
 }
 
 
-static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_shader_default_mapping(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
 {
-       node->storage= add_mapping();
+       node->storage= add_tex_mapping();
 }
 
 static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 }
 
 static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
@@ -94,7 +94,7 @@ void register_node_type_sh_mapping(ListBase *lb)
        node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING);
        node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
        node_type_size(&ntype, 240, 160, 320);
        node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING);
        node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
        node_type_size(&ntype, 240, 160, 320);
-       node_type_init(&ntype, node_shader_init_mapping);
+       node_type_init(&ntype, node_shader_default_mapping);
        node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
        node_type_exec(&ntype, node_shader_exec_mapping);
        node_type_gpu(&ntype, gpu_shader_mapping);
        node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
        node_type_exec(&ntype, node_shader_exec_mapping);
        node_type_gpu(&ntype, gpu_shader_mapping);
index 659b0cadd5b13d8acc8652de3fe5fadb6dfbeead..50bafede2aa3e291d7789d3d06426a176a8ee816 100644 (file)
@@ -88,6 +88,8 @@ static bNodeSocketTemplate sh_node_tex_blend_out[]= {
 static void node_shader_init_tex_blend(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexBlend *tex = MEM_callocN(sizeof(NodeTexBlend), "NodeTexBlend");
 static void node_shader_init_tex_blend(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexBlend *tex = MEM_callocN(sizeof(NodeTexBlend), "NodeTexBlend");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->progression = SHD_BLEND_LINEAR;
        tex->axis = SHD_BLEND_HORIZONTAL;
 
        tex->progression = SHD_BLEND_LINEAR;
        tex->axis = SHD_BLEND_HORIZONTAL;
 
@@ -109,11 +111,13 @@ static void node_shader_exec_tex_blend(void *data, bNode *node, bNodeStack **in,
        out[0]->vec[0]= blend(vec, tex->progression, tex->axis);
 }
 
        out[0]->vec[0]= blend(vec, tex->progression, tex->axis);
 }
 
-static int node_shader_gpu_tex_blend(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_blend(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_blend", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_blend", in, out);
 }
 
index c38dd155a7b70e717eb01681faae565bea7ed3c9..12f117995bc3b7d3799c02f536f7a49a94b538e4 100644 (file)
@@ -68,6 +68,8 @@ static bNodeSocketTemplate sh_node_tex_clouds_out[]= {
 static void node_shader_init_tex_clouds(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexClouds *tex = MEM_callocN(sizeof(NodeTexClouds), "NodeTexClouds");
 static void node_shader_init_tex_clouds(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexClouds *tex = MEM_callocN(sizeof(NodeTexClouds), "NodeTexClouds");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->basis = SHD_NOISE_PERLIN;
        tex->hard = 0;
        tex->depth = 2;
        tex->basis = SHD_NOISE_PERLIN;
        tex->hard = 0;
        tex->depth = 2;
@@ -92,11 +94,13 @@ static void node_shader_exec_tex_clouds(void *data, bNode *node, bNodeStack **in
        out[1]->vec[0]= clouds(tex->basis, tex->hard, tex->depth, size, vec, out[0]->vec);
 }
 
        out[1]->vec[0]= clouds(tex->basis, tex->hard, tex->depth, size, vec, out[0]->vec);
 }
 
-static int node_shader_gpu_tex_clouds(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_clouds(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_clouds", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_clouds", in, out);
 }
 
index c28fef9e472352b26fe5fef28ff3efae62f31d05..56a87949fc708e8de6cd07ac8caaa8df2a3406fa 100644 (file)
@@ -65,6 +65,8 @@ static bNodeSocketTemplate sh_node_tex_distnoise_out[]= {
 static void node_shader_init_tex_distorted_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexDistortedNoise *tex = MEM_callocN(sizeof(NodeTexDistortedNoise), "NodeTexDistortedNoise");
 static void node_shader_init_tex_distorted_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexDistortedNoise *tex = MEM_callocN(sizeof(NodeTexDistortedNoise), "NodeTexDistortedNoise");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->basis = SHD_NOISE_PERLIN;
        tex->distortion_basis = SHD_NOISE_PERLIN;
 
        tex->basis = SHD_NOISE_PERLIN;
        tex->distortion_basis = SHD_NOISE_PERLIN;
 
@@ -89,11 +91,13 @@ static void node_shader_exec_tex_distnoise(void *data, bNode *node, bNodeStack *
        out[0]->vec[0]= distorted_noise(vec, size, tex->basis, tex->distortion_basis, distortion);
 }
 
        out[0]->vec[0]= distorted_noise(vec, size, tex->basis, tex->distortion_basis, distortion);
 }
 
-static int node_shader_gpu_tex_distnoise(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_distnoise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_distnoise", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_distnoise", in, out);
 }
 
index 7fbd5142e2290cd9b74b2f2025bb1e55d733d0d7..3c0a1a22e5ac01debc5e325f2aa87c9f3ef404a2 100644 (file)
@@ -44,6 +44,8 @@ static bNodeSocketTemplate sh_node_tex_environment_out[]= {
 static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexEnvironment *tex = MEM_callocN(sizeof(NodeTexEnvironment), "NodeTexEnvironment");
 static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexEnvironment *tex = MEM_callocN(sizeof(NodeTexEnvironment), "NodeTexEnvironment");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->color_space = SHD_COLORSPACE_SRGB;
 
        node->storage = tex;
        tex->color_space = SHD_COLORSPACE_SRGB;
 
        node->storage = tex;
@@ -94,6 +96,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod
        if(!in[0].link)
                in[0].link = GPU_builtin(GPU_VIEW_POSITION);
 
        if(!in[0].link)
                in[0].link = GPU_builtin(GPU_VIEW_POSITION);
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser));
 }
 
        return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser));
 }
 
index 11a2c914746163c4f7e407ce88b531f82455ca1d..562884a9ed9490c7d4ffbf97a36e091d5125be0f 100644 (file)
@@ -44,6 +44,8 @@ static bNodeSocketTemplate sh_node_tex_image_out[]= {
 static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage");
 static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->color_space = SHD_COLORSPACE_SRGB;
 
        node->storage = tex;
        tex->color_space = SHD_COLORSPACE_SRGB;
 
        node->storage = tex;
@@ -92,6 +94,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_MTFACE, "");
 
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_MTFACE, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser));
 }
 
        return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser));
 }
 
index 5ccb42d99c4a2b64601d3bc8800a0ca46fe630fe..8d0a2d3fb85abca23d01350cad202f305491734d 100644 (file)
@@ -118,6 +118,8 @@ static bNodeSocketTemplate sh_node_tex_magic_out[]= {
 static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMagic *tex = MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic");
 static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMagic *tex = MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->depth = 2;
 
        node->storage = tex;
        tex->depth = 2;
 
        node->storage = tex;
@@ -148,6 +150,8 @@ static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, GPUNodeStack
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_magic", in, out, GPU_uniform(&depth));
 }
 
        return GPU_stack_link(mat, "node_tex_magic", in, out, GPU_uniform(&depth));
 }
 
index 5b9b30080383b79bae3f36eff35ab9585519546a..3bb999659c970897b902f1a18c41c33e234bb5a4 100644 (file)
@@ -70,6 +70,8 @@ static bNodeSocketTemplate sh_node_tex_marble_out[]= {
 static void node_shader_init_tex_marble(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMarble *tex = MEM_callocN(sizeof(NodeTexMarble), "NodeTexMarble");
 static void node_shader_init_tex_marble(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMarble *tex = MEM_callocN(sizeof(NodeTexMarble), "NodeTexMarble");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->type = SHD_MARBLE_SOFT;
        tex->wave = SHD_WAVE_SINE;
        tex->basis = SHD_NOISE_PERLIN;
        tex->type = SHD_MARBLE_SOFT;
        tex->wave = SHD_WAVE_SINE;
        tex->basis = SHD_NOISE_PERLIN;
@@ -97,11 +99,13 @@ static void node_shader_exec_tex_marble(void *data, bNode *node, bNodeStack **in
        out[0]->vec[0]= marble(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence, tex->depth);
 }
 
        out[0]->vec[0]= marble(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence, tex->depth);
 }
 
-static int node_shader_gpu_tex_marble(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_marble(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_marble", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_marble", in, out);
 }
 
index f8586b5e9aca6ae8bf6ce4c8dff7bd26133e90fa..7cf33445a5d3ea36f94a5c88b2098b61d3636287 100644 (file)
@@ -234,6 +234,8 @@ static bNodeSocketTemplate sh_node_tex_musgrave_out[]= {
 static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave");
 static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->type = SHD_MUSGRAVE_FBM;
        tex->basis = SHD_NOISE_PERLIN;
 
        tex->type = SHD_MUSGRAVE_FBM;
        tex->basis = SHD_NOISE_PERLIN;
 
@@ -262,11 +264,13 @@ static void node_shader_exec_tex_musgrave(void *data, bNode *node, bNodeStack **
        out[0]->vec[0]= musgrave(tex->type, tex->basis, dimension, lacunarity, octaves, offset, 1.0f, gain, size, vec);
 }
 
        out[0]->vec[0]= musgrave(tex->type, tex->basis, dimension, lacunarity, octaves, offset, 1.0f, gain, size, vec);
 }
 
-static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_musgrave", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_musgrave", in, out);
 }
 
index 32f88e998a5bde069ebf1d00bd70cc699afd2168..e8fb47373051327f8ee002c68e7e33b0f4b83e6a 100644 (file)
@@ -59,6 +59,15 @@ static bNodeSocketTemplate sh_node_tex_noise_out[]= {
        {       -1, 0, ""       }
 };
 
        {       -1, 0, ""       }
 };
 
+static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexNoise *tex = MEM_callocN(sizeof(NodeTexNoise), "NodeTexNoise");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
+
+       node->storage = tex;
+}
+
 static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
        ShaderCallData *scd= (ShaderCallData*)data;
 static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
        ShaderCallData *scd= (ShaderCallData*)data;
@@ -74,11 +83,13 @@ static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in,
        out[1]->vec[0]= noise_texture_value(vec);
 }
 
        out[1]->vec[0]= noise_texture_value(vec);
 }
 
-static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_noise", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_noise", in, out);
 }
 
@@ -91,7 +102,7 @@ void register_node_type_sh_tex_noise(ListBase *lb)
        node_type_compatibility(&ntype, NODE_NEW_SHADING);
        node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
        node_type_size(&ntype, 150, 60, 200);
        node_type_compatibility(&ntype, NODE_NEW_SHADING);
        node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
        node_type_size(&ntype, 150, 60, 200);
-       node_type_init(&ntype, NULL);
+       node_type_init(&ntype, node_shader_init_tex_noise);
        node_type_storage(&ntype, "", NULL, NULL);
        node_type_exec(&ntype, node_shader_exec_tex_noise);
        node_type_gpu(&ntype, node_shader_gpu_tex_noise);
        node_type_storage(&ntype, "", NULL, NULL);
        node_type_exec(&ntype, node_shader_exec_tex_noise);
        node_type_gpu(&ntype, node_shader_gpu_tex_noise);
index b43f7bd29245377b0cdb37e3be6f95a9998fc22d..6fb1f4f51cf6a7cda7b9e18546caef7de2626556 100644 (file)
@@ -44,6 +44,8 @@ static bNodeSocketTemplate sh_node_tex_sky_out[]= {
 static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexSky *tex = MEM_callocN(sizeof(NodeTexSky), "NodeTexSky");
 static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexSky *tex = MEM_callocN(sizeof(NodeTexSky), "NodeTexSky");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->sun_direction[0] = 0.0f;
        tex->sun_direction[1] = 0.0f;
        tex->sun_direction[2] = 1.0f;
        tex->sun_direction[0] = 0.0f;
        tex->sun_direction[1] = 0.0f;
        tex->sun_direction[2] = 1.0f;
@@ -56,11 +58,13 @@ static void node_shader_exec_tex_sky(void *UNUSED(data), bNode *UNUSED(node), bN
 {
 }
 
 {
 }
 
-static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_sky", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_sky", in, out);
 }
 
index 4540e2c982b4ebb9ffeb6f535a02d0f51e851ea6..3eb315052a9deed43122f1eab55433064608dad0 100644 (file)
@@ -67,6 +67,8 @@ static bNodeSocketTemplate sh_node_tex_stucci_out[]= {
 static void node_shader_init_tex_stucci(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexStucci *tex = MEM_callocN(sizeof(NodeTexStucci), "NodeTexStucci");
 static void node_shader_init_tex_stucci(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexStucci *tex = MEM_callocN(sizeof(NodeTexStucci), "NodeTexStucci");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->type = SHD_STUCCI_PLASTIC;
        tex->basis = SHD_NOISE_PERLIN;
        tex->hard = 0;
        tex->type = SHD_STUCCI_PLASTIC;
        tex->basis = SHD_NOISE_PERLIN;
        tex->hard = 0;
@@ -92,11 +94,13 @@ static void node_shader_exec_tex_stucci(void *data, bNode *node, bNodeStack **in
        out[0]->vec[0]= stucci(tex->type, tex->basis, tex->hard, turbulence, size, vec);
 }
 
        out[0]->vec[0]= stucci(tex->type, tex->basis, tex->hard, turbulence, size, vec);
 }
 
-static int node_shader_gpu_tex_stucci(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_stucci(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_stucci", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_stucci", in, out);
 }
 
index b942aa00fb427df06cc5bc48bf8ffea9cbf3a01f..ee8838ca1b3953c20e8e93dd55b13e83eec57a6d 100644 (file)
@@ -109,6 +109,8 @@ static bNodeSocketTemplate sh_node_tex_voronoi_out[]= {
 static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi");
 static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->distance_metric = SHD_VORONOI_ACTUAL_DISTANCE;
        tex->coloring = SHD_VORONOI_INTENSITY;
 
        tex->distance_metric = SHD_VORONOI_ACTUAL_DISTANCE;
        tex->coloring = SHD_VORONOI_INTENSITY;
 
@@ -138,11 +140,13 @@ static void node_shader_exec_tex_voronoi(void *data, bNode *node, bNodeStack **i
                exponent, 1.0f, size, vec, out[0]->vec);
 }
 
                exponent, 1.0f, size, vec, out[0]->vec);
 }
 
-static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_voronoi", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_voronoi", in, out);
 }
 
index 4fb11743882af9b09b33fb35ce4e6db93604857c..f1beb8e5d7dc5f4ccdf6c0a3dda42377b04682c7 100644 (file)
@@ -73,6 +73,8 @@ static bNodeSocketTemplate sh_node_tex_wood_out[]= {
 static void node_shader_init_tex_wood(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexWood *tex = MEM_callocN(sizeof(NodeTexWood), "NodeTexWood");
 static void node_shader_init_tex_wood(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeTexWood *tex = MEM_callocN(sizeof(NodeTexWood), "NodeTexWood");
+       default_tex_mapping(&tex->base.tex_mapping);
+       default_color_mapping(&tex->base.color_mapping);
        tex->type = SHD_WOOD_BANDS;
        tex->wave = SHD_WAVE_SINE;
        tex->basis = SHD_NOISE_PERLIN;
        tex->type = SHD_WOOD_BANDS;
        tex->wave = SHD_WAVE_SINE;
        tex->basis = SHD_NOISE_PERLIN;
@@ -99,11 +101,13 @@ static void node_shader_exec_tex_wood(void *data, bNode *node, bNodeStack **in,
        out[0]->vec[0]= wood(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence);
 }
 
        out[0]->vec[0]= wood(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence);
 }
 
-static int node_shader_gpu_tex_wood(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+static int node_shader_gpu_tex_wood(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
 {
        if(!in[0].link)
                in[0].link = GPU_attribute(CD_ORCO, "");
 
+       node_shader_gpu_tex_mapping(mat, node, in, out);
+
        return GPU_stack_link(mat, "node_tex_wood", in, out);
 }
 
        return GPU_stack_link(mat, "node_tex_wood", in, out);
 }