Blender V4.3
overlay_shader_shared.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#ifndef GPU_SHADER
6# pragma once
7
9
10# include "DNA_action_types.h"
11# include "DNA_view3d_types.h"
12
13# ifdef __cplusplus
14extern "C" {
15# else
17# endif
21typedef struct VertexData VertexData;
22#endif
23
24/* TODO(fclem): Should eventually become OVERLAY_BackgroundType.
25 * But there is no uint push constant functions at the moment. */
26#define BG_SOLID 0
27#define BG_GRADIENT 1
28#define BG_CHECKER 2
29#define BG_RADIAL 3
30#define BG_SOLID_CHECKER 4
31#define BG_MASK 5
32
34 SHOW_AXIS_X = (1u << 0u),
35 SHOW_AXIS_Y = (1u << 1u),
36 SHOW_AXIS_Z = (1u << 2u),
37 SHOW_GRID = (1u << 3u),
38 PLANE_XY = (1u << 4u),
39 PLANE_XZ = (1u << 5u),
40 PLANE_YZ = (1u << 6u),
41 CLIP_ZPOS = (1u << 7u),
42 CLIP_ZNEG = (1u << 8u),
43 GRID_BACK = (1u << 9u),
44 GRID_CAMERA = (1u << 10u),
45 PLANE_IMAGE = (1u << 11u),
46 CUSTOM_GRID = (1u << 12u),
47};
48#ifndef GPU_SHADER
50#endif
51
52/* Match: #SI_GRID_STEPS_LEN */
53#define OVERLAY_GRID_STEPS_LEN 8
54
55/* Due to the encoding clamping the passed in floats, the wire width needs to be scaled down. */
56#define WIRE_WIDTH_COMPRESSION 16.0
57
59 float4 steps[OVERLAY_GRID_STEPS_LEN]; /* float arrays are padded to float4 in std130. */
60 float4 size; /* float3 padded to float4. */
61 float distance;
62 float line_size;
63 float zoom_factor; /* Only for UV editor */
64 float _pad0;
65};
67
68#ifdef GPU_SHADER
69/* Keep the same values as in `draw_cache_impl_curves.cc` */
70# define EDIT_CURVES_NURBS_CONTROL_POINT (1u)
71# define EDIT_CURVES_BEZIER_HANDLE (1u << 1)
72# define EDIT_CURVES_ACTIVE_HANDLE (1u << 2)
73# define EDIT_CURVES_HANDLE_TYPES_SHIFT (4u)
74/* Keep the same values as in `draw_cache_imp_curve.c` */
75# define ACTIVE_NURB (1u << 2)
76# define BEZIER_HANDLE (1u << 3)
77# define EVEN_U_BIT (1u << 4)
78# define COLOR_SHIFT 5u
79
80/* Keep the same value in `handle_display` in `DNA_view3d_types.h` */
81# define CURVE_HANDLE_SELECTED 0u
82# define CURVE_HANDLE_ALL 1u
83
84# define GP_EDIT_POINT_SELECTED 1u /* 1 << 0 */
85# define GP_EDIT_STROKE_SELECTED 2u /* 1 << 1 */
86# define GP_EDIT_MULTIFRAME 4u /* 1 << 2 */
87# define GP_EDIT_STROKE_START 8u /* 1 << 3 */
88# define GP_EDIT_STROKE_END 16u /* 1 << 4 */
89# define GP_EDIT_POINT_DIMMED 32u /* 1 << 5 */
90
91# define MOTIONPATH_VERT_SEL (1u << 0)
92# define MOTIONPATH_VERT_KEY (1u << 1)
93
94#else
95/* TODO(fclem): Find a better way to share enums/defines from DNA files with GLSL. */
96BLI_STATIC_ASSERT(CURVE_HANDLE_SELECTED == 0u, "Ensure value is sync");
97BLI_STATIC_ASSERT(CURVE_HANDLE_ALL == 1u, "Ensure value is sync");
98BLI_STATIC_ASSERT(MOTIONPATH_VERT_SEL == (1u << 0), "Ensure value is sync");
99BLI_STATIC_ASSERT(MOTIONPATH_VERT_KEY == (1u << 1), "Ensure value is sync");
100#endif
101
143
147
154
170
186
189
191
196
198
204
207
209};
211
213 float4 color_;
215
216#if !defined(GPU_SHADER) && defined(__cplusplus)
217 ExtraInstanceData(const float4x4 &object_to_world, const float4 &color, float draw_size)
218 {
219 this->color_ = color;
220 this->object_to_world_ = object_to_world;
221 this->object_to_world_[3][3] = draw_size;
222 };
223
224 ExtraInstanceData with_color(const float4 &color) const
225 {
226 ExtraInstanceData copy = *this;
227 copy.color_ = color;
228 return copy;
229 }
230
231 /* For degrees of freedom. */
232 ExtraInstanceData(const float4x4 &object_to_world,
233 const float4 &color,
234 float angle_min_x,
235 float angle_min_z,
236 float angle_max_x,
237 float angle_max_z)
238 {
239 this->color_ = color;
240 this->object_to_world_ = object_to_world;
241 this->object_to_world_[0][3] = angle_min_x;
242 this->object_to_world_[1][3] = angle_min_z;
243 this->object_to_world_[2][3] = angle_max_x;
244 this->object_to_world_[3][3] = angle_max_z;
245 };
246#endif
247};
249
251 float4 pos_;
252 /* TODO: change to color_id. Idea expressed in #125894. */
253 float4 color_;
254};
256
257/* Limited by expand_prim_len bit count. */
258#define PARTICLE_SHAPE_CIRCLE_RESOLUTION 7
259
260/* TODO(fclem): This should be a enum, but it breaks compilation on Metal for some reason. */
261#define PART_SHAPE_AXIS 1
262#define PART_SHAPE_CIRCLE 2
263#define PART_SHAPE_CROSS 3
264
267 /* Can either be velocity or acceleration. */
268 float value;
269 /* Rotation encoded as quaternion. */
270 float4 rotation;
271};
273
279 float4 x_axis;
280
281#ifndef GPU_SHADER
282 BoneEnvelopeData() = default;
283
284 /* For bone fills. */
285 BoneEnvelopeData(float4 &head_sphere,
286 float4 &tail_sphere,
287 float3 &bone_color,
288 float3 &state_color,
289 float3 &x_axis)
290 : head_sphere(head_sphere),
291 tail_sphere(tail_sphere),
292 bone_color_and_wire_width(bone_color),
293 state_color(state_color),
294 x_axis(x_axis){};
295
296 /* For bone outlines. */
297 BoneEnvelopeData(float4 &head_sphere,
298 float4 &tail_sphere,
299 float4 &color_and_wire_width,
300 float3 &x_axis)
301 : head_sphere(head_sphere),
302 tail_sphere(tail_sphere),
303 bone_color_and_wire_width(color_and_wire_width),
304 x_axis(x_axis){};
305
306 /* For bone distance volumes. */
307 BoneEnvelopeData(float4 &head_sphere, float4 &tail_sphere, float3 &x_axis)
308 : head_sphere(head_sphere), tail_sphere(tail_sphere), x_axis(x_axis){};
309#endif
310};
312
313/* Keep in sync with armature_stick_vert.glsl. */
315 COL_WIRE = (1u << 0u),
316 COL_HEAD = (1u << 1u),
317 COL_TAIL = (1u << 2u),
318 COL_BONE = (1u << 3u),
319 POS_HEAD = (1u << 4u),
320 POS_TAIL = (1u << 5u),
321 POS_BONE = (1u << 6u),
322};
323
326 float4 bone_end;
331
332#ifndef GPU_SHADER
333 BoneStickData() = default;
334
335 /* For bone fills. */
348#endif
349};
351
352#ifndef GPU_SHADER
353# ifdef __cplusplus
354}
355# endif
356#endif
#define BLI_STATIC_ASSERT(a, msg)
Definition BLI_assert.h:87
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition BLI_assert.h:90
#define ENUM_OPERATORS(_type, _max)
@ MOTIONPATH_VERT_KEY
@ MOTIONPATH_VERT_SEL
@ CURVE_HANDLE_ALL
@ CURVE_HANDLE_SELECTED
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
#define OVERLAY_GRID_STEPS_LEN
struct ExtraInstanceData ExtraInstanceData
BoneEnvelopeData()=default
BoneEnvelopeData(float4 &head_sphere, float4 &tail_sphere, float3 &bone_color, float3 &state_color, float3 &x_axis)
BoneEnvelopeData(float4 &head_sphere, float4 &tail_sphere, float3 &x_axis)
BoneEnvelopeData(float4 &head_sphere, float4 &tail_sphere, float4 &color_and_wire_width, float3 &x_axis)
BoneStickData()=default
BoneStickData(float3 &bone_start, float3 &bone_end, float4 &wire_color, float4 &bone_color, float4 &head_color, float4 &tail_color)
float4 steps[OVERLAY_GRID_STEPS_LEN]