Blender V5.3
overlay_extra_infos.hh
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#ifdef GPU_SHADER
6# pragma once
7# include "gpu_shader_compat.hh"
8
10# include "draw_view_infos.hh"
11
13
15#endif
16
18
19/* -------------------------------------------------------------------- */
22
23GPU_SHADER_INTERFACE_INFO(overlay_extra_iface)
24NO_PERSPECTIVE(float2, edge_pos)
25FLAT(float2, edge_start)
26FLAT(float4, final_color)
28
29GPU_SHADER_CREATE_INFO(overlay_extra)
31TYPEDEF_SOURCE("overlay_shader_shared.hh")
32VERTEX_IN(0, float3, pos)
33VERTEX_IN(1, int, vclass)
34VERTEX_OUT(overlay_extra_iface)
36FRAGMENT_OUT(1, float4, line_output)
37VERTEX_SOURCE("overlay_extra_vert.glsl")
38FRAGMENT_SOURCE("overlay_extra_frag.glsl")
39ADDITIONAL_INFO(draw_view)
40ADDITIONAL_INFO(draw_globals)
41STORAGE_BUF(0, read, ExtraInstanceData, data_buf[])
43
44/* clang-format off */
45CREATE_INFO_VARIANT(overlay_extra_selectable, overlay_extra, overlay_select)
46CREATE_INFO_VARIANT(overlay_extra_clipped, overlay_extra, drw_clipped)
47CREATE_INFO_VARIANT(overlay_extra_selectable_clipped, overlay_extra_selectable, drw_clipped)
48/* clang-format on */
49
50GPU_SHADER_CREATE_INFO(overlay_extra_spot_cone)
52ADDITIONAL_INFO(overlay_extra)
53DEFINE("IS_SPOT_CONE")
55
56CREATE_INFO_VARIANT(overlay_extra_spot_cone_clipped, overlay_extra_spot_cone, drw_clipped)
57
59
60/* -------------------------------------------------------------------- */
63
64GPU_SHADER_INTERFACE_INFO(overlay_extra_grid_iface)
65FLAT(float4, final_color)
67
68GPU_SHADER_CREATE_INFO(overlay_extra_grid_base)
69SAMPLER(0, sampler2DDepth, depth_buffer)
70PUSH_CONSTANT(float4x4, grid_model_matrix)
71PUSH_CONSTANT(bool, is_transform)
72VERTEX_OUT(overlay_extra_grid_iface)
74VERTEX_SOURCE("overlay_extra_lightprobe_grid_vert.glsl")
75FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
76ADDITIONAL_INFO(draw_view)
77ADDITIONAL_INFO(draw_globals)
79
80/* clang-format off */
81CREATE_INFO_VARIANT(overlay_extra_grid, overlay_extra_grid_base, draw_modelmat)
82CREATE_INFO_VARIANT(overlay_extra_grid_selectable, overlay_extra_grid_base, draw_modelmat_with_custom_id, overlay_select)
83CREATE_INFO_VARIANT(overlay_extra_grid_clipped, overlay_extra_grid, drw_clipped)
84CREATE_INFO_VARIANT(overlay_extra_grid_selectable_clipped, overlay_extra_grid_selectable, drw_clipped)
85/* clang-format on */
86
88
89/* -------------------------------------------------------------------- */
92
93GPU_SHADER_CREATE_INFO(overlay_extra_groundline)
95VERTEX_IN(0, float3, pos)
96/* Instance attributes. */
97VERTEX_OUT(overlay_extra_iface)
99FRAGMENT_OUT(1, float4, line_output)
100VERTEX_SOURCE("overlay_extra_groundline_vert.glsl")
101FRAGMENT_SOURCE("overlay_extra_frag.glsl")
102ADDITIONAL_INFO(draw_view)
103ADDITIONAL_INFO(draw_globals)
104STORAGE_BUF(0, read, float4, data_buf[])
106
107/* clang-format off */
108CREATE_INFO_VARIANT(overlay_extra_groundline_selectable, overlay_extra_groundline, overlay_select)
109CREATE_INFO_VARIANT(overlay_extra_groundline_clipped, overlay_extra_groundline, drw_clipped)
110CREATE_INFO_VARIANT(overlay_extra_groundline_selectable_clipped, overlay_extra_groundline_selectable, drw_clipped)
111/* clang-format on */
112
114
115/* -------------------------------------------------------------------- */
118
119GPU_SHADER_INTERFACE_INFO(overlay_extra_wire_iface)
120NO_PERSPECTIVE(float2, stipple_coord)
121FLAT(float2, stipple_start)
122FLAT(float4, final_color)
124
125GPU_SHADER_CREATE_INFO(overlay_extra_wire_base)
126VERTEX_OUT(overlay_extra_wire_iface)
128FRAGMENT_OUT(1, float4, line_output)
129VERTEX_SOURCE("overlay_extra_wire_vert.glsl")
130FRAGMENT_SOURCE("overlay_extra_wire_frag.glsl")
131TYPEDEF_SOURCE("overlay_shader_shared.hh")
132STORAGE_BUF(0, read, VertexData, data_buf[])
133PUSH_CONSTANT(int, colorid)
134DEFINE_VALUE("pos", "data_buf[gl_VertexID].pos_.xyz")
135DEFINE_VALUE("color", "data_buf[gl_VertexID].color_")
136ADDITIONAL_INFO(draw_view)
137ADDITIONAL_INFO(draw_globals)
139
140/* clang-format off */
141CREATE_INFO_VARIANT(overlay_extra_wire, overlay_extra_wire_base, draw_modelmat)
142CREATE_INFO_VARIANT(overlay_extra_wire_selectable, overlay_extra_wire_base, draw_modelmat_with_custom_id, overlay_select)
143CREATE_INFO_VARIANT(overlay_extra_wire_clipped, overlay_extra_wire, drw_clipped)
144CREATE_INFO_VARIANT(overlay_extra_wire_selectable_clipped, overlay_extra_wire_selectable, drw_clipped)
145/* clang-format on */
146
147GPU_SHADER_CREATE_INFO(overlay_extra_wire_object_base)
148VERTEX_IN(0, float3, pos)
149VERTEX_IN(1, float4, color)
150/* If colorid is equal to 0 (i.e: Not specified) use color attribute and stippling. */
151VERTEX_IN(2, int, colorid)
152VERTEX_OUT(overlay_extra_wire_iface)
154FRAGMENT_OUT(1, float4, line_output)
155VERTEX_SOURCE("overlay_extra_wire_vert.glsl")
156FRAGMENT_SOURCE("overlay_extra_wire_frag.glsl")
157DEFINE("OBJECT_WIRE")
158ADDITIONAL_INFO(draw_view)
159ADDITIONAL_INFO(draw_globals)
161
162/* clang-format off */
163CREATE_INFO_VARIANT(overlay_extra_wire_object, overlay_extra_wire_object_base, draw_modelmat)
164CREATE_INFO_VARIANT(overlay_extra_wire_object_selectable, overlay_extra_wire_object_base, draw_modelmat_with_custom_id, overlay_select)
165CREATE_INFO_VARIANT(overlay_extra_wire_object_clipped, overlay_extra_wire_object, drw_clipped)
166CREATE_INFO_VARIANT(overlay_extra_wire_object_selectable_clipped, overlay_extra_wire_object_selectable, drw_clipped)
167/* clang-format on */
168
170
171/* -------------------------------------------------------------------- */
174
175GPU_SHADER_INTERFACE_INFO(overlay_extra_point_iface)
176FLAT(float4, radii)
177FLAT(float4, fill_color)
178FLAT(float4, outline_color)
180
181GPU_SHADER_CREATE_INFO(overlay_extra_point_base)
182/* TODO(fclem): Move the vertex shader to Overlay engine and remove this bypass. */
183DEFINE_VALUE("blender_srgb_to_framebuffer_space(a)", "a")
184VERTEX_OUT(overlay_extra_point_iface)
186VERTEX_SOURCE("overlay_extra_point_vert.glsl")
187FRAGMENT_SOURCE("overlay_point_varying_color_varying_outline_aa_frag.glsl")
188ADDITIONAL_INFO(draw_view)
189ADDITIONAL_INFO(draw_globals)
190TYPEDEF_SOURCE("overlay_shader_shared.hh")
191STORAGE_BUF(0, read, VertexData, data_buf[])
193
194/* clang-format off */
195CREATE_INFO_VARIANT(overlay_extra_point, overlay_extra_point_base, draw_modelmat)
196CREATE_INFO_VARIANT(overlay_extra_point_selectable, overlay_extra_point_base, draw_modelmat_with_custom_id, overlay_select)
197CREATE_INFO_VARIANT(overlay_extra_point_clipped, overlay_extra_point, drw_clipped)
198CREATE_INFO_VARIANT(overlay_extra_point_selectable_clipped, overlay_extra_point_selectable, drw_clipped)
199/* clang-format on */
200
201GPU_SHADER_INTERFACE_INFO(overlay_extra_loose_point_iface)
202SMOOTH(float4, final_color)
204
205GPU_SHADER_CREATE_INFO(overlay_extra_loose_point_base)
206VERTEX_OUT(overlay_extra_loose_point_iface)
208FRAGMENT_OUT(1, float4, line_output)
209VERTEX_SOURCE("overlay_extra_loose_point_vert.glsl")
210FRAGMENT_SOURCE("overlay_extra_loose_point_frag.glsl")
211TYPEDEF_SOURCE("overlay_shader_shared.hh")
212STORAGE_BUF(0, read, VertexData, data_buf[])
213ADDITIONAL_INFO(draw_view)
214ADDITIONAL_INFO(draw_globals)
216
217/* clang-format off */
218CREATE_INFO_VARIANT(overlay_extra_loose_point, overlay_extra_loose_point_base, draw_modelmat)
219CREATE_INFO_VARIANT(overlay_extra_loose_point_selectable, overlay_extra_loose_point_base, draw_modelmat_with_custom_id, overlay_select)
220CREATE_INFO_VARIANT(overlay_extra_loose_point_clipped, overlay_extra_loose_point, drw_clipped)
221CREATE_INFO_VARIANT(overlay_extra_loose_point_selectable_clipped, overlay_extra_loose_point_selectable, drw_clipped)
222/* clang-format on */
223
225
226/* -------------------------------------------------------------------- */
229
230GPU_SHADER_NAMED_INTERFACE_INFO(overlay_motion_path_line_iface, interp)
231SMOOTH(float4, color)
233
234GPU_SHADER_CREATE_INFO(overlay_motion_path_line)
236STORAGE_BUF_FREQ(0, read, float, pos[], GEOMETRY)
237PUSH_CONSTANT(int2, gpu_attr_0)
238PUSH_CONSTANT(int, gpu_attr_0_len) /* Avoid a warning on Metal. */
239PUSH_CONSTANT(int4, mpath_line_settings)
240PUSH_CONSTANT(bool, selected)
241PUSH_CONSTANT(float3, custom_color_pre)
242PUSH_CONSTANT(float3, custom_color_post)
243PUSH_CONSTANT(int, line_thickness) /* In pixels. */
244PUSH_CONSTANT(float4x4, camera_object_persinv)
245VERTEX_OUT(overlay_motion_path_line_iface)
247VERTEX_SOURCE("overlay_motion_path_line_vert.glsl")
248FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl")
249ADDITIONAL_INFO(draw_view)
250ADDITIONAL_INFO(gpu_index_buffer_load)
251ADDITIONAL_INFO(draw_globals)
253
254CREATE_INFO_VARIANT(overlay_motion_path_line_clipped, overlay_motion_path_line, drw_clipped)
255
256GPU_SHADER_INTERFACE_INFO(overlay_motion_path_point_iface)
257FLAT(float4, final_color)
259
260GPU_SHADER_CREATE_INFO(overlay_motion_path_point)
262TYPEDEF_SOURCE("overlay_shader_shared.hh")
263VERTEX_IN(0, float3, pos)
264VERTEX_IN(1, int, flag)
265PUSH_CONSTANT(int4, mpath_point_settings)
266PUSH_CONSTANT(bool, show_key_frames)
267PUSH_CONSTANT(float3, custom_color_pre)
268PUSH_CONSTANT(float3, custom_color_post)
269PUSH_CONSTANT(float4x4, camera_object_persinv)
270VERTEX_OUT(overlay_motion_path_point_iface)
272VERTEX_SOURCE("overlay_motion_path_point_vert.glsl")
273FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
274ADDITIONAL_INFO(draw_view)
275ADDITIONAL_INFO(draw_globals)
277
278CREATE_INFO_VARIANT(overlay_motion_path_point_clipped, overlay_motion_path_point, drw_clipped)
279
281
282/* -------------------------------------------------------------------- */
285
286GPU_SHADER_INTERFACE_INFO(overlay_image_iface)
287SMOOTH(float2, uvs)
289
290GPU_SHADER_CREATE_INFO(overlay_image_base)
291PUSH_CONSTANT(bool, depth_set)
292PUSH_CONSTANT(bool, is_camera_background)
293PUSH_CONSTANT(bool, img_premultiplied)
294PUSH_CONSTANT(bool, img_alpha_blend)
295PUSH_CONSTANT(float4, ucolor)
296VERTEX_IN(0, float3, pos)
297VERTEX_OUT(overlay_image_iface)
298SAMPLER(0, sampler2D, img_tx)
300VERTEX_SOURCE("overlay_image_vert.glsl")
301FRAGMENT_SOURCE("overlay_image_frag.glsl")
302ADDITIONAL_INFO(draw_view)
303ADDITIONAL_INFO(draw_globals)
305
306/* clang-format off */
307CREATE_INFO_VARIANT(overlay_image, overlay_image_base, draw_modelmat)
308CREATE_INFO_VARIANT(overlay_image_selectable, overlay_image_base, draw_modelmat_with_custom_id, overlay_select)
309CREATE_INFO_VARIANT(overlay_image_clipped, overlay_image, drw_clipped)
310CREATE_INFO_VARIANT(overlay_image_selectable_clipped, overlay_image_selectable, drw_clipped)
311/* clang-format on */
312
313GPU_SHADER_CREATE_INFO(overlay_image_depth_bias_base)
314ADDITIONAL_INFO(overlay_image_base)
315DEFINE("DEPTH_BIAS")
316PUSH_CONSTANT(float4x4, depth_bias_winmat)
318
319/* clang-format off */
320CREATE_INFO_VARIANT(overlay_image_depth_bias, overlay_image_depth_bias_base, draw_modelmat)
321CREATE_INFO_VARIANT(overlay_image_depth_bias_selectable, overlay_image_depth_bias_base, draw_modelmat_with_custom_id, overlay_select)
322CREATE_INFO_VARIANT(overlay_image_depth_bias_clipped, overlay_image_depth_bias, drw_clipped)
323CREATE_INFO_VARIANT(overlay_image_depth_bias_selectable_clipped, overlay_image_depth_bias_selectable, drw_clipped)
324/* clang-format on */
325
327
328/* -------------------------------------------------------------------- */
331
332GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas)
334VERTEX_OUT(overlay_extra_iface)
335PUSH_CONSTANT(float4, color)
336PUSH_CONSTANT(float3, axis_x)
337PUSH_CONSTANT(float3, axis_y)
338PUSH_CONSTANT(float3, origin)
339PUSH_CONSTANT(int, half_line_count)
341FRAGMENT_OUT(1, float4, line_output)
342VERTEX_SOURCE("overlay_edit_gpencil_canvas_vert.glsl")
343FRAGMENT_SOURCE("overlay_extra_frag.glsl")
344ADDITIONAL_INFO(draw_mesh)
345ADDITIONAL_INFO(draw_view)
346ADDITIONAL_INFO(draw_globals)
348
349CREATE_INFO_VARIANT(overlay_gpencil_canvas_clipped, overlay_gpencil_canvas, drw_clipped)
350
352
353/* -------------------------------------------------------------------- */
356
357GPU_SHADER_INTERFACE_INFO(overlay_particle_iface)
358FLAT(float4, final_color)
360
361GPU_SHADER_CREATE_INFO(overlay_particle_dot_base)
362SAMPLER(0, sampler1D, weight_tx)
363PUSH_CONSTANT(float4, ucolor) /* Draw-size packed in alpha. */
364VERTEX_IN(0, float3, part_pos)
365VERTEX_IN(1, float4, part_rot)
366VERTEX_IN(2, float, part_val)
367VERTEX_OUT(overlay_particle_iface)
369FRAGMENT_OUT(1, float4, line_output)
370VERTEX_SOURCE("overlay_particle_vert.glsl")
371FRAGMENT_SOURCE("overlay_particle_frag.glsl")
372ADDITIONAL_INFO(draw_view)
373ADDITIONAL_INFO(draw_globals)
375
376/* clang-format off */
377CREATE_INFO_VARIANT(overlay_particle_dot, overlay_particle_dot_base, draw_modelmat)
378CREATE_INFO_VARIANT(overlay_particle_dot_selectable, overlay_particle_dot_base, draw_modelmat_with_custom_id, overlay_select)
379CREATE_INFO_VARIANT(overlay_particle_dot_clipped, overlay_particle_dot, drw_clipped)
380CREATE_INFO_VARIANT(overlay_particle_dot_selectable_clipped, overlay_particle_dot_selectable, drw_clipped)
381/* clang-format on */
382
383GPU_SHADER_CREATE_INFO(overlay_particle_shape_base)
384TYPEDEF_SOURCE("overlay_shader_shared.hh")
385SAMPLER(0, sampler1D, weight_tx)
386PUSH_CONSTANT(float4, ucolor) /* Draw-size packed in alpha. */
387PUSH_CONSTANT(int, shape_type)
388/* Use first attribute to only bind one buffer. */
389STORAGE_BUF_FREQ(0, read, ParticlePointData, part_pos[], GEOMETRY)
390VERTEX_OUT(overlay_extra_iface)
392FRAGMENT_OUT(1, float4, line_output)
393VERTEX_SOURCE("overlay_particle_shape_vert.glsl")
394FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl")
395ADDITIONAL_INFO(draw_view)
396ADDITIONAL_INFO(draw_globals)
398
399/* clang-format off */
400CREATE_INFO_VARIANT(overlay_particle_shape, overlay_particle_shape_base, draw_modelmat)
401CREATE_INFO_VARIANT(overlay_particle_shape_selectable, overlay_particle_shape_base, draw_modelmat_with_custom_id, overlay_select)
402CREATE_INFO_VARIANT(overlay_particle_shape_clipped, overlay_particle_shape, drw_clipped)
403CREATE_INFO_VARIANT(overlay_particle_shape_selectable_clipped, overlay_particle_shape_selectable, drw_clipped)
404/* clang-format on */
405
406GPU_SHADER_CREATE_INFO(overlay_particle_hair_base)
407TYPEDEF_SOURCE("overlay_shader_shared.hh")
408VERTEX_IN(0, float3, pos)
409VERTEX_IN(1, float3, nor)
410PUSH_CONSTANT(int, color_type)
411PUSH_CONSTANT(bool, is_transform)
412PUSH_CONSTANT(bool, use_coloring)
413VERTEX_OUT(overlay_extra_iface)
415FRAGMENT_OUT(1, float4, line_output)
416VERTEX_SOURCE("overlay_particle_hair_vert.glsl")
417FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl")
418ADDITIONAL_INFO(draw_view)
419ADDITIONAL_INFO(draw_object_infos)
420ADDITIONAL_INFO(draw_globals)
422
423/* clang-format off */
424CREATE_INFO_VARIANT(overlay_particle_hair, overlay_particle_hair_base, draw_modelmat)
425CREATE_INFO_VARIANT(overlay_particle_hair_selectable, overlay_particle_hair_base, draw_modelmat_with_custom_id, overlay_select)
426CREATE_INFO_VARIANT(overlay_particle_hair_clipped, overlay_particle_hair, drw_clipped)
427CREATE_INFO_VARIANT(overlay_particle_hair_selectable_clipped, overlay_particle_hair_selectable, drw_clipped)
428/* clang-format on */
429
#define GPU_SHADER_INTERFACE_END()
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_NAMED_INTERFACE_END(_inst_name)
#define GPU_SHADER_INTERFACE_INFO(_interface)
#define GPU_SHADER_CREATE_INFO(_info)
#define GPU_SHADER_CREATE_END()
#define TYPEDEF_SOURCE(filename)
#define VERTEX_OUT(stage_interface)
#define SMOOTH(type, name)
#define SAMPLER(slot, type, name)
#define CREATE_INFO_VARIANT(name,...)
#define FRAGMENT_SOURCE(filename)
#define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq)
#define ADDITIONAL_INFO(info_name)
#define PUSH_CONSTANT(type, name)
#define DEFINE(name)
#define FLAT(type, name)
#define FRAGMENT_OUT(slot, type, name)
#define NO_PERSPECTIVE(type, name)
#define STORAGE_BUF(slot, qualifiers, type_name, name)
#define VERTEX_SOURCE(filename)
#define VERTEX_IN(slot, type, name)
#define DO_STATIC_COMPILATION()
#define DEFINE_VALUE(name, value)
#define frag_color(slot)
MatBase< 4, 4 > float4x4
SamplerBase< float, 1 > sampler1D
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:549