Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_brick.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_float2.hh" | #include "BLI_float2.hh" | ||||
| #include "BLI_float4.hh" | #include "BLI_float4.hh" | ||||
| namespace blender::nodes::node_shader_tex_brick_cc { | namespace blender::nodes { | ||||
| static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b) | static void sh_node_tex_brick_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::Color>(N_("Color1")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); | b.add_input<decl::Color>(N_("Color1")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); | ||||
| b.add_input<decl::Color>(N_("Color2")).default_value({0.2f, 0.2f, 0.2f, 1.0f}); | b.add_input<decl::Color>(N_("Color2")).default_value({0.2f, 0.2f, 0.2f, 1.0f}); | ||||
| b.add_input<decl::Color>(N_("Mortar")).default_value({0.0f, 0.0f, 0.0f, 1.0f}).no_muted_links(); | b.add_input<decl::Color>(N_("Mortar")).default_value({0.0f, 0.0f, 0.0f, 1.0f}).no_muted_links(); | ||||
| Show All 18 Lines | b.add_input<decl::Float>(N_("Row Height")) | ||||
| .min(0.01f) | .min(0.01f) | ||||
| .max(100.0f) | .max(100.0f) | ||||
| .default_value(0.25f) | .default_value(0.25f) | ||||
| .no_muted_links(); | .no_muted_links(); | ||||
| b.add_output<decl::Color>(N_("Color")); | b.add_output<decl::Color>(N_("Color")); | ||||
| b.add_output<decl::Float>(N_("Fac")); | b.add_output<decl::Float>(N_("Fac")); | ||||
| }; | }; | ||||
| } // namespace blender::nodes | |||||
| static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexBrick *tex = (NodeTexBrick *)MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick"); | NodeTexBrick *tex = (NodeTexBrick *)MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick"); | ||||
| 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->offset = 0.5f; | tex->offset = 0.5f; | ||||
| tex->squash = 1.0f; | tex->squash = 1.0f; | ||||
| Show All 26 Lines | return GPU_stack_link(mat, | ||||
| in, | in, | ||||
| out, | out, | ||||
| GPU_uniform(&tex->offset), | GPU_uniform(&tex->offset), | ||||
| GPU_constant(&offset_freq), | GPU_constant(&offset_freq), | ||||
| GPU_uniform(&tex->squash), | GPU_uniform(&tex->squash), | ||||
| GPU_constant(&squash_freq)); | GPU_constant(&squash_freq)); | ||||
| } | } | ||||
| namespace blender::nodes { | |||||
| class BrickFunction : public fn::MultiFunction { | class BrickFunction : public fn::MultiFunction { | ||||
| private: | private: | ||||
| const float offset_; | const float offset_; | ||||
| const int offset_freq_; | const int offset_freq_; | ||||
| const float squash_; | const float squash_; | ||||
| const int squash_freq_; | const int squash_freq_; | ||||
| public: | public: | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| bNode &node = builder.node(); | bNode &node = builder.node(); | ||||
| NodeTexBrick *tex = (NodeTexBrick *)node.storage; | NodeTexBrick *tex = (NodeTexBrick *)node.storage; | ||||
| builder.construct_and_set_matching_fn<BrickFunction>( | builder.construct_and_set_matching_fn<BrickFunction>( | ||||
| tex->offset, tex->offset_freq, tex->squash, tex->squash_freq); | tex->offset, tex->offset_freq, tex->squash, tex->squash_freq); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_brick_cc | } // namespace blender::nodes | ||||
| void register_node_type_sh_tex_brick() | void register_node_type_sh_tex_brick(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_brick_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0); | sh_fn_node_type_base(&ntype, SH_NODE_TEX_BRICK, "Brick Texture", NODE_CLASS_TEXTURE, 0); | ||||
| ntype.declare = file_ns::sh_node_tex_brick_declare; | ntype.declare = blender::nodes::sh_node_tex_brick_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_brick); | node_type_init(&ntype, node_shader_init_tex_brick); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_brick); | node_type_gpu(&ntype, node_shader_gpu_tex_brick); | ||||
| ntype.build_multi_function = file_ns::sh_node_brick_build_multi_function; | ntype.build_multi_function = blender::nodes::sh_node_brick_build_multi_function; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||