Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_geometry.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2005 Blender Foundation. All rights reserved. */ | * Copyright 2005 Blender Foundation. All rights reserved. */ | ||||
| #include "node_shader_util.hh" | #include "node_shader_util.hh" | ||||
| #include "NOD_geometry_exec.hh" | |||||
| namespace blender::nodes::node_shader_geometry_cc { | namespace blender::nodes::node_shader_geometry_cc { | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_output<decl::Vector>(N_("Position")); | b.add_output<decl::Vector>(N_("Position")); | ||||
| b.add_output<decl::Vector>(N_("Normal")); | b.add_output<decl::Vector>(N_("Normal")); | ||||
| b.add_output<decl::Vector>(N_("Tangent")); | b.add_output<decl::Vector>(N_("Tangent")); | ||||
| b.add_output<decl::Vector>(N_("True Normal")); | b.add_output<decl::Vector>(N_("True Normal")); | ||||
| Show All 39 Lines | if (ELEM(i, 1, 2, 4)) { | ||||
| &out[i].link, | &out[i].link, | ||||
| nullptr); | nullptr); | ||||
| } | } | ||||
| } | } | ||||
| return success; | return success; | ||||
| } | } | ||||
| static void node_geo_exec(GeoNodeExecParams params) | |||||
| { | |||||
| /* Texture nodes are always evaluated in object spaces, whereas the shader | |||||
| * node outputs world space. For that reason this duplicates much of the | |||||
| * texture coordinate node. */ | |||||
| if (params.output_is_required("Position")) { | |||||
| Field<float3> field{AttributeFieldInput::Create<float3>("position")}; | |||||
| params.set_output("Position", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("Normal")) { | |||||
| Field<float3> field{std::make_shared<bke::NormalFieldInput>()}; | |||||
| params.set_output("Normal", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("Tangent")) { | |||||
| Field<float3> field{AttributeFieldInput::Create<float3>(".tangent")}; | |||||
| params.set_output("Tangent", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("True Normal")) { | |||||
| Field<float3> field{AttributeFieldInput::Create<float3>(".face_normal")}; | |||||
| params.set_output("True Normal", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("Parametric")) { | |||||
| Field<float3> field{AttributeFieldInput::Create<float3>(".parametric")}; | |||||
| params.set_output("Parametric", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("Backfacing")) { | |||||
| /* No view direction in texture nodes. */ | |||||
| params.set_output("Backfacing", float(0.0f)); | |||||
| } | |||||
| if (params.output_is_required("Pointiness")) { | |||||
| Field<float> field{AttributeFieldInput::Create<float>(".pointiness")}; | |||||
| params.set_output("Pointiness", std::move(field)); | |||||
| } | |||||
| if (params.output_is_required("Random Per Island")) { | |||||
| Field<float> field{AttributeFieldInput::Create<float>(".random_per_island")}; | |||||
| params.set_output("Random Per Island", std::move(field)); | |||||
| } | |||||
| } | |||||
| } // namespace blender::nodes::node_shader_geometry_cc | } // namespace blender::nodes::node_shader_geometry_cc | ||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_geometry() | void register_node_type_sh_geometry() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_geometry_cc; | namespace file_ns = blender::nodes::node_shader_geometry_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_NEW_GEOMETRY, "Geometry", NODE_CLASS_INPUT); | sh_fn_node_type_base(&ntype, SH_NODE_NEW_GEOMETRY, "Geometry", NODE_CLASS_INPUT); | ||||
| ntype.declare = file_ns::node_declare; | ntype.declare = file_ns::node_declare; | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_geometry); | node_type_gpu(&ntype, file_ns::node_shader_gpu_geometry); | ||||
| ntype.geometry_node_execute = file_ns::node_geo_exec; | |||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||