forked from bartvdbraak/blender
Cycles / Vector Transform Node:
* First step towards a new vector transform node, to convert Points/Vectors between World/Object/Camera space. This only contains the Blender UI, RNA... code, no Cycles integration yet.
This commit is contained in:
parent
e6fc174152
commit
370ebad2f9
@ -210,6 +210,7 @@ shader_node_categories = [
|
||||
NodeItem("ShaderNodeNormalMap"),
|
||||
NodeItem("ShaderNodeNormal"),
|
||||
NodeItem("ShaderNodeVectorCurve"),
|
||||
NodeItem("ShaderNodeVectorTransform"),
|
||||
]),
|
||||
ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
|
||||
NodeItem("ShaderNodeMath"),
|
||||
|
@ -743,6 +743,7 @@ struct ShadeResult;
|
||||
#define SH_NODE_BSDF_TOON 179
|
||||
#define SH_NODE_WAVELENGTH 180
|
||||
#define SH_NODE_BLACKBODY 181
|
||||
#define SH_NODE_VECT_TRANSFORM 182
|
||||
|
||||
/* custom defines options for Material node */
|
||||
#define SH_NODE_MAT_DIFF 1
|
||||
|
@ -3419,6 +3419,7 @@ static void registerShaderNodes(void)
|
||||
register_node_type_sh_curve_rgb();
|
||||
register_node_type_sh_math();
|
||||
register_node_type_sh_vect_math();
|
||||
register_node_type_sh_vect_transform();
|
||||
register_node_type_sh_squeeze();
|
||||
register_node_type_sh_material_ext();
|
||||
register_node_type_sh_invert();
|
||||
|
@ -735,6 +735,13 @@ static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), Po
|
||||
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE);
|
||||
uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
|
||||
@ -969,6 +976,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
|
||||
case SH_NODE_VECT_MATH:
|
||||
ntype->uifunc = node_shader_buts_vect_math;
|
||||
break;
|
||||
case SH_NODE_VECT_TRANSFORM:
|
||||
ntype->uifunc = node_shader_buts_vect_transform;
|
||||
break;
|
||||
case SH_NODE_GEOMETRY:
|
||||
ntype->uifunc = node_shader_buts_geometry;
|
||||
break;
|
||||
|
@ -788,6 +788,12 @@ typedef struct NodeShaderAttribute {
|
||||
char name[64];
|
||||
} NodeShaderAttribute;
|
||||
|
||||
typedef struct NodeShaderVectTransform {
|
||||
int type;
|
||||
int convert_from, convert_to;
|
||||
int pad;
|
||||
} NodeShaderVectTransform;
|
||||
|
||||
/* TEX_output */
|
||||
typedef struct TexNodeOutput {
|
||||
char name[64];
|
||||
@ -869,6 +875,18 @@ typedef struct NodeShaderNormalMap {
|
||||
#define SHD_GLOSSY_SHARP 1
|
||||
#define SHD_GLOSSY_GGX 2
|
||||
|
||||
/* vector transform */
|
||||
#define SHD_VECT_TRANSFORM_TYPE_VECTOR 0
|
||||
#define SHD_VECT_TRANSFORM_TYPE_POINT 1
|
||||
|
||||
#define SHD_VECT_TRANSFORM_FROM_WORLD 0
|
||||
#define SHD_VECT_TRANSFORM_FROM_OBJECT 1
|
||||
#define SHD_VECT_TRANSFORM_FROM_CAMERA 2
|
||||
|
||||
#define SHD_VECT_TRANSFORM_TO_WORLD 0
|
||||
#define SHD_VECT_TRANSFORM_TO_OBJECT 1
|
||||
#define SHD_VECT_TRANSFORM_TO_CAMERA 2
|
||||
|
||||
/* toon modes */
|
||||
#define SHD_TOON_DIFFUSE 0
|
||||
#define SHD_TOON_GLOSSY 1
|
||||
|
@ -3482,6 +3482,48 @@ static void def_sh_tex_coord(StructRNA *srna)
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_sh_vect_transform(StructRNA *srna)
|
||||
{
|
||||
static EnumPropertyItem prop_vect_type_items[] = {
|
||||
{SHD_VECT_TRANSFORM_TYPE_VECTOR, "VECTOR", 0, "Vector", ""},
|
||||
{SHD_VECT_TRANSFORM_TYPE_POINT, "POINT", 0, "Point", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_vect_from_items[] = {
|
||||
{SHD_VECT_TRANSFORM_FROM_WORLD, "WORLD", 0, "World", ""},
|
||||
{SHD_VECT_TRANSFORM_FROM_OBJECT, "OBJECT", 0, "Object", ""},
|
||||
{SHD_VECT_TRANSFORM_FROM_CAMERA, "CAMERA", 0, "Camera", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_vect_to_items[] = {
|
||||
{SHD_VECT_TRANSFORM_TO_WORLD, "WORLD", 0, "World", ""},
|
||||
{SHD_VECT_TRANSFORM_TO_OBJECT, "OBJECT", 0, "Object", ""},
|
||||
{SHD_VECT_TRANSFORM_TO_CAMERA, "CAMERA", 0, "Camera", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
PropertyRNA *prop;
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "NodeShaderVectTransform", "storage");
|
||||
|
||||
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_vect_type_items);
|
||||
RNA_def_property_ui_text(prop, "Type", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "convert_from", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_vect_from_items);
|
||||
RNA_def_property_ui_text(prop, "Convert From", "Space to convert from");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "convert_to", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_vect_to_items);
|
||||
RNA_def_property_ui_text(prop, "Convert To", "Space to convert to");
|
||||
RNA_def_property_update(prop, 0, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_sh_tex_wireframe(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
@ -148,6 +148,7 @@ set(SRC
|
||||
shader/nodes/node_shader_wavelength.c
|
||||
shader/nodes/node_shader_blackbody.c
|
||||
shader/nodes/node_shader_vectMath.c
|
||||
shader/nodes/node_shader_vectTransform.c
|
||||
shader/nodes/node_shader_add_shader.c
|
||||
shader/nodes/node_shader_ambient_occlusion.c
|
||||
shader/nodes/node_shader_attribute.c
|
||||
|
@ -89,6 +89,7 @@ void register_node_type_sh_hair_info(void);
|
||||
void register_node_type_sh_script(void);
|
||||
void register_node_type_sh_normal_map(void);
|
||||
void register_node_type_sh_tangent(void);
|
||||
void register_node_type_sh_vect_transform(void);
|
||||
|
||||
void register_node_type_sh_ambient_occlusion(void);
|
||||
void register_node_type_sh_background(void);
|
||||
|
@ -114,6 +114,7 @@ DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TE
|
||||
DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" )
|
||||
DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" )
|
||||
DefNode( ShaderNode, SH_NODE_VECT_TRANSFORM, def_sh_vect_transform, "VECT_TRANSFORM", VectorTransform, "Vector Transform", "" )
|
||||
|
||||
DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
|
||||
DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" )
|
||||
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file blender/nodes/shader/nodes/node_shader_vectTransform.c
|
||||
* \ingroup shdnodes
|
||||
*/
|
||||
|
||||
#include "../node_shader_util.h"
|
||||
|
||||
/* **************** Vector Transform ******************** */
|
||||
static bNodeSocketTemplate sh_node_vect_transform_in[] = {
|
||||
{ SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate sh_node_vect_transform_out[] = {
|
||||
{ SOCK_VECTOR, 0, N_("Vector")},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
{
|
||||
NodeShaderVectTransform *vect = MEM_callocN(sizeof(NodeShaderVectTransform), "NodeShaderVectTransform");
|
||||
|
||||
/* Convert World into Object Space per default */
|
||||
vect->convert_to = 1;
|
||||
|
||||
node->storage = vect;
|
||||
}
|
||||
|
||||
void register_node_type_sh_vect_transform(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_CONVERTOR, 0);
|
||||
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
||||
node_type_init(&ntype, node_shader_init_vect_transform);
|
||||
node_type_socket_templates(&ntype, sh_node_vect_transform_in, sh_node_vect_transform_out);
|
||||
node_type_storage(&ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage);
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
Loading…
Reference in New Issue
Block a user