Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_wave.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_wave_cc { | namespace blender::nodes { | ||||
| static void sh_node_tex_wave_declare(NodeDeclarationBuilder &b) | static void sh_node_tex_wave_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(0.0f); | b.add_input<decl::Float>(N_("Distortion")).min(-1000.0f).max(1000.0f).default_value(0.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_("Detail Scale")).min(-1000.0f).max(1000.0f).default_value(1.0f); | b.add_input<decl::Float>(N_("Detail Scale")).min(-1000.0f).max(1000.0f).default_value(1.0f); | ||||
| b.add_input<decl::Float>(N_("Detail Roughness")) | b.add_input<decl::Float>(N_("Detail Roughness")) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .max(1.0f) | .max(1.0f) | ||||
| .default_value(0.5f) | .default_value(0.5f) | ||||
| .subtype(PROP_FACTOR); | .subtype(PROP_FACTOR); | ||||
| b.add_input<decl::Float>(N_("Phase Offset")).min(-1000.0f).max(1000.0f).default_value(0.0f); | b.add_input<decl::Float>(N_("Phase Offset")).min(-1000.0f).max(1000.0f).default_value(0.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_wave(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexWave *tex = (NodeTexWave *)MEM_callocN(sizeof(NodeTexWave), "NodeTexWave"); | NodeTexWave *tex = (NodeTexWave *)MEM_callocN(sizeof(NodeTexWave), "NodeTexWave"); | ||||
| 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->wave_type = SHD_WAVE_BANDS; | tex->wave_type = SHD_WAVE_BANDS; | ||||
| tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_X; | tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_X; | ||||
| tex->rings_direction = SHD_WAVE_RINGS_DIRECTION_X; | tex->rings_direction = SHD_WAVE_RINGS_DIRECTION_X; | ||||
| Show All 22 Lines | return GPU_stack_link(mat, | ||||
| in, | in, | ||||
| out, | out, | ||||
| GPU_constant(&wave_type), | GPU_constant(&wave_type), | ||||
| GPU_constant(&bands_direction), | GPU_constant(&bands_direction), | ||||
| GPU_constant(&rings_direction), | GPU_constant(&rings_direction), | ||||
| GPU_constant(&wave_profile)); | GPU_constant(&wave_profile)); | ||||
| } | } | ||||
| namespace blender::nodes { | |||||
| class WaveFunction : public fn::MultiFunction { | class WaveFunction : public fn::MultiFunction { | ||||
| private: | private: | ||||
| int wave_type_; | int wave_type_; | ||||
| int bands_direction_; | int bands_direction_; | ||||
| int rings_direction_; | int rings_direction_; | ||||
| int wave_profile_; | int wave_profile_; | ||||
| public: | public: | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | static void sh_node_wave_tex_build_multi_function( | ||||
| blender::nodes::NodeMultiFunctionBuilder &builder) | blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &node = builder.node(); | bNode &node = builder.node(); | ||||
| NodeTexWave *tex = (NodeTexWave *)node.storage; | NodeTexWave *tex = (NodeTexWave *)node.storage; | ||||
| builder.construct_and_set_matching_fn<WaveFunction>( | builder.construct_and_set_matching_fn<WaveFunction>( | ||||
| tex->wave_type, tex->bands_direction, tex->rings_direction, tex->wave_profile); | tex->wave_type, tex->bands_direction, tex->rings_direction, tex->wave_profile); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_wave_cc | } // namespace blender::nodes | ||||
| void register_node_type_sh_tex_wave() | void register_node_type_sh_tex_wave(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_wave_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0); | sh_fn_node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0); | ||||
| ntype.declare = file_ns::sh_node_tex_wave_declare; | ntype.declare = blender::nodes::sh_node_tex_wave_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_wave); | node_type_init(&ntype, node_shader_init_tex_wave); | ||||
| node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); | node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_wave); | node_type_gpu(&ntype, node_shader_gpu_tex_wave); | ||||
| ntype.build_multi_function = file_ns::sh_node_wave_tex_build_multi_function; | ntype.build_multi_function = blender::nodes::sh_node_wave_tex_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||