Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_musgrave.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" | ||||
| #include "BLI_noise.hh" | #include "BLI_noise.hh" | ||||
| namespace blender::nodes::node_shader_tex_musgrave_cc { | namespace blender::nodes { | ||||
| static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b) | static void sh_node_tex_musgrave_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Vector>(N_("Vector")).hide_value().implicit_field(); | b.add_input<decl::Vector>(N_("Vector")).hide_value().implicit_field(); | ||||
| b.add_input<decl::Float>(N_("W")).min(-1000.0f).max(1000.0f); | b.add_input<decl::Float>(N_("W")).min(-1000.0f).max(1000.0f); | ||||
| 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_("Detail")).min(0.0f).max(15.0f).default_value(2.0f); | b.add_input<decl::Float>(N_("Detail")).min(0.0f).max(15.0f).default_value(2.0f); | ||||
| b.add_input<decl::Float>(N_("Dimension")).min(0.0f).max(1000.0f).default_value(2.0f); | b.add_input<decl::Float>(N_("Dimension")).min(0.0f).max(1000.0f).default_value(2.0f); | ||||
| b.add_input<decl::Float>(N_("Lacunarity")).min(0.0f).max(1000.0f).default_value(2.0f); | b.add_input<decl::Float>(N_("Lacunarity")).min(0.0f).max(1000.0f).default_value(2.0f); | ||||
| b.add_input<decl::Float>(N_("Offset")).min(-1000.0f).max(1000.0f); | b.add_input<decl::Float>(N_("Offset")).min(-1000.0f).max(1000.0f); | ||||
| b.add_input<decl::Float>(N_("Gain")).min(0.0f).max(1000.0f).default_value(1.0f); | b.add_input<decl::Float>(N_("Gain")).min(0.0f).max(1000.0f).default_value(1.0f); | ||||
| 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_musgrave(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexMusgrave *tex = (NodeTexMusgrave *)MEM_callocN(sizeof(NodeTexMusgrave), | NodeTexMusgrave *tex = (NodeTexMusgrave *)MEM_callocN(sizeof(NodeTexMusgrave), | ||||
| "NodeTexMusgrave"); | "NodeTexMusgrave"); | ||||
| 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->musgrave_type = SHD_MUSGRAVE_FBM; | tex->musgrave_type = SHD_MUSGRAVE_FBM; | ||||
| tex->dimensions = 3; | tex->dimensions = 3; | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | nodeSetSocketAvailability(ntree, | ||||
| inGainSock, | inGainSock, | ||||
| tex->musgrave_type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL || | tex->musgrave_type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL || | ||||
| tex->musgrave_type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL); | tex->musgrave_type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL); | ||||
| bNodeSocket *outFacSock = nodeFindSocket(node, SOCK_OUT, "Fac"); | bNodeSocket *outFacSock = nodeFindSocket(node, SOCK_OUT, "Fac"); | ||||
| node_sock_label(outFacSock, "Height"); | node_sock_label(outFacSock, "Height"); | ||||
| } | } | ||||
| namespace blender::nodes { | |||||
| class MusgraveFunction : public fn::MultiFunction { | class MusgraveFunction : public fn::MultiFunction { | ||||
| private: | private: | ||||
| const int dimensions_; | const int dimensions_; | ||||
| const int musgrave_type_; | const int musgrave_type_; | ||||
| public: | public: | ||||
| MusgraveFunction(const int dimensions, const int musgrave_type) | MusgraveFunction(const int dimensions, const int musgrave_type) | ||||
| : dimensions_(dimensions), musgrave_type_(musgrave_type) | : dimensions_(dimensions), musgrave_type_(musgrave_type) | ||||
| ▲ Show 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | |||||
| static void sh_node_musgrave_build_multi_function( | static void sh_node_musgrave_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &node = builder.node(); | bNode &node = builder.node(); | ||||
| NodeTexMusgrave *tex = (NodeTexMusgrave *)node.storage; | NodeTexMusgrave *tex = (NodeTexMusgrave *)node.storage; | ||||
| builder.construct_and_set_matching_fn<MusgraveFunction>(tex->dimensions, tex->musgrave_type); | builder.construct_and_set_matching_fn<MusgraveFunction>(tex->dimensions, tex->musgrave_type); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_musgrave_cc | } // namespace blender::nodes | ||||
| void register_node_type_sh_tex_musgrave() | void register_node_type_sh_tex_musgrave(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_musgrave_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0); | sh_fn_node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0); | ||||
| ntype.declare = file_ns::sh_node_tex_musgrave_declare; | ntype.declare = blender::nodes::sh_node_tex_musgrave_declare; | ||||
| 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_tex_musgrave); | node_type_init(&ntype, node_shader_init_tex_musgrave); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_musgrave); | node_type_gpu(&ntype, node_shader_gpu_tex_musgrave); | ||||
| node_type_update(&ntype, file_ns::node_shader_update_tex_musgrave); | node_type_update(&ntype, node_shader_update_tex_musgrave); | ||||
| ntype.build_multi_function = file_ns::sh_node_musgrave_build_multi_function; | ntype.build_multi_function = blender::nodes::sh_node_musgrave_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||