diff options
Diffstat (limited to 'source')
34 files changed, 490 insertions, 140 deletions
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 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 ******************* */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c0d52747d56..1c96cd2e05a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -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 */ @@ -12339,6 +12373,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) 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 */ diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index dd46c5cc7e7..0666884351a 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -40,6 +40,7 @@ struct Object; struct Scene; struct SpaceImage; struct bContext; +struct bNode; 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); -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); diff --git a/source/blender/editors/interface/interface_node.c b/source/blender/editors/interface/interface_node.c index abf12029b23..982f33bd600 100644 --- a/source/blender/editors/interface/interface_node.c +++ b/source/blender/editors/interface/interface_node.c @@ -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); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index dc6a647cada..c8c1f083046 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -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; - 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; @@ -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; - 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; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index a00adec3dc7..e817565c509 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -597,7 +597,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) 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 */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 533d2555b26..45713ff2a8f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -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) { + PointerRNA mappingptr = RNA_pointer_get(ptr, "mapping"); 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); - 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); #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); - 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 } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 5b5f79160a1..a932f1b10d9 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -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) { - 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); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 692d45f8303..e23824a2210 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -40,11 +40,12 @@ #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_object_types.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; + bNode *node; 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) { + NodeTexBase *texbase= node->storage; + /* 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); + glMatrixMode(GL_TEXTURE); + glLoadMatrixf(texbase->tex_mapping.mat); + glMatrixMode(GL_MODELVIEW); + /* 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) { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + /* 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); + 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); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 3019dcf1b8d..02653d29a50 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -101,7 +101,7 @@ static int is_image_texture_node(bNode *node) 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; @@ -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_r) *node_r= node; return TRUE; } if(ima) *ima= NULL; if(iuser) *iuser= NULL; + if(node_r) *node_r= node; return FALSE; } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 13237495cea..3103bb9b7b3 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -35,6 +35,7 @@ #include "DNA_ID.h" #include "DNA_vec_types.h" #include "DNA_listBase.h" +#include "DNA_texture_types.h" struct ID; struct ListBase; @@ -426,25 +427,39 @@ typedef struct 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 { + NodeTexBase base; float sun_direction[3]; float turbidity; } NodeTexSky; typedef struct NodeTexImage { + NodeTexBase base; int color_space; } NodeTexImage; typedef struct NodeTexEnvironment { + NodeTexBase base; int color_space; } NodeTexEnvironment; typedef struct NodeTexBlend { + NodeTexBase base; int progression; int axis; } NodeTexBlend; typedef struct NodeTexClouds { + NodeTexBase base; int hard; int depth; int basis; @@ -452,16 +467,19 @@ typedef struct NodeTexClouds { } NodeTexClouds; typedef struct NodeTexVoronoi { + NodeTexBase base; int distance_metric; int coloring; } NodeTexVoronoi; typedef struct NodeTexMusgrave { + NodeTexBase base; int type; int basis; } NodeTexMusgrave; typedef struct NodeTexMarble { + NodeTexBase base; int type; int wave; int basis; @@ -471,11 +489,13 @@ typedef struct NodeTexMarble { } NodeTexMarble; typedef struct NodeTexMagic { + NodeTexBase base; int depth; int pad; } NodeTexMagic; typedef struct NodeTexStucci { + NodeTexBase base; int type; int basis; int hard; @@ -483,11 +503,13 @@ typedef struct NodeTexStucci { } NodeTexStucci; typedef struct NodeTexDistortedNoise { + NodeTexBase base; int basis; int distortion_basis; } NodeTexDistortedNoise; typedef struct NodeTexWood { + NodeTexBase base; int type; int wave; int basis; 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 55432511730..db80f8906fd 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -446,15 +446,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; @@ -1104,48 +1095,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) @@ -1177,11 +1132,33 @@ static void def_sh_attribute(StructRNA *srna) 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"); + 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"); @@ -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"); + 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); @@ -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"); + 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); @@ -1260,6 +1239,7 @@ static void def_sh_tex_blend(StructRNA *srna) 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"); @@ -1279,6 +1259,7 @@ static void def_sh_tex_clouds(StructRNA *srna) 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"); @@ -1304,6 +1285,7 @@ static void def_sh_tex_distnoise(StructRNA *srna) 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"); @@ -1323,6 +1305,7 @@ static void def_sh_tex_magic(StructRNA *srna) 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"); @@ -1342,6 +1325,7 @@ static void def_sh_tex_marble(StructRNA *srna) 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"); @@ -1387,6 +1371,7 @@ static void def_sh_tex_musgrave(StructRNA *srna) 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"); @@ -1412,6 +1397,7 @@ static void def_sh_tex_stucci(StructRNA *srna) 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"); @@ -1454,6 +1440,7 @@ static void def_sh_tex_voronoi(StructRNA *srna) 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"); @@ -1480,6 +1467,7 @@ static void def_sh_tex_wood(StructRNA *srna) 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"); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 6744dc77469..c74d8943bcf 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -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_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", "") diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5793a2ba6f1..8315ff4f2c2 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -114,13 +114,14 @@ EnumPropertyItem viewport_shade_items[] = { #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_scene.h" +#include "BKE_screen.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_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_item_end(&item, &totitem); *free= 1; 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/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 8c5750f3ae2..468f593773d 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -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"); +} + diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index f18310d351d..19976ada3ec 100644 --- a/source/blender/nodes/shader/node_shader_util.h +++ b/source/blender/nodes/shader/node_shader_util.h @@ -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_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); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 36ac25dbd4d..2eff74651ef 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -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) @@ -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_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); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_blend.c b/source/blender/nodes/shader/nodes/node_shader_tex_blend.c index 659b0cadd5b..50bafede2aa 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_blend.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_blend.c @@ -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"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); 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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_blend", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c b/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c index c38dd155a7b..12f117995bc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_clouds", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c b/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c index c28fef9e472..56a87949fc7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_distnoise", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 7fbd5142e22..3c0a1a22e5a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -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"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); 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); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 11a2c914746..562884a9ed9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -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"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); 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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index 5ccb42d99c4..8d0a2d3fb85 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -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"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); 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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_magic", in, out, GPU_uniform(&depth)); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_marble.c b/source/blender/nodes/shader/nodes/node_shader_tex_marble.c index 5b9b3008038..3bb999659c9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_marble.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_marble.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_marble", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index f8586b5e9ac..7cf33445a5d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -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"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); 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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_musgrave", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index 32f88e998a5..e8fb4737305 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -59,6 +59,15 @@ static bNodeSocketTemplate sh_node_tex_noise_out[]= { { -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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, 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_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); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index b43f7bd2924..6fb1f4f51cf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -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"); + 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; @@ -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_sky", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c b/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c index 4540e2c982b..3eb315052a9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_stucci", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index b942aa00fb4..ee8838ca1b3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_voronoi", in, out); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wood.c b/source/blender/nodes/shader/nodes/node_shader_tex_wood.c index 4fb11743882..f1beb8e5d7d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wood.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wood.c @@ -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"); + 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; @@ -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); } -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, ""); + node_shader_gpu_tex_mapping(mat, node, in, out); + return GPU_stack_link(mat, "node_tex_wood", in, out); } |