Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-05 00:58:00 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-05 00:58:00 +0400
commit72929172dd0d3d51edf7b5b0cbcc9296ce0bb4da (patch)
treeef0870019d8058a286c11f02c7461f31b827faaa /intern
parent942d2fe3b7b75facbf280271b1adc31882fc5693 (diff)
Cycles: add location/rotate/scale and XYZ mapping options for all texture nodes,
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?
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/addon/ui.py55
-rw-r--r--intern/cycles/blender/blender_shader.cpp33
-rw-r--r--intern/cycles/render/nodes.cpp6
-rw-r--r--intern/cycles/render/nodes.h2
4 files changed, 80 insertions, 16 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index ca077a50ad6..49193ecb195 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -311,7 +311,7 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
@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
@@ -604,23 +604,64 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
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_options = {'DEFAULT_CLOSED'}
@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
- 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
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index ed84777de7c..48bdcd88c9d 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -97,6 +97,17 @@ static float get_node_output_value(BL::Node b_node, const string& name)
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;
@@ -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();
- 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;
@@ -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()];
+ get_tex_mapping(&image->tex_mapping, b_image_node.texture_mapping());
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()];
+ get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
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: {
@@ -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()];
+ get_tex_mapping(&blend->tex_mapping, b_blend_node.texture_mapping());
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()];
+ get_tex_mapping(&voronoi->tex_mapping, b_voronoi_node.texture_mapping());
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();
+ get_tex_mapping(&magic->tex_mapping, b_magic_node.texture_mapping());
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;
+ get_tex_mapping(&marble->tex_mapping, b_marble_node.texture_mapping());
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;
+ get_tex_mapping(&clouds->tex_mapping, b_clouds_node.texture_mapping());
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()];
+ get_tex_mapping(&wood->tex_mapping, b_wood_node.texture_mapping());
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()];
+ get_tex_mapping(&musgrave->tex_mapping, b_musgrave_node.texture_mapping());
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;
+ get_tex_mapping(&stucci->tex_mapping, b_stucci_node.texture_mapping());
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()];
+ get_tex_mapping(&distnoise->tex_mapping, b_distnoise_node.texture_mapping());
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();
+ get_tex_mapping(&sky->tex_mapping, b_sky_node.texture_mapping());
node = sky;
break;
}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 9c72c01417a..56d5bdf77ba 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -45,11 +45,11 @@ Transform TextureMapping::compute_transform()
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)
- mmat[1][y_mapping] = 1.0f;
+ mmat[1][y_mapping-1] = 1.0f;
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);
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index e11c51b4aaf..09b565b5043 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -41,7 +41,7 @@ public:
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 };