diff options
Diffstat (limited to 'source/blender/draw')
20 files changed, 362 insertions, 384 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 2c3c9620165..278aefb8fec 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -325,35 +325,16 @@ GPUShader *OVERLAY_shader_edit_mesh_edge(bool use_flat_interp) GPUShader *OVERLAY_shader_armature_sphere(bool use_outline) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; - const char extensions[] = ""; if (use_outline && !sh_data->armature_sphere_outline) { - sh_data->armature_sphere_outline = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_sphere_outline_vert_glsl, - NULL}, - .frag = (const char *[]){extensions, - datatoc_common_view_lib_glsl, - datatoc_armature_wire_frag_glsl, - NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_sphere_outline = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_sphere_outline_clipped" : + "overlay_armature_sphere_outline"); } else if (!sh_data->armature_sphere_solid) { - sh_data->armature_sphere_solid = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_view_lib_glsl, - datatoc_armature_sphere_solid_vert_glsl, - NULL}, - .frag = (const char *[]){extensions, - datatoc_common_view_lib_glsl, - datatoc_armature_sphere_solid_frag_glsl, - NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_sphere_solid = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_sphere_solid_clipped" : + "overlay_armature_sphere_solid"); } return use_outline ? sh_data->armature_sphere_outline : sh_data->armature_sphere_solid; } @@ -361,34 +342,16 @@ GPUShader *OVERLAY_shader_armature_sphere(bool use_outline) GPUShader *OVERLAY_shader_armature_shape(bool use_outline) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (use_outline && !sh_data->armature_shape_outline) { - sh_data->armature_shape_outline = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_shape_outline_vert_glsl, - NULL}, - .geom = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_shape_outline_geom_glsl, - NULL}, - .frag = - (const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_shape_outline = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_shape_outline_clipped" : + "overlay_armature_shape_outline"); } else if (!sh_data->armature_shape_solid) { - sh_data->armature_shape_solid = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_view_lib_glsl, - datatoc_armature_shape_solid_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_armature_shape_solid_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_shape_solid = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_shape_solid_clipped" : + "overlay_armature_shape_solid"); } return use_outline ? sh_data->armature_shape_outline : sh_data->armature_shape_solid; } @@ -396,19 +359,10 @@ GPUShader *OVERLAY_shader_armature_shape(bool use_outline) GPUShader *OVERLAY_shader_armature_shape_wire(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->armature_shape_wire) { - sh_data->armature_shape_wire = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_shape_wire_vert_glsl, - NULL}, - .frag = - (const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_shape_wire = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_shape_wire_clipped" : "overlay_armature_shape_wire"); } return sh_data->armature_shape_wire; } @@ -416,29 +370,16 @@ GPUShader *OVERLAY_shader_armature_shape_wire(void) GPUShader *OVERLAY_shader_armature_envelope(bool use_outline) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (use_outline && !sh_data->armature_envelope_outline) { - sh_data->armature_envelope_outline = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_envelope_outline_vert_glsl, - NULL}, - .frag = - (const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_envelope_outline = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_envelope_outline_clipped" : + "overlay_armature_envelope_outline"); } else if (!sh_data->armature_envelope_solid) { - sh_data->armature_envelope_solid = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_view_lib_glsl, - datatoc_armature_envelope_solid_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_armature_envelope_solid_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_envelope_solid = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_envelope_solid_clipped" : + "overlay_armature_envelope_solid"); } return use_outline ? sh_data->armature_envelope_outline : sh_data->armature_envelope_solid; } @@ -446,18 +387,10 @@ GPUShader *OVERLAY_shader_armature_envelope(bool use_outline) GPUShader *OVERLAY_shader_armature_stick(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->armature_stick) { - sh_data->armature_stick = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_stick_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_armature_stick_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_stick = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_stick_clipped" : "overlay_armature_stick"); } return sh_data->armature_stick; } @@ -465,19 +398,10 @@ GPUShader *OVERLAY_shader_armature_stick(void) GPUShader *OVERLAY_shader_armature_degrees_of_freedom_wire(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->armature_dof_wire) { - sh_data->armature_dof_wire = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_dof_vert_glsl, - NULL}, - .frag = - (const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, "#define EDGE\n", NULL}, - }); + sh_data->armature_dof_wire = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_dof_wire_clipped" : "overlay_armature_dof_wire"); } return sh_data->armature_dof_wire; } @@ -485,20 +409,10 @@ GPUShader *OVERLAY_shader_armature_degrees_of_freedom_wire(void) GPUShader *OVERLAY_shader_armature_degrees_of_freedom_solid(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->armature_dof_solid) { - sh_data->armature_dof_solid = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_dof_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_common_view_lib_glsl, - datatoc_armature_dof_solid_frag_glsl, - NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_dof_solid = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_dof_solid_clipped" : "overlay_armature_dof_solid"); } return sh_data->armature_dof_solid; } @@ -506,19 +420,10 @@ GPUShader *OVERLAY_shader_armature_degrees_of_freedom_solid(void) GPUShader *OVERLAY_shader_armature_wire(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); - const GPUShaderConfigData *sh_cfg = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->armature_wire) { - sh_data->armature_wire = GPU_shader_create_from_arrays({ - .vert = (const char *[]){sh_cfg->lib, - datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_armature_wire_vert_glsl, - NULL}, - .frag = - (const char *[]){datatoc_common_view_lib_glsl, datatoc_armature_wire_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg->def, NULL}, - }); + sh_data->armature_wire = GPU_shader_create_from_info_name( + draw_ctx->sh_cfg ? "overlay_armature_wire_clipped" : "overlay_armature_wire"); } return sh_data->armature_wire; } diff --git a/source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl index aedc9bcda61..d46abbf79ee 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl @@ -1,11 +1,4 @@ -uniform float alpha = 1.0; - -flat in vec4 finalColor; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; - void main() { fragColor = vec4(finalColor.rgb, finalColor.a * alpha); diff --git a/source/blender/draw/engines/overlay/shaders/armature_dof_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_dof_vert.glsl index 18a80fc1fb4..b3c9ce5dfd2 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_dof_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_dof_vert.glsl @@ -1,17 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec2 pos; - -/* ---- Per instance Attrs ---- */ -/* Assumed to be in world coordinate already. */ -in vec4 color; -in mat4 inst_obmat; - -flat out vec4 finalColor; -#ifdef EDGE -flat out vec2 edgeStart; -noperspective out vec2 edgePos; -#endif +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) vec3 sphere_project(float ax, float az) { @@ -37,11 +26,7 @@ void main() gl_Position = point_world_to_ndc(world_pos); finalColor = color; -#ifdef EDGE - edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; -#endif + edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif + view_clipping_distances(world_pos); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_envelope_outline_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_envelope_outline_vert.glsl index 2260b2d3fa6..0a8e279e9b0 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_envelope_outline_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_envelope_outline_vert.glsl @@ -1,19 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec2 pos0; -in vec2 pos1; -in vec2 pos2; - -/* ---- Per instance Attrs ---- */ -/* Assumed to be in world coordinate already. */ -in vec4 headSphere; -in vec4 tailSphere; -in vec4 outlineColorSize; -in vec3 xAxis; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) /* project to screen space */ vec2 proj(vec4 pos) @@ -134,9 +121,7 @@ void main() vec3 wpos2 = get_outline_point( pos2, sph_near, sph_far, mat_near, mat_far, z_ofs_near, z_ofs_far, b); -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(wpos1); -#endif + view_clipping_distances(wpos1); vec4 p0 = point_world_to_ndc(wpos0); vec4 p1 = point_world_to_ndc(wpos1); @@ -152,7 +137,7 @@ void main() vec2 ofs_dir = compute_dir(ss0, ss1, ss2); /* Offset away from the center to avoid overlap with solid shape. */ - gl_Position.xy += ofs_dir * sizeViewportInv.xy * gl_Position.w; + gl_Position.xy += ofs_dir * drw_view.viewport_size_inverse * gl_Position.w; edgeStart = edgePos = proj(gl_Position); diff --git a/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl index 51cfe6250be..a90d2e3e406 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl @@ -1,14 +1,4 @@ -uniform float alpha = 0.6; -uniform bool isDistance; - -flat in vec3 finalStateColor; -flat in vec3 finalBoneColor; -in vec3 normalView; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; - void main() { float n = normalize(normalView).z; diff --git a/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_vert.glsl index 620b3f2527c..2dd86a57dfd 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_envelope_solid_vert.glsl @@ -1,18 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec3 pos; - -/* ---- Per instance Attrs ---- */ -/* Assumed to be in world coordinate already. */ -in vec4 headSphere; -in vec4 tailSphere; -in vec3 xAxis; -in vec3 stateColor; -in vec3 boneColor; - -flat out vec3 finalStateColor; -flat out vec3 finalBoneColor; -out vec3 normalView; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -47,9 +35,8 @@ void main() finalStateColor = stateColor; finalBoneColor = boneColor; + view_clipping_distances(sp); + vec4 pos_4d = vec4(sp, 1.0); gl_Position = ViewProjectionMatrix * pos_4d; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(pos_4d.xyz); -#endif } diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl index a2a478f400b..47c5dada708 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_geom.glsl @@ -1,28 +1,16 @@ -layout(lines_adjacency) in; -layout(line_strip, max_vertices = 2) out; - -in vec4 pPos[]; -in vec3 vPos[]; -in vec2 ssPos[]; -in vec2 ssNor[]; -in vec4 vColSize[]; -in int inverted[]; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) void main(void) { - finalColor = vec4(vColSize[0].rgb, 1.0); + finalColor = vec4(geom_in[0].vColSize.rgb, 1.0); bool is_persp = (ProjectionMatrix[3][3] == 0.0); - vec3 view_vec = (is_persp) ? normalize(vPos[1]) : vec3(0.0, 0.0, -1.0); - vec3 v10 = vPos[0] - vPos[1]; - vec3 v12 = vPos[2] - vPos[1]; - vec3 v13 = vPos[3] - vPos[1]; + vec3 view_vec = (is_persp) ? normalize(geom_in[1].vPos) : vec3(0.0, 0.0, -1.0); + vec3 v10 = geom_in[0].vPos - geom_in[1].vPos; + vec3 v12 = geom_in[2].vPos - geom_in[1].vPos; + vec3 v13 = geom_in[3].vPos - geom_in[1].vPos; vec3 n0 = cross(v12, v10); vec3 n3 = cross(v13, v12); @@ -40,13 +28,13 @@ void main(void) } } - n0 = (inverted[0] == 1) ? -n0 : n0; + n0 = (geom_in[0].inverted == 1) ? -n0 : n0; /* Don't outline if concave edge. */ if (dot(n0, v13) > 0.0001) { return; } - vec2 perp = normalize(ssPos[2] - ssPos[1]); + vec2 perp = normalize(geom_in[2].ssPos - geom_in[1].ssPos); vec2 edge_dir = vec2(-perp.y, perp.x); vec2 hidden_point; @@ -55,37 +43,33 @@ void main(void) * If the chosen point is parallel to the edge in screen space, * choose the other point anyway. * This fixes some issue with cubes in orthographic views. */ - if (vPos[0].z < vPos[3].z) { - hidden_point = (abs(fac0) > 1e-5) ? ssPos[0] : ssPos[3]; + if (geom_in[0].vPos.z < geom_in[3].vPos.z) { + hidden_point = (abs(fac0) > 1e-5) ? geom_in[0].ssPos : geom_in[3].ssPos; } else { - hidden_point = (abs(fac3) > 1e-5) ? ssPos[3] : ssPos[0]; + hidden_point = (abs(fac3) > 1e-5) ? geom_in[3].ssPos : geom_in[0].ssPos; } - vec2 hidden_dir = normalize(hidden_point - ssPos[1]); + vec2 hidden_dir = normalize(hidden_point - geom_in[1].ssPos); float fac = dot(-hidden_dir, edge_dir); edge_dir *= (fac < 0.0) ? -1.0 : 1.0; - gl_Position = pPos[1]; + gl_Position = geom_in[1].pPos; /* Offset away from the center to avoid overlap with solid shape. */ - gl_Position.xy += (edge_dir - perp) * sizeViewportInv.xy * gl_Position.w; + gl_Position.xy += (edge_dir - perp) * drw_view.viewport_size_inverse * gl_Position.w; /* Improve AA bleeding inside bone silhouette. */ gl_Position.z -= (is_persp) ? 1e-4 : 1e-6; - edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance); -#endif + edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport; + view_clipping_distances_set(gl_in[1]); EmitVertex(); - gl_Position = pPos[2]; + gl_Position = geom_in[2].pPos; /* Offset away from the center to avoid overlap with solid shape. */ - gl_Position.xy += (edge_dir + perp) * sizeViewportInv.xy * gl_Position.w; + gl_Position.xy += (edge_dir + perp) * drw_view.viewport_size_inverse * gl_Position.w; /* Improve AA bleeding inside bone silhouette. */ gl_Position.z -= (is_persp) ? 1e-4 : 1e-6; edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_set_clip_distance(gl_in[2].gl_ClipDistance); -#endif + view_clipping_distances_set(gl_in[2]); EmitVertex(); EndPrimitive(); diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_vert.glsl index ddc6328e6a2..29319b3f7ac 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_shape_outline_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_shape_outline_vert.glsl @@ -1,18 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec3 pos; -in vec3 snor; - -/* ---- Per instance Attrs ---- */ -in vec4 color; -in mat4 inst_obmat; - -out vec4 pPos; -out vec3 vPos; -out vec2 ssPos; -out vec2 ssNor; -out vec4 vColSize; -out int inverted; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) /* project to screen space */ vec2 proj(vec4 pos) @@ -25,13 +13,13 @@ void main() vec4 bone_color, state_color; mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color); - vec4 worldPosition = model_mat * vec4(pos, 1.0); - vec4 viewpos = ViewMatrix * worldPosition; + vec4 world_pos = model_mat * vec4(pos, 1.0); + vec4 view_pos = ViewMatrix * world_pos; - vPos = viewpos.xyz; - pPos = ProjectionMatrix * viewpos; + geom_in.vPos = view_pos.xyz; + geom_in.pPos = ProjectionMatrix * view_pos; - inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0); + geom_in.inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0); /* This is slow and run per vertex, but it's still faster than * doing it per instance on CPU and sending it on via instance attribute. */ @@ -39,13 +27,11 @@ void main() /* TODO: FIX: there is still a problem with this vector * when the bone is scaled or in persp mode. But it's * barely visible at the outline corners. */ - ssNor = normalize(normal_world_to_view(normal_mat * snor).xy); + geom_in.ssNor = normalize(normal_world_to_view(normal_mat * snor).xy); - ssPos = proj(pPos); + geom_in.ssPos = proj(geom_in.pPos); - vColSize = bone_color; + geom_in.vColSize = bone_color; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(worldPosition.xyz); -#endif + view_clipping_distances(world_pos.xyz); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl index 26796c82f66..8e1768846dc 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl @@ -1,12 +1,4 @@ -uniform float alpha = 0.6; - -in vec4 finalColor; -flat in int inverted; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; - void main() { /* Manual back-face culling. Not ideal for performance diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_solid_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_solid_vert.glsl index 5979a877681..cdbe8c3d7df 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_shape_solid_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_shape_solid_vert.glsl @@ -1,13 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec3 pos; -in vec3 nor; - -/* ---- Per instance Attrs ---- */ -in mat4 inst_obmat; - -out vec4 finalColor; -flat out int inverted; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -31,10 +24,8 @@ void main() finalColor.rgb = mix(state_color.rgb, bone_color.rgb, fac * fac); finalColor.a = 1.0; - vec4 worldPosition = model_mat * vec4(pos, 1.0); - gl_Position = ViewProjectionMatrix * worldPosition; + vec4 world_pos = model_mat * vec4(pos, 1.0); + gl_Position = ViewProjectionMatrix * world_pos; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(worldPosition.xyz); -#endif + view_clipping_distances(world_pos.xyz); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_shape_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_shape_wire_vert.glsl index 0bf21cbaaac..cee86956c43 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_shape_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_shape_wire_vert.glsl @@ -1,14 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec3 pos; -in vec3 nor; - -/* ---- Per instance Attrs ---- */ -in mat4 inst_obmat; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -23,7 +15,5 @@ void main() edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif + view_clipping_distances(world_pos); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_sphere_outline_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_sphere_outline_vert.glsl index 934485359b3..31369e0c3df 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_sphere_outline_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_sphere_outline_vert.glsl @@ -1,13 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec2 pos; - -/* ---- Per instance Attrs ---- */ -in mat4 inst_obmat; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) /* project to screen space */ vec2 proj(vec4 pos) @@ -70,14 +63,12 @@ void main() /* Offset away from the center to avoid overlap with solid shape. */ vec2 ofs_dir = normalize(proj(gl_Position) - proj(center)); - gl_Position.xy += ofs_dir * sizeViewportInv.xy * gl_Position.w; + gl_Position.xy += ofs_dir * drw_view.viewport_size_inverse * gl_Position.w; edgeStart = edgePos = proj(gl_Position); finalColor = vec4(bone_color.rgb, 1.0); -#ifdef USE_WORLD_CLIP_PLANES - vec4 worldPosition = model_mat * vec4(cam_pos0, 1.0); - world_clip_planes_calc_clip_distance(worldPosition.xyz); -#endif + vec4 world_pos = model_mat * vec4(cam_pos0, 1.0); + view_clipping_distances(world_pos.xyz); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl index 0925901a9c9..e60b6e94492 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl @@ -1,18 +1,5 @@ -uniform float alpha = 0.4; - -flat in vec3 finalStateColor; -flat in vec3 finalBoneColor; -flat in mat4 sphereMatrix; -in vec3 viewPosition; - -#ifdef GL_ARB_conservative_depth -/* Saves a lot of overdraw! */ -layout(depth_greater) out float gl_FragDepth; -#endif - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { diff --git a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_vert.glsl index e6fa29ce851..abbaad8cd10 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_sphere_solid_vert.glsl @@ -1,15 +1,6 @@ -/* ---- Instantiated Attrs ---- */ -in vec2 pos; - -/* ---- Per instance Attrs ---- */ -in vec4 color; -in mat4 inst_obmat; - -flat out vec3 finalStateColor; -flat out vec3 finalBoneColor; -flat out mat4 sphereMatrix; -out vec3 viewPosition; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) /* Sphere radius */ const float rad = 0.05; @@ -80,8 +71,6 @@ void main() finalStateColor = state_color.xyz; finalBoneColor = bone_color.xyz; -#ifdef USE_WORLD_CLIP_PLANES - vec4 worldPosition = model_mat * pos_4d; - world_clip_planes_calc_clip_distance(worldPosition.xyz); -#endif + vec4 world_pos = model_mat * pos_4d; + view_clipping_distances(world_pos.xyz); } diff --git a/source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl index 85136672180..2e42cdf0517 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl @@ -1,13 +1,4 @@ -uniform float alpha = 1.0; - -noperspective in float colorFac; -flat in vec4 finalWireColor; -flat in vec4 finalInnerColor; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; - void main() { float fac = smoothstep(1.0, 0.2, colorFac); diff --git a/source/blender/draw/engines/overlay/shaders/armature_stick_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_stick_vert.glsl index 0a2598fb6b7..b5edcd2858b 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_stick_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_stick_vert.glsl @@ -1,8 +1,8 @@ -/* ---- Instantiated Attrs ---- */ -in vec2 pos; /* bone aligned screen space */ -in uint flag; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) +/* TODO(@fclem): Share definition with C code. */ #define COL_WIRE 1u /* (1 << 0) */ #define COL_HEAD 2u /* (1 << 1) */ #define COL_TAIL 4u /* (1 << 2) */ @@ -12,22 +12,9 @@ in uint flag; #define POS_TAIL 32u /* (1 << 5) */ /* UNUSED */ #define POS_BONE 64u /* (1 << 6) */ -/* ---- Per instance Attrs ---- */ -in vec3 boneStart; -in vec3 boneEnd; -in vec4 wireColor; /* alpha encode if we do wire. If 0.0 we don't. */ -in vec4 boneColor; /* alpha encode if we do bone. If 0.0 we don't. */ -in vec4 headColor; /* alpha encode if we do head. If 0.0 we don't. */ -in vec4 tailColor; /* alpha encode if we do tail. If 0.0 we don't. */ - -#define do_wire (wireColor.a > 0.0) #define is_head bool(flag & POS_HEAD) #define is_bone bool(flag & POS_BONE) -noperspective out float colorFac; -flat out vec4 finalWireColor; -flat out vec4 finalInnerColor; - /* project to screen space */ vec2 proj(vec4 pos) { @@ -77,12 +64,9 @@ void main() if (finalInnerColor.a > 0.0) { float stick_size = sizePixel * 5.0; gl_Position = (is_head) ? p0 : p1; - gl_Position.xy += stick_size * (vpos * sizeViewportInv.xy); + gl_Position.xy += stick_size * (vpos * drw_view.viewport_size_inverse); gl_Position.z += (is_bone) ? 0.0 : 1e-6; /* Avoid Z fighting of head/tails. */ - -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance((is_head ? boneStart_4d : boneEnd_4d).xyz); -#endif + view_clipping_distances((is_head ? boneStart_4d : boneEnd_4d).xyz); } else { gl_Position = vec4(0.0); diff --git a/source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl b/source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl index 55278515f74..2c454a8becd 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl @@ -1,12 +1,5 @@ -uniform float alpha = 1.0; - -flat in vec4 finalColor; -flat in vec2 edgeStart; -noperspective in vec2 edgePos; - -layout(location = 0) out vec4 fragColor; -layout(location = 1) out vec4 lineOutput; +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { diff --git a/source/blender/draw/engines/overlay/shaders/armature_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/armature_wire_vert.glsl index d6d6cb6e024..c89d0249e4f 100644 --- a/source/blender/draw/engines/overlay/shaders/armature_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/armature_wire_vert.glsl @@ -1,22 +1,16 @@ -in vec3 color; -in vec3 pos; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { - finalColor.rgb = color; + finalColor.rgb = color.rgb; finalColor.a = 1.0; - vec3 worldPosition = point_object_to_world(pos); - gl_Position = point_world_to_ndc(worldPosition); + vec3 world_pos = point_object_to_world(pos); + gl_Position = point_world_to_ndc(world_pos); edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(worldPosition); -#endif + view_clipping_distances(world_pos); } diff --git a/source/blender/draw/engines/overlay/shaders/infos/armature_info.hh b/source/blender/draw/engines/overlay/shaders/infos/armature_info.hh new file mode 100644 index 00000000000..f417fbe1fd4 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/infos/armature_info.hh @@ -0,0 +1,262 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(overlay_frag_output) + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_out(1, Type::VEC4, "lineOutput"); + +GPU_SHADER_INTERFACE_INFO(overlay_armature_wire_iface, "") + .flat(Type::VEC4, "finalColor") + .flat(Type::VEC2, "edgeStart") + .no_perspective(Type::VEC2, "edgePos"); + +GPU_SHADER_CREATE_INFO(overlay_armature_common) + .push_constant(Type::FLOAT, "alpha") + .additional_info("draw_view"); + +/* -------------------------------------------------------------------- */ +/** \name Armature Sphere + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline) + .do_static_compilation(true) + .vertex_in(0, Type::VEC2, "pos") + /* Per instance. */ + .vertex_in(1, Type::MAT4, "inst_obmat") + .vertex_out(overlay_armature_wire_iface) + .vertex_source("armature_sphere_outline_vert.glsl") + .fragment_source("armature_wire_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_sphere_outline", "drw_clipped"); + +GPU_SHADER_INTERFACE_INFO(overlay_armature_sphere_solid_iface, "") + .flat(Type::VEC3, "finalStateColor") + .flat(Type::VEC3, "finalBoneColor") + .flat(Type::MAT4, "sphereMatrix") + .smooth(Type::VEC3, "viewPosition"); + +GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid) + .do_static_compilation(true) + .vertex_in(0, Type::VEC2, "pos") + /* Per instance. */ + .vertex_in(1, Type::MAT4, "inst_obmat") + .vertex_in(2, Type::VEC4, "color") + // .depth_layout(DepthLayout::GREATER) /* TODO */ + .vertex_out(overlay_armature_sphere_solid_iface) + .vertex_source("armature_sphere_solid_vert.glsl") + .fragment_source("armature_sphere_solid_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_sphere_solid", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Armature Shapes + * \{ */ + +GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_iface, "geom_in") + .smooth(Type::VEC4, "pPos") + .smooth(Type::VEC3, "vPos") + .smooth(Type::VEC2, "ssPos") + .smooth(Type::VEC2, "ssNor") + .smooth(Type::VEC4, "vColSize") + .flat(Type::INT, "inverted"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC3, "snor") + /* Per instance. */ + .vertex_in(2, Type::VEC4, "color") + .vertex_in(3, Type::MAT4, "inst_obmat") + .vertex_out(overlay_armature_shape_outline_iface) + .geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2) + .geometry_out(overlay_armature_wire_iface) + .vertex_source("armature_shape_outline_vert.glsl") + .geometry_source("armature_shape_outline_geom.glsl") + .fragment_source("armature_wire_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_shape_outline", "drw_clipped"); + +GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_solid_iface, "") + .smooth(Type::VEC4, "finalColor") + .flat(Type::INT, "inverted"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_solid) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC3, "nor") + /* Per instance. */ + .vertex_in(2, Type::MAT4, "inst_obmat") + .depth_write(DepthWrite::GREATER) + .vertex_out(overlay_armature_shape_solid_iface) + .vertex_source("armature_shape_solid_vert.glsl") + .fragment_source("armature_shape_solid_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_solid_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_shape_solid", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC3, "nor") + /* Per instance. */ + .vertex_in(2, Type::MAT4, "inst_obmat") + .vertex_out(overlay_armature_wire_iface) + .vertex_source("armature_shape_wire_vert.glsl") + .fragment_source("armature_wire_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_shape_wire", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Armature Envelope + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_armature_envelope_outline) + .do_static_compilation(true) + .vertex_in(0, Type::VEC2, "pos0") + .vertex_in(1, Type::VEC2, "pos1") + .vertex_in(2, Type::VEC2, "pos2") + /* Per instance. */ + .vertex_in(3, Type::VEC4, "headSphere") + .vertex_in(4, Type::VEC4, "tailSphere") + .vertex_in(5, Type::VEC4, "outlineColorSize") + .vertex_in(6, Type::VEC3, "xAxis") + .vertex_out(overlay_armature_wire_iface) + .vertex_source("armature_envelope_outline_vert.glsl") + .fragment_source("armature_wire_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_envelope_outline_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_envelope_outline", "drw_clipped"); + +GPU_SHADER_INTERFACE_INFO(overlay_armature_envelope_solid_iface, "") + .flat(Type::VEC3, "finalStateColor") + .flat(Type::VEC3, "finalBoneColor") + .smooth(Type::VEC3, "normalView"); + +GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + /* Per instance. Assumed to be in world coordinate already. */ + .vertex_in(1, Type::VEC4, "headSphere") + .vertex_in(2, Type::VEC4, "tailSphere") + .vertex_in(3, Type::VEC3, "xAxis") + .vertex_in(4, Type::VEC3, "stateColor") + .vertex_in(5, Type::VEC3, "boneColor") + .vertex_out(overlay_armature_envelope_solid_iface) + .push_constant(Type::BOOL, "isDistance") + .vertex_source("armature_envelope_solid_vert.glsl") + .fragment_source("armature_envelope_solid_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common"); + +GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_envelope_solid", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Armature Stick + * \{ */ + +GPU_SHADER_INTERFACE_INFO(overlay_armature_stick_iface, "") + .no_perspective(Type::FLOAT, "colorFac") + .flat(Type::VEC4, "finalWireColor") + .flat(Type::VEC4, "finalInnerColor"); + +GPU_SHADER_CREATE_INFO(overlay_armature_stick) + .do_static_compilation(true) + /* Bone aligned screen space. */ + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::UINT, "flag") + /* Per instance. Assumed to be in world coordinate already. */ + .vertex_in(2, Type::VEC3, "boneStart") + .vertex_in(3, Type::VEC3, "boneEnd") + /* alpha encode if we do wire. If 0.0 we don't. */ + .vertex_in(4, Type::VEC4, "wireColor") + .vertex_in(5, Type::VEC4, "boneColor") + .vertex_in(6, Type::VEC4, "headColor") + .vertex_in(7, Type::VEC4, "tailColor") + .define("do_wire", "(wireColor.a > 0.0)") + .vertex_out(overlay_armature_stick_iface) + .vertex_source("armature_stick_vert.glsl") + .fragment_source("armature_stick_frag.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_stick_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_stick", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Armature Degrees of Freedom + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_armature_dof) + .vertex_in(0, Type::VEC2, "pos") + /* Per instance. Assumed to be in world coordinate already. */ + .vertex_in(1, Type::VEC4, "color") + .vertex_in(2, Type::MAT4, "inst_obmat") + .vertex_out(overlay_armature_wire_iface) + .vertex_source("armature_dof_vert.glsl") + .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_dof_wire) + .do_static_compilation(true) + .fragment_source("armature_dof_solid_frag.glsl") + .additional_info("overlay_armature_dof"); + +GPU_SHADER_CREATE_INFO(overlay_armature_dof_wire_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_dof_wire", "drw_clipped"); + +GPU_SHADER_CREATE_INFO(overlay_armature_dof_solid) + .do_static_compilation(true) + .fragment_source("armature_dof_solid_frag.glsl") + .additional_info("overlay_armature_dof"); + +GPU_SHADER_CREATE_INFO(overlay_armature_dof_solid_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_dof_solid", "drw_clipped"); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Armature Wire + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_armature_wire) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "color") + .push_constant(Type::FLOAT, "alpha") + .vertex_out(overlay_armature_wire_iface) + .vertex_source("armature_wire_vert.glsl") + .fragment_source("armature_wire_frag.glsl") + .additional_info("overlay_frag_output", "draw_mesh", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_armature_wire_clipped) + .do_static_compilation(true) + .additional_info("overlay_armature_wire", "drw_clipped"); + +/** \} */ diff --git a/source/blender/draw/intern/draw_common_shader_shared.h b/source/blender/draw/intern/draw_common_shader_shared.h index fa1fc9516b0..46382ed7f16 100644 --- a/source/blender/draw/intern/draw_common_shader_shared.h +++ b/source/blender/draw/intern/draw_common_shader_shared.h @@ -229,7 +229,6 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16) # define colorFaceFront globalsBlock.colorFaceFront # define colorUVShadow globalsBlock.colorUVShadow # define screenVecs globalsBlock.screenVecs -# define sizeViewportInv globalsBlock.sizeViewport.zw # define sizeViewport globalsBlock.sizeViewport.xy # define sizePixel globalsBlock.sizePixel # define pixelFac globalsBlock.pixelFac |