Blender V5.0
node_shader_ies_light.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "node_shader_util.hh"
6#include "node_util.hh"
7
8#include "RNA_access.hh"
9
11#include "UI_resources.hh"
12
14
16{
17 b.add_input<decl::Vector>("Vector").hide_value();
18 b.add_input<decl::Float>("Strength")
19 .default_value(1.0f)
20 .min(0.0f)
21 .max(1000000.0f)
22 .description("Strength of the light source")
23 .translation_context(BLT_I18NCONTEXT_AMOUNT);
24 b.add_output<decl::Float>("Factor", "Fac");
25}
26
27static void node_shader_buts_ies(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
28{
29 uiLayout *row;
30
31 row = &layout->row(false);
32 row->prop(ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
33
34 row = &layout->row(true);
35
36 if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) {
37 row->prop(ptr, "ies", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
38 }
39 else {
40 row->prop(ptr, "filepath", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
41 }
42}
43
44static void node_shader_init_tex_ies(bNodeTree * /*ntree*/, bNode *node)
45{
46 NodeShaderTexIES *tex = MEM_callocN<NodeShaderTexIES>("NodeShaderIESLight");
47 node->storage = tex;
48}
49
50} // namespace blender::nodes::node_shader_ies_light_cc
51
52/* node type definition */
54{
56
57 static blender::bke::bNodeType ntype;
58
59 sh_node_type_base(&ntype, "ShaderNodeTexIES", SH_NODE_TEX_IES);
60 ntype.ui_name = "IES Texture";
61 ntype.ui_description =
62 "Match real world lights with IES files, which store the directional intensity distribution "
63 "of light sources";
64 ntype.enum_name_legacy = "TEX_IES";
66 ntype.declare = file_ns::node_declare;
67 ntype.draw_buttons = file_ns::node_shader_buts_ies;
68 ntype.initfunc = file_ns::node_shader_init_tex_ies;
70 ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage);
71
73}
#define NODE_CLASS_TEXTURE
Definition BKE_node.hh:457
#define SH_NODE_TEX_IES
#define BLT_I18NCONTEXT_AMOUNT
@ NODE_IES_INTERNAL
@ UI_ITEM_R_SPLIT_EMPTY_NAME
@ UI_ITEM_R_EXPAND
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
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))
Definition node.cc:5414
static void node_shader_init_tex_ies(bNodeTree *, bNode *node)
static void node_shader_buts_ies(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
void register_node_type_sh_tex_ies()
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)
Definition node_util.cc:42
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:54
int RNA_enum_get(PointerRNA *ptr, const char *name)
void * storage
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:259
NodeDeclareFunction declare
Definition BKE_node.hh:362
uiLayout & row(bool align)
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)
PointerRNA * ptr
Definition wm_files.cc:4238