Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_magic.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" | ||||
| namespace blender::nodes::node_shader_tex_magic_cc { | namespace blender::nodes { | ||||
| static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) | static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Vector>(N_("Vector")).implicit_field(); | b.add_input<decl::Vector>(N_("Vector")).implicit_field(); | ||||
| b.add_input<decl::Float>(N_("Scale")).min(-1000.0f).max(1000.0f).default_value(5.0f); | b.add_input<decl::Float>(N_("Scale")).min(-1000.0f).max(1000.0f).default_value(5.0f); | ||||
| b.add_input<decl::Float>(N_("Distortion")).min(-1000.0f).max(1000.0f).default_value(1.0f); | b.add_input<decl::Float>(N_("Distortion")).min(-1000.0f).max(1000.0f).default_value(1.0f); | ||||
| b.add_output<decl::Color>(N_("Color")).no_muted_links(); | b.add_output<decl::Color>(N_("Color")).no_muted_links(); | ||||
| b.add_output<decl::Float>(N_("Fac")).no_muted_links(); | b.add_output<decl::Float>(N_("Fac")).no_muted_links(); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexMagic *tex = (NodeTexMagic *)MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic"); | NodeTexMagic *tex = (NodeTexMagic *)MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic"); | ||||
| BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | ||||
| BKE_texture_colormapping_default(&tex->base.color_mapping); | BKE_texture_colormapping_default(&tex->base.color_mapping); | ||||
| tex->depth = 2; | tex->depth = 2; | ||||
| node->storage = tex; | node->storage = tex; | ||||
| Show All 9 Lines | static int node_shader_gpu_tex_magic(GPUMaterial *mat, | ||||
| float depth = tex->depth; | float depth = tex->depth; | ||||
| node_shader_gpu_default_tex_coord(mat, node, &in[0].link); | node_shader_gpu_default_tex_coord(mat, node, &in[0].link); | ||||
| node_shader_gpu_tex_mapping(mat, node, in, out); | node_shader_gpu_tex_mapping(mat, node, in, out); | ||||
| return GPU_stack_link(mat, node, "node_tex_magic", in, out, GPU_constant(&depth)); | return GPU_stack_link(mat, node, "node_tex_magic", in, out, GPU_constant(&depth)); | ||||
| } | } | ||||
| namespace blender::nodes { | |||||
| class MagicFunction : public fn::MultiFunction { | class MagicFunction : public fn::MultiFunction { | ||||
| private: | private: | ||||
| int depth_; | int depth_; | ||||
| public: | public: | ||||
| MagicFunction(int depth) : depth_(depth) | MagicFunction(int depth) : depth_(depth) | ||||
| { | { | ||||
| static fn::MFSignature signature = create_signature(); | static fn::MFSignature signature = create_signature(); | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
| static void sh_node_magic_tex_build_multi_function( | static void sh_node_magic_tex_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &node = builder.node(); | bNode &node = builder.node(); | ||||
| NodeTexMagic *tex = (NodeTexMagic *)node.storage; | NodeTexMagic *tex = (NodeTexMagic *)node.storage; | ||||
| builder.construct_and_set_matching_fn<MagicFunction>(tex->depth); | builder.construct_and_set_matching_fn<MagicFunction>(tex->depth); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_magic_cc | } // namespace blender::nodes | ||||
| void register_node_type_sh_tex_magic() | void register_node_type_sh_tex_magic(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_magic_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0); | sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0); | ||||
| ntype.declare = file_ns::sh_node_tex_magic_declare; | ntype.declare = blender::nodes::sh_node_tex_magic_declare; | ||||
| node_type_init(&ntype, file_ns::node_shader_init_tex_magic); | node_type_init(&ntype, node_shader_init_tex_magic); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_magic); | node_type_gpu(&ntype, node_shader_gpu_tex_magic); | ||||
| ntype.build_multi_function = file_ns::sh_node_magic_tex_build_multi_function; | ntype.build_multi_function = blender::nodes::sh_node_magic_tex_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||