Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_shader.c
| Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | typedef struct OVERLAY_Shaders { | ||||
| GPUShader *edit_mesh_skin_root; | GPUShader *edit_mesh_skin_root; | ||||
| GPUShader *edit_mesh_vnormals; | GPUShader *edit_mesh_vnormals; | ||||
| GPUShader *edit_mesh_normals; | GPUShader *edit_mesh_normals; | ||||
| GPUShader *edit_mesh_fnormals; | GPUShader *edit_mesh_fnormals; | ||||
| GPUShader *edit_mesh_analysis; | GPUShader *edit_mesh_analysis; | ||||
| GPUShader *edit_particle_strand; | GPUShader *edit_particle_strand; | ||||
| GPUShader *edit_particle_point; | GPUShader *edit_particle_point; | ||||
| GPUShader *extra; | GPUShader *extra; | ||||
| GPUShader *extra_select; | |||||
| GPUShader *extra_groundline; | GPUShader *extra_groundline; | ||||
| GPUShader *extra_wire[2]; | GPUShader *extra_wire[2]; | ||||
| GPUShader *extra_wire_select; | |||||
| GPUShader *extra_point; | GPUShader *extra_point; | ||||
| GPUShader *extra_lightprobe_grid; | GPUShader *extra_lightprobe_grid; | ||||
| GPUShader *extra_loose_point; | GPUShader *extra_loose_point; | ||||
| GPUShader *facing; | GPUShader *facing; | ||||
| GPUShader *gpencil_canvas; | GPUShader *gpencil_canvas; | ||||
| GPUShader *grid; | GPUShader *grid; | ||||
| GPUShader *image; | GPUShader *image; | ||||
| GPUShader *motion_path_line; | GPUShader *motion_path_line; | ||||
| ▲ Show 20 Lines • Show All 615 Lines • ▼ Show 20 Lines | sh_data->edit_particle_point = GPU_shader_create_from_arrays({ | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL}, | ||||
| .defs = (const char *[]){sh_cfg->def, NULL}, | .defs = (const char *[]){sh_cfg->def, NULL}, | ||||
| }); | }); | ||||
| } | } | ||||
| return sh_data->edit_particle_point; | return sh_data->edit_particle_point; | ||||
| } | } | ||||
| GPUShader *OVERLAY_shader_extra(void) | GPUShader *OVERLAY_shader_extra(bool is_select) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | ||||
| OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | ||||
| if (!sh_data->extra) { | GPUShader **sh = (is_select) ? &sh_data->extra_select : &sh_data->extra; | ||||
| sh_data->extra = GPU_shader_create_from_arrays({ | if (!*sh) { | ||||
| *sh = GPU_shader_create_from_arrays({ | |||||
| .vert = (const char *[]){sh_cfg->lib, | .vert = (const char *[]){sh_cfg->lib, | ||||
| datatoc_common_globals_lib_glsl, | datatoc_common_globals_lib_glsl, | ||||
| datatoc_common_view_lib_glsl, | datatoc_common_view_lib_glsl, | ||||
| datatoc_extra_vert_glsl, | datatoc_extra_vert_glsl, | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_frag_glsl, NULL}, | ||||
| .defs = (const char *[]){sh_cfg->def, NULL}, | .defs = (const char *[]){sh_cfg->def, (is_select) ? "#define SELECT_EDGES\n" : NULL, NULL}, | ||||
| }); | }); | ||||
| } | } | ||||
| return sh_data->extra; | return *sh; | ||||
| } | } | ||||
| GPUShader *OVERLAY_shader_extra_grid(void) | GPUShader *OVERLAY_shader_extra_grid(void) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | ||||
| OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | ||||
| if (!sh_data->extra_lightprobe_grid) { | if (!sh_data->extra_lightprobe_grid) { | ||||
| Show All 25 Lines | sh_data->extra_groundline = GPU_shader_create_from_arrays({ | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_frag_glsl, NULL}, | ||||
| .defs = (const char *[]){sh_cfg->def, NULL}, | .defs = (const char *[]){sh_cfg->def, NULL}, | ||||
| }); | }); | ||||
| } | } | ||||
| return sh_data->extra_groundline; | return sh_data->extra_groundline; | ||||
| } | } | ||||
| GPUShader *OVERLAY_shader_extra_wire(bool use_object) | GPUShader *OVERLAY_shader_extra_wire(bool use_object, bool is_select) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | ||||
| OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | ||||
| if (!sh_data->extra_wire[use_object]) { | GPUShader **sh = (is_select) ? &sh_data->extra_wire_select : &sh_data->extra_wire[use_object]; | ||||
| if (!*sh) { | |||||
| char colorids[1024]; | char colorids[1024]; | ||||
| /* NOTE: define all ids we need here. */ | /* NOTE: define all ids we need here. */ | ||||
| BLI_snprintf(colorids, | BLI_snprintf(colorids, | ||||
| sizeof(colorids), | sizeof(colorids), | ||||
| "#define TH_ACTIVE %d\n" | "#define TH_ACTIVE %d\n" | ||||
| "#define TH_SELECT %d\n" | "#define TH_SELECT %d\n" | ||||
| "#define TH_TRANSFORM %d\n" | "#define TH_TRANSFORM %d\n" | ||||
| "#define TH_WIRE %d\n" | "#define TH_WIRE %d\n" | ||||
| "#define TH_CAMERA_PATH %d\n", | "#define TH_CAMERA_PATH %d\n", | ||||
| TH_ACTIVE, | TH_ACTIVE, | ||||
| TH_SELECT, | TH_SELECT, | ||||
| TH_TRANSFORM, | TH_TRANSFORM, | ||||
| TH_WIRE, | TH_WIRE, | ||||
| TH_CAMERA_PATH); | TH_CAMERA_PATH); | ||||
| sh_data->extra_wire[use_object] = GPU_shader_create_from_arrays({ | *sh = GPU_shader_create_from_arrays({ | ||||
| .vert = (const char *[]){sh_cfg->lib, | .vert = (const char *[]){sh_cfg->lib, | ||||
| datatoc_common_globals_lib_glsl, | datatoc_common_globals_lib_glsl, | ||||
| datatoc_common_view_lib_glsl, | datatoc_common_view_lib_glsl, | ||||
| datatoc_extra_wire_vert_glsl, | datatoc_extra_wire_vert_glsl, | ||||
| NULL}, | NULL}, | ||||
| .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_wire_frag_glsl, NULL}, | .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_wire_frag_glsl, NULL}, | ||||
| .defs = (const char *[]){sh_cfg->def, | .defs = (const char *[]){sh_cfg->def, | ||||
| colorids, | colorids, | ||||
| (is_select) ? "#define SELECT_EDGES\n" : "", | |||||
| (use_object) ? "#define OBJECT_WIRE \n" : NULL, | (use_object) ? "#define OBJECT_WIRE \n" : NULL, | ||||
| NULL}, | NULL}, | ||||
| }); | }); | ||||
| } | } | ||||
| return sh_data->extra_wire[use_object]; | return *sh; | ||||
| } | } | ||||
| GPUShader *OVERLAY_shader_extra_loose_point(void) | GPUShader *OVERLAY_shader_extra_loose_point(void) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; | ||||
| OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; | ||||
| if (!sh_data->extra_loose_point) { | if (!sh_data->extra_loose_point) { | ||||
| ▲ Show 20 Lines • Show All 595 Lines • Show Last 20 Lines | |||||