diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 21:35:20 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-07 21:35:20 +0400 |
commit | f3407e7d60d8000d71c66192d760bd5700345b21 (patch) | |
tree | 99930ebf3b63d48bff2def3d30d543acacd6f1b1 | |
parent | 448731834839bbddee02558080dd9a5e586f6f21 (diff) |
Textures/Shaders: extend TexMapping to include projection options, and add a
ColorMapping struct for color manipulation of textures. These will be the
standard built-in texture node options for manipulating the incoming texture
coordinate and outgoing color.
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 94 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 27 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 22 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 55 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 176 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_mapValue.c | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mapping.c | 2 |
10 files changed, 295 insertions, 117 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 7033a2e0cce..ac56cd02eb0 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 260 -#define BLENDER_SUBVERSION 1 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index de72428b3d7..508fef8d9a4 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -103,9 +103,12 @@ void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex 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); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 377eeef117e..c80b2880d12 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -202,33 +202,95 @@ 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); + copy_v3_v3(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); - copy_v3_v3(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 ******************* */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ba1d333f44f..96fbe392922 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5991,7 +5991,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID if(id->flag & LIB_FAKEUSER) id->us= 1; else id->us= 0; id->icon_id = 0; - id->flag &= ~LIB_ID_RECALC; + id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); /* this case cannot be direct_linked: it's just the ID part */ if(bhead->code==ID_ID) { @@ -7235,6 +7235,22 @@ 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) { + if(node->type == SH_NODE_MAPPING) { + TexMapping *tex_mapping; + + tex_mapping= node->storage; + tex_mapping->projx= PROJ_X; + tex_mapping->projy= PROJ_Y; + tex_mapping->projz= PROJ_Z; + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -12320,6 +12336,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 2)) { + 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 */ { { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b4d89e1365d..648027b9c58 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -95,6 +95,14 @@ static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v) } } +static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block, + bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock, + const char *UNUSED(name), int x, int y, int width) +{ + uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, ""); +} + + static void node_socket_button_default(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *name, int x, int y, int width) @@ -938,28 +946,28 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping"); uiLayout *row; uiItemL(layout, "Location:", 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); - uiItemR(row, ptr, "rotation", 0, "", ICON_NONE); + uiItemR(row, &mappingptr, "rotation", 0, "", ICON_NONE); uiItemL(layout, "Scale:", ICON_NONE); row= uiLayoutRow(layout, 1); - uiItemR(row, ptr, "scale", 0, "", ICON_NONE); + uiItemR(row, &mappingptr, "scale", 0, "", ICON_NONE); 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); - 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); } static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -2089,6 +2097,9 @@ void ED_init_node_butfuncs(void) case SOCK_RGBA: stype->buttonfunc = node_socket_button_color; break; + case SOCK_SHADER: + stype->buttonfunc = node_socket_button_label; + break; default: stype->buttonfunc = NULL; } diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 4cf31edb891..1ecca5a0b2a 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -267,11 +267,13 @@ typedef struct 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; + char projx, projy, projz, mapping; + int pad; float mat[4][4]; float min[3], max[3]; @@ -279,10 +281,24 @@ typedef struct 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 */ -#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 ********************* */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index f024ad3addd..7e74c490e5c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -425,15 +425,6 @@ static void rna_NodeSocketVector_range(PointerRNA *ptr, float *min, float *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; @@ -1077,48 +1068,12 @@ static void def_sh_material(StructRNA *srna) 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) diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index c420ecefdae..aac4da9e6f6 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -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}}; +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" @@ -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) @@ -400,71 +439,139 @@ static char *rna_VoxelData_path(PointerRNA *UNUSED(ptr)) 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); - 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", ""); - 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_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", ""); - 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"); - 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"); - 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"); - 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"); - 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; + + 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", ""}, @@ -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"); - 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"); @@ -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_colormapping(brna); } #endif diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index 81e963d4790..6930fbf0664 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -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)) { - node->storage= add_mapping(); + node->storage= add_tex_mapping(); } void register_node_type_cmp_map_value(ListBase *lb) diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 862c52187dc..35007724037 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -69,7 +69,7 @@ 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)) { - node->storage= add_mapping(); + node->storage= add_tex_mapping(); } static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) |