Blender  V2.93
FX_shader_glow.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2018, Blender Foundation
17  * This is a new part of Blender
18  */
19 
24 #include <stdio.h>
25 
26 #include "DNA_gpencil_types.h"
27 #include "DNA_object_types.h"
28 #include "DNA_scene_types.h"
29 #include "DNA_screen_types.h"
30 
31 #include "BLI_math.h"
32 #include "BLI_utildefines.h"
33 
34 #include "BKE_context.h"
35 #include "BKE_modifier.h"
36 #include "BKE_screen.h"
37 #include "BKE_shader_fx.h"
38 
39 #include "UI_interface.h"
40 #include "UI_resources.h"
41 
42 #include "RNA_access.h"
43 
44 #include "FX_shader_types.h"
45 #include "FX_ui_common.h"
46 
47 static void initData(ShaderFxData *md)
48 {
49  GlowShaderFxData *gpfx = (GlowShaderFxData *)md;
50  ARRAY_SET_ITEMS(gpfx->glow_color, 0.75f, 1.0f, 1.0f, 1.0f);
51  ARRAY_SET_ITEMS(gpfx->select_color, 0.0f, 0.0f, 0.0f);
52  copy_v2_fl(gpfx->blur, 50.0f);
53  gpfx->threshold = 0.1f;
54  gpfx->samples = 8;
55 }
56 
57 static void copyData(const ShaderFxData *md, ShaderFxData *target)
58 {
60 }
61 
62 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
63 {
64  uiLayout *layout = panel->layout;
65 
67 
68  int mode = RNA_enum_get(ptr, "mode");
69 
70  uiLayoutSetPropSep(layout, true);
71 
72  uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
73 
74  if (mode == eShaderFxGlowMode_Luminance) {
75  uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
76  }
77  else {
78  uiItemR(layout, ptr, "select_color", 0, NULL, ICON_NONE);
79  }
80  uiItemR(layout, ptr, "glow_color", 0, NULL, ICON_NONE);
81 
82  uiItemS(layout);
83 
84  uiItemR(layout, ptr, "blend_mode", 0, NULL, ICON_NONE);
85  uiItemR(layout, ptr, "opacity", 0, NULL, ICON_NONE);
86  uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
87  uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
88  uiItemR(layout, ptr, "samples", 0, NULL, ICON_NONE);
89  uiItemR(layout, ptr, "use_glow_under", 0, NULL, ICON_NONE);
90 
91  shaderfx_panel_end(layout, ptr);
92 }
93 
94 static void panelRegister(ARegionType *region_type)
95 {
97 }
98 
100  /* name */ "Glow",
101  /* structName */ "GlowShaderFxData",
102  /* structSize */ sizeof(GlowShaderFxData),
103  /* type */ eShaderFxType_GpencilType,
104  /* flags */ 0,
105 
106  /* copyData */ copyData,
107 
108  /* initData */ initData,
109  /* freeData */ NULL,
110  /* isDisabled */ NULL,
111  /* updateDepsgraph */ NULL,
112  /* dependsOnTime */ NULL,
113  /* foreachIDLink */ NULL,
114  /* panelRegister */ panelRegister,
115 };
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:49
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
MINLINE void copy_v2_fl(float r[2], float f)
#define ARRAY_SET_ITEMS(...)
#define UNUSED(x)
Object is a sort of wrapper for general info.
struct GlowShaderFxData GlowShaderFxData
@ eShaderFxGlowMode_Luminance
@ eShaderFxType_Glow
static void initData(ShaderFxData *md)
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
static void panelRegister(ARegionType *region_type)
static void copyData(const ShaderFxData *md, ShaderFxData *target)
ShaderFxTypeInfo shaderfx_Type_Glow
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
Definition: FX_ui_common.c:242
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: FX_ui_common.c:99
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
Definition: FX_ui_common.c:111
#define C
Definition: RandGen.cpp:39
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
struct uiLayout * layout
PointerRNA * ptr
Definition: wm_files.c:3157