Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tangent.c
- This file was moved from source/blender/nodes/shader/nodes/node_shader_tangent.cc.
| Show All 11 Lines | |||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2005 Blender Foundation. | * The Original Code is Copyright (C) 2005 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "../node_shader_util.h" | ||||
| /* **************** OUTPUT ******************** */ | /* **************** OUTPUT ******************** */ | ||||
| namespace blender::nodes::node_shader_tangent_cc { | |||||
| static bNodeSocketTemplate sh_node_tangent_out[] = { | static bNodeSocketTemplate sh_node_tangent_out[] = { | ||||
| {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static void node_shader_init_tangent(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tangent(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeShaderTangent *attr = (NodeShaderTangent *)MEM_callocN(sizeof(NodeShaderTangent), | NodeShaderTangent *attr = MEM_callocN(sizeof(NodeShaderTangent), "NodeShaderTangent"); | ||||
| "NodeShaderTangent"); | |||||
| attr->axis = SHD_TANGENT_AXIS_Z; | attr->axis = SHD_TANGENT_AXIS_Z; | ||||
| node->storage = attr; | node->storage = attr; | ||||
| } | } | ||||
| static int node_shader_gpu_tangent(GPUMaterial *mat, | static int node_shader_gpu_tangent(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| NodeShaderTangent *attr = (NodeShaderTangent *)node->storage; | NodeShaderTangent *attr = node->storage; | ||||
| if (attr->direction_type == SHD_TANGENT_UVMAP) { | if (attr->direction_type == SHD_TANGENT_UVMAP) { | ||||
| return GPU_stack_link( | return GPU_stack_link( | ||||
| mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map)); | mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map)); | ||||
| } | } | ||||
| GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); | GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); | ||||
| Show All 12 Lines | return GPU_stack_link(mat, | ||||
| "node_tangent", | "node_tangent", | ||||
| in, | in, | ||||
| out, | out, | ||||
| GPU_builtin(GPU_WORLD_NORMAL), | GPU_builtin(GPU_WORLD_NORMAL), | ||||
| orco, | orco, | ||||
| GPU_builtin(GPU_OBJECT_MATRIX)); | GPU_builtin(GPU_OBJECT_MATRIX)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tangent_cc | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tangent() | void register_node_type_sh_tangent(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tangent_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, 0); | sh_node_type_base(&ntype, SH_NODE_TANGENT, "Tangent", NODE_CLASS_INPUT, 0); | ||||
| node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_tangent_out); | node_type_socket_templates(&ntype, NULL, sh_node_tangent_out); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | ||||
| node_type_init(&ntype, file_ns::node_shader_init_tangent); | node_type_init(&ntype, node_shader_init_tangent); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tangent); | node_type_gpu(&ntype, node_shader_gpu_tangent); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeShaderTangent", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeShaderTangent", node_free_standard_storage, node_copy_standard_storage); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||