Blender V4.3
overlay_shader.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "DRW_render.hh"
10
11#include "GPU_shader.hh"
12
13#include "UI_resources.hh"
14
16
17#include "overlay_private.hh"
18
116};
117
118static struct {
120} e_data = {{{nullptr}}};
121
123{
124 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
125 if (!sh_data->antialiasing) {
126 sh_data->antialiasing = GPU_shader_create_from_info_name("overlay_antialiasing");
127 }
128 return sh_data->antialiasing;
129}
130
132{
133 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
134 if (!sh_data->background) {
135 sh_data->background = GPU_shader_create_from_info_name("overlay_background");
136 }
137 return sh_data->background;
138}
139
141{
142 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
143 if (!sh_data->clipbound) {
144 sh_data->clipbound = GPU_shader_create_from_info_name("overlay_clipbound");
145 }
146 return sh_data->clipbound;
147}
148
150{
151 const DRWContextState *draw_ctx = DRW_context_state_get();
152 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
153 if (!sh_data->depth_only) {
155 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_depth_only_clipped" :
156 "overlay_depth_only");
157 }
158 return sh_data->depth_only;
159}
160
162{
163 const DRWContextState *draw_ctx = DRW_context_state_get();
164 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
165 if (!sh_data->edit_mesh_depth) {
167 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_depth_clipped" :
168 "overlay_edit_mesh_depth");
169 }
170 return sh_data->edit_mesh_depth;
171}
172
174{
175 const DRWContextState *draw_ctx = DRW_context_state_get();
176 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
177 if (!sh_data->edit_mesh_vert) {
179 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_vert_clipped" :
180 "overlay_edit_mesh_vert");
181 }
182 return sh_data->edit_mesh_vert;
183}
184
186{
187 const DRWContextState *draw_ctx = DRW_context_state_get();
188 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
189 GPUShader **sh = use_flat_interp ? &sh_data->edit_mesh_edge_flat : &sh_data->edit_mesh_edge;
190 if (*sh == nullptr) {
192 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
193 (use_flat_interp ? "overlay_edit_mesh_edge_flat_clipped" :
194 "overlay_edit_mesh_edge_clipped") :
195 (use_flat_interp ? "overlay_edit_mesh_edge_flat" : "overlay_edit_mesh_edge"));
196 }
197 return *sh;
198}
199
201{
202 const DRWContextState *draw_ctx = DRW_context_state_get();
203 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
204 if (use_outline && !sh_data->armature_sphere_outline) {
206 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_sphere_outline_clipped" :
207 "overlay_armature_sphere_outline");
208 }
209 else if (!sh_data->armature_sphere_solid) {
211 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_sphere_solid_clipped" :
212 "overlay_armature_sphere_solid");
213 }
215}
216
218{
219 const DRWContextState *draw_ctx = DRW_context_state_get();
220 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
221 if (use_outline && !sh_data->armature_shape_outline) {
223 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_shape_outline_clipped" :
224 "overlay_armature_shape_outline");
225 }
226 else if (!sh_data->armature_shape_solid) {
228 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_shape_solid_clipped" :
229 "overlay_armature_shape_solid");
230 }
232}
233
235{
236 const DRWContextState *draw_ctx = DRW_context_state_get();
237 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
240 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_shape_wire_clipped" :
241 "overlay_armature_shape_wire");
242 }
244}
245
247{
248 const DRWContextState *draw_ctx = DRW_context_state_get();
249 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
250 if (use_outline && !sh_data->armature_envelope_outline) {
252 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
253 "overlay_armature_envelope_outline_clipped" :
254 "overlay_armature_envelope_outline");
255 }
256 else if (!sh_data->armature_envelope_solid) {
258 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_envelope_solid_clipped" :
259 "overlay_armature_envelope_solid");
260 }
262}
263
265{
266 const DRWContextState *draw_ctx = DRW_context_state_get();
267 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
268 if (!sh_data->armature_stick) {
270 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_stick_clipped" :
271 "overlay_armature_stick");
272 }
273 return sh_data->armature_stick;
274}
275
277{
278 const DRWContextState *draw_ctx = DRW_context_state_get();
279 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
282 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_dof_clipped" :
283 "overlay_armature_dof");
284 }
286}
287
289{
290 const DRWContextState *draw_ctx = DRW_context_state_get();
291 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
294 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_dof_clipped" :
295 "overlay_armature_dof");
296 }
298}
299
301{
302 const DRWContextState *draw_ctx = DRW_context_state_get();
303 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
304 if (!sh_data->armature_wire) {
306 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_armature_wire_clipped" :
307 "overlay_armature_wire");
308 }
309 return sh_data->armature_wire;
310}
311
313{
314 const DRWContextState *draw_ctx = DRW_context_state_get();
315 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
318 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_curve_handle_clipped" :
319 "overlay_edit_curve_handle");
320 }
322}
323
325{
326 const DRWContextState *draw_ctx = DRW_context_state_get();
327 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
330 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_curve_point_clipped" :
331 "overlay_edit_curve_point");
332 }
334}
335
337{
338 const DRWContextState *draw_ctx = DRW_context_state_get();
339 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
342 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_curves_handle_clipped" :
343 "overlay_edit_curves_handle");
344 }
346}
347
349{
350 const DRWContextState *draw_ctx = DRW_context_state_get();
351 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
352 if (!sh_data->edit_curve_wire) {
354 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_curve_wire_clipped" :
355 "overlay_edit_curve_wire");
356 }
357 return sh_data->edit_curve_wire;
358}
359
361{
362 const DRWContextState *draw_ctx = DRW_context_state_get();
363 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
366 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_gpencil_guide_point_clipped" :
367 "overlay_edit_gpencil_guide_point");
368 }
370}
371
373{
374 const DRWContextState *draw_ctx = DRW_context_state_get();
375 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
378 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_gpencil_point_clipped" :
379 "overlay_edit_gpencil_point");
380 }
382}
383
385{
386 const DRWContextState *draw_ctx = DRW_context_state_get();
387 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
390 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_gpencil_wire_clipped" :
391 "overlay_edit_gpencil_wire");
392 }
394}
395
397{
398 const DRWContextState *draw_ctx = DRW_context_state_get();
399 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
402 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_lattice_point_clipped" :
403 "overlay_edit_lattice_point");
404 }
406}
407
409{
410 const DRWContextState *draw_ctx = DRW_context_state_get();
411 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
414 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_lattice_wire_clipped" :
415 "overlay_edit_lattice_wire");
416 }
418}
419
421{
422 const DRWContextState *draw_ctx = DRW_context_state_get();
423 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
424 if (!sh_data->edit_mesh_face) {
426 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_face_clipped" :
427 "overlay_edit_mesh_face");
428 }
429 return sh_data->edit_mesh_face;
430}
431
433{
434 const DRWContextState *draw_ctx = DRW_context_state_get();
435 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
438 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_facedot_clipped" :
439 "overlay_edit_mesh_facedot");
440 }
442}
443
445{
446 const DRWContextState *draw_ctx = DRW_context_state_get();
447 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
450 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_normal_clipped" :
451 "overlay_edit_mesh_normal");
452 }
454}
455
457{
458 const DRWContextState *draw_ctx = DRW_context_state_get();
459 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
462 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_analysis_clipped" :
463 "overlay_edit_mesh_analysis");
464 }
466}
467
469{
470 const DRWContextState *draw_ctx = DRW_context_state_get();
471 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
474 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_mesh_skin_root_clipped" :
475 "overlay_edit_mesh_skin_root");
476 }
478}
479
481{
482 const DRWContextState *draw_ctx = DRW_context_state_get();
483 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
486 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_particle_strand_clipped" :
487 "overlay_edit_particle_strand");
488 }
490}
491
493{
494 const DRWContextState *draw_ctx = DRW_context_state_get();
495 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
498 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_edit_particle_point_clipped" :
499 "overlay_edit_particle_point");
500 }
502}
503
505{
506 const DRWContextState *draw_ctx = DRW_context_state_get();
507 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
508 GPUShader **sh = (is_select) ? &sh_data->extra_select : &sh_data->extra;
509 if (!*sh) {
511 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
512 (is_select ? "overlay_extra_select_clipped" : "overlay_extra_clipped") :
513 (is_select ? "overlay_extra_select" : "overlay_extra"));
514 }
515 return *sh;
516}
517
519{
520 const DRWContextState *draw_ctx = DRW_context_state_get();
521 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
524 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_extra_grid_clipped" :
525 "overlay_extra_grid");
526 }
528}
529
531{
532 const DRWContextState *draw_ctx = DRW_context_state_get();
533 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
536 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_extra_groundline_clipped" :
537 "overlay_extra_groundline");
538 }
540}
541
542GPUShader *OVERLAY_shader_extra_wire(bool use_object, bool is_select)
543{
544 const DRWContextState *draw_ctx = DRW_context_state_get();
545 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
546 GPUShader **sh = (is_select) ? &sh_data->extra_wire_select : &sh_data->extra_wire[use_object];
547 if (!*sh) {
548 const char *info_name = nullptr;
549 if (draw_ctx->sh_cfg) {
550 if (is_select) {
551 info_name = "overlay_extra_wire_select_clipped";
552 }
553 else {
554 info_name = use_object ? "overlay_extra_wire_object_clipped" :
555 "overlay_extra_wire_clipped";
556 }
557 }
558 else {
559 if (is_select) {
560 info_name = "overlay_extra_wire_select";
561 }
562 else {
563 info_name = use_object ? "overlay_extra_wire_object" : "overlay_extra_wire";
564 }
565 }
566 *sh = GPU_shader_create_from_info_name(info_name);
567 }
568 return *sh;
569}
570
572{
573 const DRWContextState *draw_ctx = DRW_context_state_get();
574 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
577 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_extra_loose_point_clipped" :
578 "overlay_extra_loose_point");
579 }
581}
582
584{
585 const DRWContextState *draw_ctx = DRW_context_state_get();
586 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
587 if (!sh_data->extra_point) {
589 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_extra_point_clipped" :
590 "overlay_extra_point");
591 }
592 return sh_data->extra_point;
593}
594
596{
597 const DRWContextState *draw_ctx = DRW_context_state_get();
598 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
599 if (!sh_data->facing) {
601 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_facing_clipped" :
602 "overlay_facing");
603 }
604 return sh_data->facing;
605}
606
608{
609 const DRWContextState *draw_ctx = DRW_context_state_get();
610 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
611 if (!sh_data->gpencil_canvas) {
612 /* TODO(fclem): Support Clipping? Everything is already setup but don't want to change behavior
613 * without agreement of all gpencil module. */
615 false ? "overlay_gpencil_canvas_clipped" : "overlay_gpencil_canvas");
616 }
617 return sh_data->gpencil_canvas;
618}
619
621{
622 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
623 if (!sh_data->grid) {
625 }
626 return sh_data->grid;
627}
628
637
639{
640 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
641 if (!sh_data->grid_image) {
642 sh_data->grid_image = GPU_shader_create_from_info_name("overlay_grid_image");
643 }
644 return sh_data->grid_image;
645}
646
656
665
667{
668 const DRWContextState *draw_ctx = DRW_context_state_get();
669 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
670 if (!sh_data->image) {
671 /* TODO(fclem): Do we want to allow clipping reference images? */
672 sh_data->image = GPU_shader_create_from_info_name(false ? "overlay_image_clipped" :
673 "overlay_image");
674 }
675 return sh_data->image;
676}
677
679{
680 const DRWContextState *draw_ctx = DRW_context_state_get();
681 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
684 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_motion_path_line_clipped" :
685 "overlay_motion_path_line");
686 }
688}
689
691{
692 const DRWContextState *draw_ctx = DRW_context_state_get();
693 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
696 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_motion_path_point_clipped" :
697 "overlay_motion_path_point");
698 }
700}
701
703{
704 const DRWContextState *draw_ctx = DRW_context_state_get();
705 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
706 if (use_wire && !sh_data->outline_prepass_wire) {
708 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_outline_prepass_wire_clipped" :
709 "overlay_outline_prepass_wire");
710 }
711 else if (!sh_data->outline_prepass) {
713 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_outline_prepass_mesh_clipped" :
714 "overlay_outline_prepass_mesh");
715 }
717}
718
720{
721 const DRWContextState *draw_ctx = DRW_context_state_get();
722 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
725 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_outline_prepass_curves_clipped" :
726 "overlay_outline_prepass_curves");
727 }
729}
730
732{
733 const DRWContextState *draw_ctx = DRW_context_state_get();
734 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
737 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_outline_prepass_gpencil_clipped" :
738 "overlay_outline_prepass_gpencil");
739 }
741}
742
744{
745 const DRWContextState *draw_ctx = DRW_context_state_get();
746 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
749 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
750 "overlay_outline_prepass_pointcloud_clipped" :
751 "overlay_outline_prepass_pointcloud");
752 }
754}
755
757{
758 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
759 if (!sh_data->outline_detect) {
760 sh_data->outline_detect = GPU_shader_create_from_info_name("overlay_outline_detect");
761 }
762 return sh_data->outline_detect;
763}
764
766{
767 const DRWContextState *draw_ctx = DRW_context_state_get();
768 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
769 if (!sh_data->paint_face) {
771 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_paint_face_clipped" :
772 "overlay_paint_face");
773 }
774 return sh_data->paint_face;
775}
776
778{
779 const DRWContextState *draw_ctx = DRW_context_state_get();
780 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
781 if (!sh_data->paint_point) {
783 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_paint_point_clipped" :
784 "overlay_paint_point");
785 }
786 return sh_data->paint_point;
787}
788
790{
791 const DRWContextState *draw_ctx = DRW_context_state_get();
792 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
793 if (!sh_data->paint_texture) {
795 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_paint_texture_clipped" :
796 "overlay_paint_texture");
797 }
798 return sh_data->paint_texture;
799}
800
802{
803 const DRWContextState *draw_ctx = DRW_context_state_get();
804 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
805 if (!sh_data->paint_vertcol) {
807 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_paint_vertcol_clipped" :
808 "overlay_paint_vertcol");
809 }
810 return sh_data->paint_vertcol;
811}
812
814{
815 const char *info_name[2][2] = {
816 {"overlay_paint_weight", "overlay_paint_weight_fake_shading"},
817 {"overlay_paint_weight_clipped", "overlay_paint_weight_fake_shading_clipped"},
818 };
819 int index = shading ? 1 : 0;
820 const DRWContextState *draw_ctx = DRW_context_state_get();
821 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
822 if (!sh_data->paint_weight[index]) {
824 info_name[draw_ctx->sh_cfg][index]);
825 }
826 return sh_data->paint_weight[index];
827}
828
830{
831 const DRWContextState *draw_ctx = DRW_context_state_get();
832 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
833 if (!sh_data->paint_wire) {
835 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_paint_wire_clipped" :
836 "overlay_paint_wire");
837 }
838 return sh_data->paint_wire;
839}
840
842{
843 const DRWContextState *draw_ctx = DRW_context_state_get();
844 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
845 if (!sh_data->particle_dot) {
847 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_particle_dot_clipped" :
848 "overlay_particle_dot");
849 }
850 return sh_data->particle_dot;
851}
852
854{
855 const DRWContextState *draw_ctx = DRW_context_state_get();
856 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
857 if (!sh_data->particle_shape) {
859 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_particle_shape_clipped" :
860 "overlay_particle_shape");
861 }
862 return sh_data->particle_shape;
863}
864
866{
867 const DRWContextState *draw_ctx = DRW_context_state_get();
868 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
869 if (!sh_data->sculpt_mask) {
871 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_sculpt_mask_clipped" :
872 "overlay_sculpt_mask");
873 }
874 return sh_data->sculpt_mask;
875}
876
878{
879 const DRWContextState *draw_ctx = DRW_context_state_get();
880 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
883 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_sculpt_curves_selection_clipped" :
884 "overlay_sculpt_curves_selection");
885 }
887}
888
890{
891 const DRWContextState *draw_ctx = DRW_context_state_get();
892 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
895 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_sculpt_curves_cage_clipped" :
896 "overlay_sculpt_curves_cage");
897 }
899}
900
902{
903 const DRWContextState *draw_ctx = DRW_context_state_get();
904 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
907 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_viewer_attribute_mesh_clipped" :
908 "overlay_viewer_attribute_mesh");
909 }
911}
912
914{
915 const DRWContextState *draw_ctx = DRW_context_state_get();
916 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
919 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
920 "overlay_viewer_attribute_pointcloud_clipped" :
921 "overlay_viewer_attribute_pointcloud");
922 }
924}
925
927{
928 const DRWContextState *draw_ctx = DRW_context_state_get();
929 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
932 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_viewer_attribute_curve_clipped" :
933 "overlay_viewer_attribute_curve");
934 }
936}
937
939{
940 const DRWContextState *draw_ctx = DRW_context_state_get();
941 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
944 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_viewer_attribute_curves_clipped" :
945 "overlay_viewer_attribute_curves");
946 }
948}
949
951{
952 const DRWContextState *draw_ctx = DRW_context_state_get();
953 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
954 if (!sh_data->uniform_color) {
956 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_uniform_color_clipped" :
957 "overlay_uniform_color");
958 }
959 return sh_data->uniform_color;
960}
961
963{
964 const DRWContextState *draw_ctx = DRW_context_state_get();
965 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
968 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_uniform_color_pointcloud_clipped" :
969 "overlay_uniform_color_pointcloud");
970 }
972}
973
974GPUShader *OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac)
975{
976 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
977 if (use_needle && !sh_data->volume_velocity_needle_sh) {
979 "overlay_volume_velocity_needle");
980 }
981 else if (use_mac && !sh_data->volume_velocity_mac_sh) {
983 "overlay_volume_velocity_mac");
984 }
985 else if (!sh_data->volume_velocity_sh) {
987 "overlay_volume_velocity_streamline");
988 }
989
990 if (use_needle) {
992 }
993 if (use_mac) {
995 }
997}
998
999GPUShader *OVERLAY_shader_volume_gridlines(bool color_with_flags, bool color_range)
1000{
1001 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1002 if (!sh_data->volume_gridlines_flags_sh && color_with_flags) {
1004 "overlay_volume_gridlines_flags");
1005 }
1006 else if (!sh_data->volume_gridlines_range_sh && color_range) {
1008 "overlay_volume_gridlines_range");
1009 }
1010 else if (!sh_data->volume_gridlines_sh) {
1012 "overlay_volume_gridlines_flat");
1013 }
1014
1015 if (color_with_flags) {
1017 }
1018 if (color_range) {
1020 }
1021
1023}
1024
1026{
1027 const DRWContextState *draw_ctx = DRW_context_state_get();
1028 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
1029 if (!sh_data->wireframe_select) {
1031 (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_wireframe_select_clipped" :
1032 "overlay_wireframe_select");
1033 }
1034 return sh_data->wireframe_select;
1035}
1036
1038{
1039 const DRWContextState *draw_ctx = DRW_context_state_get();
1040 OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
1041 if (!sh_data->wireframe[custom_bias]) {
1043 custom_bias ? ((draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ?
1044 "overlay_wireframe_custom_depth_clipped" :
1045 "overlay_wireframe_custom_depth") :
1046 ((draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_wireframe_clipped" :
1047 "overlay_wireframe"));
1048 }
1049 return sh_data->wireframe[custom_bias];
1050}
1051
1053{
1054 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1055 if (!sh_data->xray_fade) {
1056 sh_data->xray_fade = GPU_shader_create_from_info_name("overlay_xray_fade");
1057 }
1058 return sh_data->xray_fade;
1059}
1060
1061/* -------------------------------------------------------------------- */
1066{
1067 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1068 if (!sh_data->edit_uv_edges) {
1069 sh_data->edit_uv_edges = GPU_shader_create_from_info_name("overlay_edit_uv_edges");
1070 }
1071 return sh_data->edit_uv_edges;
1072}
1073
1083
1085{
1086 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1087 if (!sh_data->edit_uv_faces) {
1088 sh_data->edit_uv_faces = GPU_shader_create_from_info_name("overlay_edit_uv_faces");
1089 }
1090 return sh_data->edit_uv_faces;
1091}
1092
1101
1103{
1104 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1105 if (!sh_data->edit_uv_verts) {
1106 sh_data->edit_uv_verts = GPU_shader_create_from_info_name("overlay_edit_uv_verts");
1107 }
1108
1109 return sh_data->edit_uv_verts;
1110}
1111
1113{
1114 OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
1117 "overlay_edit_uv_stretching_area");
1118 }
1119
1121}
1122
1133
1143
1147
1149{
1151 {
1152 {"pos", DRW_ATTR_FLOAT, 3},
1153 });
1155 {
1156 {"pos", DRW_ATTR_FLOAT, 3},
1157 {"color", DRW_ATTR_FLOAT, 4},
1158 });
1160 {
1161 {"inst_pos", DRW_ATTR_FLOAT, 3},
1162 });
1164 {
1165 {"color", DRW_ATTR_FLOAT, 4},
1166 {"inst_obmat", DRW_ATTR_FLOAT, 16},
1167 });
1169 {
1170 {"pos", DRW_ATTR_FLOAT, 3},
1171 {"colorid", DRW_ATTR_INT, 1},
1172 });
1174 {
1175 {"pos", DRW_ATTR_FLOAT, 3},
1176 {"vertex_color", DRW_ATTR_FLOAT, 4},
1177 });
1179 {
1180 {"inst_obmat", DRW_ATTR_FLOAT, 16},
1181 });
1183 {
1184 {"boneStart", DRW_ATTR_FLOAT, 3},
1185 {"boneEnd", DRW_ATTR_FLOAT, 3},
1186 {"wireColor", DRW_ATTR_FLOAT, 4}, /* TODO: `uchar` color. */
1187 {"boneColor", DRW_ATTR_FLOAT, 4},
1188 {"headColor", DRW_ATTR_FLOAT, 4},
1189 {"tailColor", DRW_ATTR_FLOAT, 4},
1190 });
1192 {
1193 {"headSphere", DRW_ATTR_FLOAT, 4},
1194 {"tailSphere", DRW_ATTR_FLOAT, 4},
1195 {"outlineColorSize", DRW_ATTR_FLOAT, 4},
1196 {"xAxis", DRW_ATTR_FLOAT, 3},
1197 });
1199 {
1200 {"headSphere", DRW_ATTR_FLOAT, 4},
1201 {"tailSphere", DRW_ATTR_FLOAT, 4},
1202 {"xAxis", DRW_ATTR_FLOAT, 3},
1203 });
1205 {
1206 {"headSphere", DRW_ATTR_FLOAT, 4},
1207 {"tailSphere", DRW_ATTR_FLOAT, 4},
1208 {"boneColor", DRW_ATTR_FLOAT, 3},
1209 {"stateColor", DRW_ATTR_FLOAT, 3},
1210 {"xAxis", DRW_ATTR_FLOAT, 3},
1211 });
1212
1213 return &g_formats;
1214}
1215
1217{
1218 for (int sh_data_index = 0; sh_data_index < ARRAY_SIZE(e_data.sh_data); sh_data_index++) {
1219 OVERLAY_Shaders *sh_data = &e_data.sh_data[sh_data_index];
1220 GPUShader **sh_data_as_array = (GPUShader **)sh_data;
1221 for (int i = 0; i < (sizeof(OVERLAY_Shaders) / sizeof(GPUShader *)); i++) {
1222 DRW_SHADER_FREE_SAFE(sh_data_as_array[i]);
1223 }
1224 }
1226 for (int i = 0; i < sizeof(g_formats) / sizeof(void *); i++, format++) {
1228 }
1229}
#define ARRAY_SIZE(arr)
#define DRW_shgroup_instance_format(format,...)
#define DRW_SHADER_FREE_SAFE(shader)
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
@ GPU_SHADER_CFG_CLIPPED
#define GPU_SHADER_CFG_LEN
#define MEM_SAFE_FREE(v)
struct GPUShader GPUShader
const DRWContextState * DRW_context_state_get()
format
GPUShader * OVERLAY_shader_edit_uv_edges_for_edge_select_get()
GPUShader * OVERLAY_shader_edit_uv_face_dots_get()
GPUShader * OVERLAY_shader_extra_wire(bool use_object, bool is_select)
GPUShader * OVERLAY_shader_armature_wire()
GPUShader * OVERLAY_shader_edit_lattice_point()
GPUShader * OVERLAY_shader_edit_uv_stencil_image()
GPUShader * OVERLAY_shader_edit_mesh_facedot()
GPUShader * OVERLAY_shader_edit_uv_mask_image()
GPUShader * OVERLAY_shader_wireframe(bool custom_bias)
GPUShader * OVERLAY_shader_edit_gpencil_wire()
GPUShader * OVERLAY_shader_edit_uv_verts_get()
GPUShader * OVERLAY_shader_uniform_color()
GPUShader * OVERLAY_shader_sculpt_mask()
GPUShader * OVERLAY_shader_armature_stick()
GPUShader * OVERLAY_shader_edit_mesh_normal()
GPUShader * OVERLAY_shader_outline_prepass(bool use_wire)
GPUShader * OVERLAY_shader_edit_gpencil_point()
GPUShader * OVERLAY_shader_armature_shape(bool use_outline)
GPUShader * OVERLAY_shader_outline_prepass_pointcloud()
GPUShader * OVERLAY_shader_paint_texture()
GPUShader * OVERLAY_shader_paint_weight(const bool shading)
static struct @244 e_data
GPUShader * OVERLAY_shader_paint_wire()
GPUShader * OVERLAY_shader_edit_particle_point()
GPUShader * OVERLAY_shader_clipbound()
GPUShader * OVERLAY_shader_edit_uv_tiled_image_borders_get()
GPUShader * OVERLAY_shader_edit_uv_stretching_angle_get()
void OVERLAY_shader_free()
GPUShader * OVERLAY_shader_uniform_color_pointcloud()
OVERLAY_Shaders sh_data[GPU_SHADER_CFG_LEN]
GPUShader * OVERLAY_shader_edit_curve_handle()
GPUShader * OVERLAY_shader_sculpt_curves_cage()
GPUShader * OVERLAY_shader_image()
GPUShader * OVERLAY_shader_armature_sphere(bool use_outline)
GPUShader * OVERLAY_shader_facing()
GPUShader * OVERLAY_shader_edit_mesh_depth()
GPUShader * OVERLAY_shader_edit_gpencil_guide_point()
GPUShader * OVERLAY_shader_grid_background()
GPUShader * OVERLAY_shader_edit_mesh_edge(bool use_flat_interp)
GPUShader * OVERLAY_shader_armature_shape_wire()
GPUShader * OVERLAY_shader_volume_gridlines(bool color_with_flags, bool color_range)
GPUShader * OVERLAY_shader_extra_grid()
GPUShader * OVERLAY_shader_viewer_attribute_curve()
GPUShader * OVERLAY_shader_armature_degrees_of_freedom_wire()
GPUShader * OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac)
GPUShader * OVERLAY_shader_paint_face()
GPUShader * OVERLAY_shader_extra_point()
GPUShader * OVERLAY_shader_particle_shape()
GPUShader * OVERLAY_shader_armature_degrees_of_freedom_solid()
GPUShader * OVERLAY_shader_outline_detect()
GPUShader * OVERLAY_shader_edit_uv_edges_get()
GPUShader * OVERLAY_shader_edit_curve_wire()
GPUShader * OVERLAY_shader_edit_mesh_skin_root()
GPUShader * OVERLAY_shader_viewer_attribute_pointcloud()
GPUShader * OVERLAY_shader_motion_path_vert()
GPUShader * OVERLAY_shader_background()
GPUShader * OVERLAY_shader_extra_loose_point()
GPUShader * OVERLAY_shader_edit_mesh_analysis()
GPUShader * OVERLAY_shader_grid()
GPUShader * OVERLAY_shader_sculpt_curves_selection()
GPUShader * OVERLAY_shader_edit_particle_strand()
GPUShader * OVERLAY_shader_particle_dot()
GPUShader * OVERLAY_shader_paint_vertcol()
GPUShader * OVERLAY_shader_motion_path_line()
GPUShader * OVERLAY_shader_wireframe_select()
GPUShader * OVERLAY_shader_extra(bool is_select)
GPUShader * OVERLAY_shader_edit_curves_handle()
GPUShader * OVERLAY_shader_edit_uv_face_get()
GPUShader * OVERLAY_shader_xray_fade()
GPUShader * OVERLAY_shader_outline_prepass_gpencil()
GPUShader * OVERLAY_shader_edit_mesh_vert()
GPUShader * OVERLAY_shader_depth_only()
GPUShader * OVERLAY_shader_edit_uv_stretching_area_get()
GPUShader * OVERLAY_shader_antialiasing()
GPUShader * OVERLAY_shader_armature_envelope(bool use_outline)
OVERLAY_InstanceFormats * OVERLAY_shader_instance_formats_get()
GPUShader * OVERLAY_shader_edit_curve_point()
GPUShader * OVERLAY_shader_edit_mesh_face()
GPUShader * OVERLAY_shader_gpencil_canvas()
GPUShader * OVERLAY_shader_outline_prepass_curves()
GPUShader * OVERLAY_shader_viewer_attribute_curves()
GPUShader * OVERLAY_shader_paint_point()
GPUShader * OVERLAY_shader_extra_groundline()
GPUShader * OVERLAY_shader_edit_lattice_wire()
GPUShader * OVERLAY_shader_viewer_attribute_mesh()
GPUShader * OVERLAY_shader_grid_image()
static OVERLAY_InstanceFormats g_formats
eGPUShaderConfig sh_cfg
GPUVertFormat * instance_bone_envelope_distance
GPUVertFormat * instance_bone_envelope_outline
GPUVertFormat * instance_bone
GPUVertFormat * instance_extra
GPUVertFormat * instance_bone_stick
GPUVertFormat * instance_bone_envelope
GPUShader * uniform_color_pointcloud
GPUShader * image
GPUShader * edit_curve_handle
GPUShader * edit_uv_stencil_image
GPUShader * edit_mesh_face
GPUShader * edit_uv_face_dots
GPUShader * paint_weight[2]
GPUShader * volume_gridlines_sh
GPUShader * armature_envelope_solid
GPUShader * edit_uv_faces
GPUShader * edit_particle_strand
GPUShader * grid_image
GPUShader * volume_velocity_mac_sh
GPUShader * paint_face
GPUShader * depth_only
GPUShader * clipbound
GPUShader * paint_vertcol
GPUShader * wireframe_select
GPUShader * edit_mesh_normals
GPUShader * grid_background
GPUShader * outline_prepass_pointcloud
GPUShader * edit_uv_verts
GPUShader * edit_uv_stretching_angle
GPUShader * motion_path_vert
GPUShader * outline_detect
GPUShader * sculpt_curves_cage
GPUShader * edit_mesh_depth
GPUShader * edit_mesh_edge_flat
GPUShader * edit_mesh_skin_root
GPUShader * edit_mesh_fnormals
GPUShader * particle_dot
GPUShader * edit_curve_point
GPUShader * armature_shape_solid
GPUShader * volume_gridlines_flags_sh
GPUShader * paint_wire
GPUShader * sculpt_mask
GPUShader * edit_mesh_edge
GPUShader * outline_prepass_gpencil
GPUShader * sculpt_curves_selection
GPUShader * viewer_attribute_curve
GPUShader * edit_uv_tiled_image_borders
GPUShader * edit_gpencil_guide_point
GPUShader * uniform_color
GPUShader * edit_mesh_facedot
GPUShader * edit_uv_edges
GPUShader * outline_prepass_curves
GPUShader * particle_shape
GPUShader * antialiasing
GPUShader * viewer_attribute_mesh
GPUShader * outline_prepass
GPUShader * armature_sphere_solid
GPUShader * edit_gpencil_wire
GPUShader * armature_shape_wire
GPUShader * edit_lattice_point
GPUShader * extra_point
GPUShader * extra_loose_point
GPUShader * extra_select
GPUShader * edit_lattice_wire
GPUShader * armature_envelope_outline
GPUShader * background
GPUShader * extra_lightprobe_grid
GPUShader * wireframe[2]
GPUShader * paint_texture
GPUShader * edit_mesh_vert
GPUShader * edit_mesh_analysis
GPUShader * extra_groundline
GPUShader * facing
GPUShader * edit_curves_handle
GPUShader * edit_gpencil_point
GPUShader * paint_point
GPUShader * armature_shape_outline
GPUShader * xray_fade
GPUShader * edit_uv_edges_for_edge_select
GPUShader * volume_velocity_needle_sh
GPUShader * extra_wire[2]
GPUShader * armature_stick
GPUShader * outline_prepass_wire
GPUShader * viewer_attribute_curves
GPUShader * edit_uv_mask_image
GPUShader * pointcloud_dot
GPUShader * armature_dof_wire
GPUShader * armature_wire
GPUShader * edit_particle_point
GPUShader * volume_velocity_sh
GPUShader * edit_mesh_vnormals
GPUShader * edit_curve_wire
GPUShader * extra_wire_select
GPUShader * armature_dof_solid
GPUShader * volume_gridlines_range_sh
GPUShader * gpencil_canvas
GPUShader * edit_uv_stretching_area
GPUShader * armature_sphere_outline
GPUShader * motion_path_line
GPUShader * extra
GPUShader * viewer_attribute_pointcloud