27 .
description(
"Strength of the normal mapping effect")
30 .default_value({0.5f, 0.5f, 1.0f, 1.0f})
31 .description(
"Color that encodes the normal map in the specified space");
49 layout->
prop_search(
ptr,
"uv_map", &dataptr,
"uv_layers",
"", ICON_GROUP_UVS);
74 strength =
in[0].link;
76 else if (node->
runtime->original) {
89 newnormal =
in[1].link;
91 else if (node->
runtime->original) {
101 const char *color_to_normal_fnc_name =
"color_to_normal_new_shading";
103 color_to_normal_fnc_name =
"color_to_blender_normal_new_shading";
106 GPU_link(mat, color_to_normal_fnc_name, newnormal, &newnormal);
121 GPU_link(mat,
"normal_transform_object_to_world", newnormal, &newnormal);
130 GPU_link(mat,
"node_normal_map_mix", strength, newnormal, &
out[0].link);
139 NodeItem
color = get_input_value(
"Color", NodeItem::Type::Vector3);
140 NodeItem strength = get_input_value(
"Strength", NodeItem::Type::Float);
142# if MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38
144 switch (normal_map_node->
space) {
161 return create_node(
"normalmap",
162 NodeItem::Type::Vector3,
163 {{
"in",
color}, {
"scale", strength}, {
"space", val(space)}});
166 return create_node(
"normalmap", NodeItem::Type::Vector3, {{
"in", color}, {
"scale", strength}});
171 NodeItem tangent = val(MaterialX::Vector3(1.0f, 0.0f, 0.0f));
172 NodeItem bitangent = val(MaterialX::Vector3(0.0f, 1.0f, 0.0f));
173 NodeItem normal = val(MaterialX::Vector3(0.0f, 0.0f, 1.0f));
175 return create_node(
"normalmap",
176 NodeItem::Type::Vector3,
179 {
"tangent", tangent},
180 {
"bitangent", bitangent},
181 {
"normal", normal}});
199 "Generate a perturbed normal from an RGB normal map image. Typically used for faking highly "
203 ntype.
declare = file_ns::node_declare;
204 ntype.
draw_buttons = file_ns::node_shader_buts_normal_map;
206 ntype.
initfunc = file_ns::node_shader_init_normal_map;
209 ntype.
gpu_fn = file_ns::gpu_shader_normal_map;
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
#define NODE_CLASS_OP_VECTOR
#define SH_NODE_NORMAL_MAP
#define BLI_assert_unreachable()
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define BLT_I18NCONTEXT_AMOUNT
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ SHD_SPACE_BLENDER_OBJECT
@ SHD_SPACE_BLENDER_WORLD
GPUNodeLink * GPU_constant(const float *num)
@ GPU_MATFLAG_OBJECT_INFO
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_uniform(const float *num)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
BPy_StructRNA * depsgraph
void * MEM_callocN(size_t len, const char *str)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_init_normal_map(bNodeTree *, bNode *node)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_normal_map()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_id_pointer_create(ID *id)
bNodeRuntimeHandle * runtime
NodeMaterialXFunction materialx_fn
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< blender::StringRefNull > name, int icon, bool results_are_suggestions)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)