Cycles / Vector Transform node:
* Add a note to convert a Vector, Point or Normal between World <=> Camera <=> Object coordinate space. Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Vector_Transform Part of my GSoC 2013 project, SVN merge of r57599, r57670, r57918, r57919, r58245 and r58775.
This commit is contained in:
@@ -250,6 +250,14 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
|
|||||||
vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
|
vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
|
||||||
node = vmath;
|
node = vmath;
|
||||||
}
|
}
|
||||||
|
else if (b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
|
||||||
|
BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
|
||||||
|
VectorTransformNode *vtransform = new VectorTransformNode();
|
||||||
|
vtransform->type = VectorTransformNode::type_enum[b_vector_transform_node.type()];
|
||||||
|
vtransform->convert_from = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_from()];
|
||||||
|
vtransform->convert_to = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_to()];
|
||||||
|
node = vtransform;
|
||||||
|
}
|
||||||
else if (b_node.is_a(&RNA_ShaderNodeNormal)) {
|
else if (b_node.is_a(&RNA_ShaderNodeNormal)) {
|
||||||
BL::Node::outputs_iterator out_it;
|
BL::Node::outputs_iterator out_it;
|
||||||
b_node.outputs.begin(out_it);
|
b_node.outputs.begin(out_it);
|
||||||
|
@@ -105,6 +105,7 @@ set(SRC_SVM_HEADERS
|
|||||||
svm/svm_texture.h
|
svm/svm_texture.h
|
||||||
svm/svm_types.h
|
svm/svm_types.h
|
||||||
svm/svm_value.h
|
svm/svm_value.h
|
||||||
|
svm/svm_vector_transform.h
|
||||||
svm/svm_voronoi.h
|
svm/svm_voronoi.h
|
||||||
svm/svm_wave.h
|
svm/svm_wave.h
|
||||||
)
|
)
|
||||||
|
@@ -154,6 +154,16 @@ __device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, flo
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
|
||||||
|
{
|
||||||
|
#ifdef __OBJECT_MOTION__
|
||||||
|
*D = transform_direction(&sd->ob_itfm, *D);
|
||||||
|
#else
|
||||||
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
||||||
|
*D = transform_direction(&tfm, *D);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
__device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
|
__device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
|
||||||
{
|
{
|
||||||
if(sd->object == ~0)
|
if(sd->object == ~0)
|
||||||
|
@@ -64,6 +64,7 @@ set(SRC_OSL
|
|||||||
node_value.osl
|
node_value.osl
|
||||||
node_vector_curves.osl
|
node_vector_curves.osl
|
||||||
node_vector_math.osl
|
node_vector_math.osl
|
||||||
|
node_vector_transform.osl
|
||||||
node_velvet_bsdf.osl
|
node_velvet_bsdf.osl
|
||||||
node_voronoi_texture.osl
|
node_voronoi_texture.osl
|
||||||
node_ward_bsdf.osl
|
node_ward_bsdf.osl
|
||||||
|
38
intern/cycles/kernel/shaders/node_vector_transform.osl
Normal file
38
intern/cycles/kernel/shaders/node_vector_transform.osl
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Blender Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdosl.h"
|
||||||
|
|
||||||
|
shader node_vector_transform(
|
||||||
|
string type = "Vector",
|
||||||
|
string convert_from = "world",
|
||||||
|
string convert_to = "object",
|
||||||
|
vector VectorIn = vector(0.0, 0.0, 0.0),
|
||||||
|
output vector VectorOut = vector(0.0, 0.0, 0.0))
|
||||||
|
{
|
||||||
|
if (type == "Vector" || type == "Normal") {
|
||||||
|
VectorOut = transform(convert_from, convert_to, VectorIn);
|
||||||
|
if (type == "Normal")
|
||||||
|
VectorOut = normalize(VectorOut);
|
||||||
|
}
|
||||||
|
else if (type == "Point") {
|
||||||
|
point Point = (point)VectorIn;
|
||||||
|
VectorOut = transform(convert_from, convert_to, Point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -177,6 +177,7 @@ CCL_NAMESPACE_END
|
|||||||
#include "svm_voronoi.h"
|
#include "svm_voronoi.h"
|
||||||
#include "svm_checker.h"
|
#include "svm_checker.h"
|
||||||
#include "svm_brick.h"
|
#include "svm_brick.h"
|
||||||
|
#include "svm_vector_transform.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -382,6 +383,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
|
|||||||
case NODE_VECTOR_MATH:
|
case NODE_VECTOR_MATH:
|
||||||
svm_node_vector_math(kg, sd, stack, node.y, node.z, node.w, &offset);
|
svm_node_vector_math(kg, sd, stack, node.y, node.z, node.w, &offset);
|
||||||
break;
|
break;
|
||||||
|
case NODE_VECTOR_TRANSFORM:
|
||||||
|
svm_node_vector_transform(kg, sd, stack, node);
|
||||||
|
break;
|
||||||
case NODE_NORMAL:
|
case NODE_NORMAL:
|
||||||
svm_node_normal(kg, sd, stack, node.y, node.z, node.w, &offset);
|
svm_node_normal(kg, sd, stack, node.y, node.z, node.w, &offset);
|
||||||
break;
|
break;
|
||||||
|
@@ -68,6 +68,7 @@ typedef enum NodeType {
|
|||||||
NODE_SET_BUMP,
|
NODE_SET_BUMP,
|
||||||
NODE_MATH,
|
NODE_MATH,
|
||||||
NODE_VECTOR_MATH,
|
NODE_VECTOR_MATH,
|
||||||
|
NODE_VECTOR_TRANSFORM,
|
||||||
NODE_MAPPING,
|
NODE_MAPPING,
|
||||||
NODE_TEX_COORD,
|
NODE_TEX_COORD,
|
||||||
NODE_TEX_COORD_BUMP_DX,
|
NODE_TEX_COORD_BUMP_DX,
|
||||||
@@ -227,6 +228,18 @@ typedef enum NodeVectorMath {
|
|||||||
NODE_VECTOR_MATH_NORMALIZE
|
NODE_VECTOR_MATH_NORMALIZE
|
||||||
} NodeVectorMath;
|
} NodeVectorMath;
|
||||||
|
|
||||||
|
typedef enum NodeVectorTransformType {
|
||||||
|
NODE_VECTOR_TRANSFORM_TYPE_VECTOR,
|
||||||
|
NODE_VECTOR_TRANSFORM_TYPE_POINT,
|
||||||
|
NODE_VECTOR_TRANSFORM_TYPE_NORMAL
|
||||||
|
} NodeVectorTransformType;
|
||||||
|
|
||||||
|
typedef enum NodeVectorTransformConvertSpace {
|
||||||
|
NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD,
|
||||||
|
NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT,
|
||||||
|
NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA
|
||||||
|
} NodeVectorTransformConvertSpace;
|
||||||
|
|
||||||
typedef enum NodeConvert {
|
typedef enum NodeConvert {
|
||||||
NODE_CONVERT_FV,
|
NODE_CONVERT_FV,
|
||||||
NODE_CONVERT_FI,
|
NODE_CONVERT_FI,
|
||||||
|
103
intern/cycles/kernel/svm/svm_vector_transform.h
Normal file
103
intern/cycles/kernel/svm/svm_vector_transform.h
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Blender Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/* Vector Transform */
|
||||||
|
|
||||||
|
__device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
|
||||||
|
{
|
||||||
|
uint itype, ifrom, ito;
|
||||||
|
uint vector_in, vector_out;
|
||||||
|
|
||||||
|
decode_node_uchar4(node.y, &itype, &ifrom, &ito, NULL);
|
||||||
|
decode_node_uchar4(node.z, &vector_in, &vector_out, NULL, NULL);
|
||||||
|
|
||||||
|
float3 in = stack_load_float3(stack, vector_in);
|
||||||
|
|
||||||
|
NodeVectorTransformType type = (NodeVectorTransformType)itype;
|
||||||
|
NodeVectorTransformConvertSpace from = (NodeVectorTransformConvertSpace)ifrom;
|
||||||
|
NodeVectorTransformConvertSpace to = (NodeVectorTransformConvertSpace)ito;
|
||||||
|
|
||||||
|
Transform tfm;
|
||||||
|
int is_object = (sd->object != ~0);
|
||||||
|
int is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR || type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
|
||||||
|
|
||||||
|
/* From world */
|
||||||
|
if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD) {
|
||||||
|
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
|
||||||
|
tfm = kernel_data.cam.worldtocamera;
|
||||||
|
if(is_direction)
|
||||||
|
in = transform_direction(&tfm, in);
|
||||||
|
else
|
||||||
|
in = transform_point(&tfm, in);
|
||||||
|
}
|
||||||
|
else if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT && is_object) {
|
||||||
|
if(is_direction)
|
||||||
|
object_inverse_dir_transform(kg, sd, &in);
|
||||||
|
else
|
||||||
|
object_inverse_position_transform(kg, sd, &in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* From camera */
|
||||||
|
else if (from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
|
||||||
|
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) {
|
||||||
|
tfm = kernel_data.cam.cameratoworld;
|
||||||
|
if(is_direction)
|
||||||
|
in = transform_direction(&tfm, in);
|
||||||
|
else
|
||||||
|
in = transform_point(&tfm, in);
|
||||||
|
}
|
||||||
|
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT && is_object) {
|
||||||
|
if(is_direction)
|
||||||
|
object_inverse_dir_transform(kg, sd, &in);
|
||||||
|
else
|
||||||
|
object_inverse_position_transform(kg, sd, &in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* From object */
|
||||||
|
else if(from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) {
|
||||||
|
if((to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) && is_object) {
|
||||||
|
if(is_direction)
|
||||||
|
object_dir_transform(kg, sd, &in);
|
||||||
|
else
|
||||||
|
object_position_transform(kg, sd, &in);
|
||||||
|
}
|
||||||
|
if(to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
|
||||||
|
tfm = kernel_data.cam.worldtocamera;
|
||||||
|
if(is_direction)
|
||||||
|
in = transform_direction(&tfm, in);
|
||||||
|
else
|
||||||
|
in = transform_point(&tfm, in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Normalize Normal */
|
||||||
|
if(type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL)
|
||||||
|
in = normalize(in);
|
||||||
|
|
||||||
|
/* Output */
|
||||||
|
if(stack_valid(vector_out)) {
|
||||||
|
stack_store_float3(stack, vector_out, in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CCL_NAMESPACE_END
|
||||||
|
|
@@ -3169,6 +3169,65 @@ void VectorMathNode::compile(OSLCompiler& compiler)
|
|||||||
compiler.add(this, "node_vector_math");
|
compiler.add(this, "node_vector_math");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* VectorTransform */
|
||||||
|
|
||||||
|
VectorTransformNode::VectorTransformNode()
|
||||||
|
: ShaderNode("vector_transform")
|
||||||
|
{
|
||||||
|
type = ustring("Vector");
|
||||||
|
convert_from = ustring("world");
|
||||||
|
convert_to = ustring("object");
|
||||||
|
|
||||||
|
add_input("Vector", SHADER_SOCKET_VECTOR);
|
||||||
|
add_output("Vector", SHADER_SOCKET_VECTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ShaderEnum vector_transform_type_init()
|
||||||
|
{
|
||||||
|
ShaderEnum enm;
|
||||||
|
|
||||||
|
enm.insert("Vector", NODE_VECTOR_TRANSFORM_TYPE_VECTOR);
|
||||||
|
enm.insert("Point", NODE_VECTOR_TRANSFORM_TYPE_POINT);
|
||||||
|
enm.insert("Normal", NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
|
||||||
|
|
||||||
|
return enm;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ShaderEnum vector_transform_convert_space_init()
|
||||||
|
{
|
||||||
|
ShaderEnum enm;
|
||||||
|
|
||||||
|
enm.insert("world", NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD);
|
||||||
|
enm.insert("object", NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT);
|
||||||
|
enm.insert("camera", NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA);
|
||||||
|
|
||||||
|
return enm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderEnum VectorTransformNode::type_enum = vector_transform_type_init();
|
||||||
|
ShaderEnum VectorTransformNode::convert_space_enum = vector_transform_convert_space_init();
|
||||||
|
|
||||||
|
void VectorTransformNode::compile(SVMCompiler& compiler)
|
||||||
|
{
|
||||||
|
ShaderInput *vector_in = input("Vector");
|
||||||
|
ShaderOutput *vector_out = output("Vector");
|
||||||
|
|
||||||
|
compiler.stack_assign(vector_in);
|
||||||
|
compiler.stack_assign(vector_out);
|
||||||
|
|
||||||
|
compiler.add_node(NODE_VECTOR_TRANSFORM,
|
||||||
|
compiler.encode_uchar4(type_enum[type], convert_space_enum[convert_from], convert_space_enum[convert_to]),
|
||||||
|
compiler.encode_uchar4(vector_in->stack_offset, vector_out->stack_offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VectorTransformNode::compile(OSLCompiler& compiler)
|
||||||
|
{
|
||||||
|
compiler.parameter("type", type);
|
||||||
|
compiler.parameter("convert_from", convert_from);
|
||||||
|
compiler.parameter("convert_to", convert_to);
|
||||||
|
compiler.add(this, "node_vector_transform");
|
||||||
|
}
|
||||||
|
|
||||||
/* BumpNode */
|
/* BumpNode */
|
||||||
|
|
||||||
BumpNode::BumpNode()
|
BumpNode::BumpNode()
|
||||||
|
@@ -494,6 +494,18 @@ public:
|
|||||||
static ShaderEnum type_enum;
|
static ShaderEnum type_enum;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VectorTransformNode : public ShaderNode {
|
||||||
|
public:
|
||||||
|
SHADER_NODE_CLASS(VectorTransformNode)
|
||||||
|
|
||||||
|
ustring type;
|
||||||
|
ustring convert_from;
|
||||||
|
ustring convert_to;
|
||||||
|
|
||||||
|
static ShaderEnum type_enum;
|
||||||
|
static ShaderEnum convert_space_enum;
|
||||||
|
};
|
||||||
|
|
||||||
class BumpNode : public ShaderNode {
|
class BumpNode : public ShaderNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(BumpNode)
|
SHADER_NODE_CLASS(BumpNode)
|
||||||
|
@@ -218,6 +218,7 @@ shader_node_categories = [
|
|||||||
NodeItem("ShaderNodeNormalMap"),
|
NodeItem("ShaderNodeNormalMap"),
|
||||||
NodeItem("ShaderNodeNormal"),
|
NodeItem("ShaderNodeNormal"),
|
||||||
NodeItem("ShaderNodeVectorCurve"),
|
NodeItem("ShaderNodeVectorCurve"),
|
||||||
|
NodeItem("ShaderNodeVectorTransform"),
|
||||||
]),
|
]),
|
||||||
ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
|
ShaderNewNodeCategory("SH_NEW_CONVERTOR", "Converter", items=[
|
||||||
NodeItem("ShaderNodeMath"),
|
NodeItem("ShaderNodeMath"),
|
||||||
|
@@ -743,6 +743,7 @@ struct ShadeResult;
|
|||||||
#define SH_NODE_BSDF_TOON 179
|
#define SH_NODE_BSDF_TOON 179
|
||||||
#define SH_NODE_WAVELENGTH 180
|
#define SH_NODE_WAVELENGTH 180
|
||||||
#define SH_NODE_BLACKBODY 181
|
#define SH_NODE_BLACKBODY 181
|
||||||
|
#define SH_NODE_VECT_TRANSFORM 182
|
||||||
|
|
||||||
/* custom defines options for Material node */
|
/* custom defines options for Material node */
|
||||||
#define SH_NODE_MAT_DIFF 1
|
#define SH_NODE_MAT_DIFF 1
|
||||||
|
@@ -3418,6 +3418,7 @@ static void registerShaderNodes(void)
|
|||||||
register_node_type_sh_curve_rgb();
|
register_node_type_sh_curve_rgb();
|
||||||
register_node_type_sh_math();
|
register_node_type_sh_math();
|
||||||
register_node_type_sh_vect_math();
|
register_node_type_sh_vect_math();
|
||||||
|
register_node_type_sh_vect_transform();
|
||||||
register_node_type_sh_squeeze();
|
register_node_type_sh_squeeze();
|
||||||
register_node_type_sh_material_ext();
|
register_node_type_sh_material_ext();
|
||||||
register_node_type_sh_invert();
|
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);
|
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)
|
static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
|
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
|
||||||
@@ -975,6 +982,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
|
|||||||
case SH_NODE_VECT_MATH:
|
case SH_NODE_VECT_MATH:
|
||||||
ntype->uifunc = node_shader_buts_vect_math;
|
ntype->uifunc = node_shader_buts_vect_math;
|
||||||
break;
|
break;
|
||||||
|
case SH_NODE_VECT_TRANSFORM:
|
||||||
|
ntype->uifunc = node_shader_buts_vect_transform;
|
||||||
|
break;
|
||||||
case SH_NODE_GEOMETRY:
|
case SH_NODE_GEOMETRY:
|
||||||
ntype->uifunc = node_shader_buts_geometry;
|
ntype->uifunc = node_shader_buts_geometry;
|
||||||
break;
|
break;
|
||||||
|
@@ -788,6 +788,12 @@ typedef struct NodeShaderAttribute {
|
|||||||
char name[64];
|
char name[64];
|
||||||
} NodeShaderAttribute;
|
} NodeShaderAttribute;
|
||||||
|
|
||||||
|
typedef struct NodeShaderVectTransform {
|
||||||
|
int type;
|
||||||
|
int convert_from, convert_to;
|
||||||
|
int pad;
|
||||||
|
} NodeShaderVectTransform;
|
||||||
|
|
||||||
/* TEX_output */
|
/* TEX_output */
|
||||||
typedef struct TexNodeOutput {
|
typedef struct TexNodeOutput {
|
||||||
char name[64];
|
char name[64];
|
||||||
@@ -869,6 +875,15 @@ typedef struct NodeShaderNormalMap {
|
|||||||
#define SHD_GLOSSY_SHARP 1
|
#define SHD_GLOSSY_SHARP 1
|
||||||
#define SHD_GLOSSY_GGX 2
|
#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_TYPE_NORMAL 2
|
||||||
|
|
||||||
|
#define SHD_VECT_TRANSFORM_SPACE_WORLD 0
|
||||||
|
#define SHD_VECT_TRANSFORM_SPACE_OBJECT 1
|
||||||
|
#define SHD_VECT_TRANSFORM_SPACE_CAMERA 2
|
||||||
|
|
||||||
/* toon modes */
|
/* toon modes */
|
||||||
#define SHD_TOON_DIFFUSE 0
|
#define SHD_TOON_DIFFUSE 0
|
||||||
#define SHD_TOON_GLOSSY 1
|
#define SHD_TOON_GLOSSY 1
|
||||||
|
@@ -3509,6 +3509,42 @@ static void def_sh_tex_coord(StructRNA *srna)
|
|||||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
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", ""},
|
||||||
|
{SHD_VECT_TRANSFORM_TYPE_NORMAL, "NORMAL", 0, "Normal", ""},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static EnumPropertyItem prop_vect_space_items[] = {
|
||||||
|
{SHD_VECT_TRANSFORM_SPACE_WORLD, "WORLD", 0, "World", ""},
|
||||||
|
{SHD_VECT_TRANSFORM_SPACE_OBJECT, "OBJECT", 0, "Object", ""},
|
||||||
|
{SHD_VECT_TRANSFORM_SPACE_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_space_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_space_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)
|
static void def_sh_tex_wireframe(StructRNA *srna)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
@@ -148,6 +148,7 @@ set(SRC
|
|||||||
shader/nodes/node_shader_wavelength.c
|
shader/nodes/node_shader_wavelength.c
|
||||||
shader/nodes/node_shader_blackbody.c
|
shader/nodes/node_shader_blackbody.c
|
||||||
shader/nodes/node_shader_vectMath.c
|
shader/nodes/node_shader_vectMath.c
|
||||||
|
shader/nodes/node_shader_vectTransform.c
|
||||||
shader/nodes/node_shader_add_shader.c
|
shader/nodes/node_shader_add_shader.c
|
||||||
shader/nodes/node_shader_ambient_occlusion.c
|
shader/nodes/node_shader_ambient_occlusion.c
|
||||||
shader/nodes/node_shader_attribute.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_script(void);
|
||||||
void register_node_type_sh_normal_map(void);
|
void register_node_type_sh_normal_map(void);
|
||||||
void register_node_type_sh_tangent(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_ambient_occlusion(void);
|
||||||
void register_node_type_sh_background(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_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_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_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_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
|
||||||
DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" )
|
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);
|
||||||
|
}
|
Reference in New Issue
Block a user