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
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 /source/blender/blenkernel/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 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/texture.c95
1 files changed, 79 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index d3bd7d7b766..88cf0689a39 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -202,33 +202,96 @@ void free_plugin_tex(PluginTex *pit)
/* ****************** 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);
-
- 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 ******************* */