Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_white_noise.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_white_noise_cc { | namespace blender::nodes { | ||||
| static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) | static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.is_function_node(); | b.is_function_node(); | ||||
| b.add_input<decl::Vector>(N_("Vector")).min(-10000.0f).max(10000.0f).implicit_field(); | b.add_input<decl::Vector>(N_("Vector")).min(-10000.0f).max(10000.0f).implicit_field(); | ||||
| b.add_input<decl::Float>(N_("W")).min(-10000.0f).max(10000.0f); | b.add_input<decl::Float>(N_("W")).min(-10000.0f).max(10000.0f); | ||||
| b.add_output<decl::Float>(N_("Value")); | b.add_output<decl::Float>(N_("Value")); | ||||
| b.add_output<decl::Color>(N_("Color")); | b.add_output<decl::Color>(N_("Color")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_init_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| node->custom1 = 3; | node->custom1 = 3; | ||||
| } | } | ||||
| static const char *gpu_shader_get_name(const int dimensions) | static const char *gpu_shader_get_name(const int dimensions) | ||||
| { | { | ||||
| BLI_assert(dimensions >= 1 && dimensions <= 4); | BLI_assert(dimensions >= 1 && dimensions <= 4); | ||||
| Show All 17 Lines | |||||
| { | { | ||||
| bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); | bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); | ||||
| bNodeSocket *sockW = nodeFindSocket(node, SOCK_IN, "W"); | bNodeSocket *sockW = nodeFindSocket(node, SOCK_IN, "W"); | ||||
| nodeSetSocketAvailability(ntree, sockVector, node->custom1 != 1); | nodeSetSocketAvailability(ntree, sockVector, node->custom1 != 1); | ||||
| nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4); | nodeSetSocketAvailability(ntree, sockW, node->custom1 == 1 || node->custom1 == 4); | ||||
| } | } | ||||
| namespace blender::nodes { | |||||
| class WhiteNoiseFunction : public fn::MultiFunction { | class WhiteNoiseFunction : public fn::MultiFunction { | ||||
| private: | private: | ||||
| int dimensions_; | int dimensions_; | ||||
| public: | public: | ||||
| WhiteNoiseFunction(int dimensions) : dimensions_(dimensions) | WhiteNoiseFunction(int dimensions) : dimensions_(dimensions) | ||||
| { | { | ||||
| BLI_assert(dimensions >= 1 && dimensions <= 4); | BLI_assert(dimensions >= 1 && dimensions <= 4); | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| static void sh_node_noise_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder) | static void sh_node_noise_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder) | ||||
| { | { | ||||
| bNode &node = builder.node(); | bNode &node = builder.node(); | ||||
| builder.construct_and_set_matching_fn<WhiteNoiseFunction>((int)node.custom1); | builder.construct_and_set_matching_fn<WhiteNoiseFunction>((int)node.custom1); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_white_noise_cc | } // namespace blender::nodes | ||||
| void register_node_type_sh_tex_white_noise() | void register_node_type_sh_tex_white_noise(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_white_noise_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base( | sh_fn_node_type_base( | ||||
| &ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0); | &ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0); | ||||
| ntype.declare = file_ns::sh_node_tex_white_noise_declare; | ntype.declare = blender::nodes::sh_node_tex_white_noise_declare; | ||||
| node_type_init(&ntype, file_ns::node_shader_init_tex_white_noise); | node_type_init(&ntype, node_shader_init_tex_white_noise); | ||||
| node_type_gpu(&ntype, file_ns::gpu_shader_tex_white_noise); | node_type_gpu(&ntype, gpu_shader_tex_white_noise); | ||||
| node_type_update(&ntype, file_ns::node_shader_update_tex_white_noise); | node_type_update(&ntype, node_shader_update_tex_white_noise); | ||||
| ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function; | ntype.build_multi_function = blender::nodes::sh_node_noise_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||