Overlay: Port Edit Mode shaders to ShaderCreateInfo

This should have no regression.
This commit is contained in:
Clément Foucault
2022-03-26 15:58:57 +01:00
parent 4cd409ca98
commit 05a77bb0d8
14 changed files with 243 additions and 218 deletions

View File

@@ -138,6 +138,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
GPUShader *edge_sh = OVERLAY_shader_edit_mesh_edge(!select_vert);
GPUShader *face_sh = OVERLAY_shader_edit_mesh_face();
const bool do_zbufclip = (i == 0 && pd->edit_mesh.do_zbufclip);
const bool do_smooth_wire = (U.gpu_flag & USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE) == 0;
DRWState state_common = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND_ALPHA;
/* Faces */
@@ -173,17 +174,21 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity);
DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex);
DRW_shgroup_uniform_bool_copy(grp, "selectEdges", pd->edit_mesh.do_edges || select_edge);
DRW_shgroup_uniform_bool_copy(grp, "do_smooth_wire", do_smooth_wire);
/* Verts */
state |= DRW_STATE_WRITE_DEPTH;
DRW_PASS_CREATE(psl->edit_mesh_verts_ps[i], state | pd->clipping_state);
if (select_vert) {
int vert_mask[4] = {0xFF, 0xFF, 0xFF, 0xFF};
sh = OVERLAY_shader_edit_mesh_vert();
grp = pd->edit_mesh_verts_grp[i] = DRW_shgroup_create(sh, psl->edit_mesh_verts_ps[i]);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity);
DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex);
DRW_shgroup_uniform_ivec4_copy(grp, "dataMask", vert_mask);
sh = OVERLAY_shader_edit_mesh_skin_root();
grp = pd->edit_mesh_skin_roots_grp[i] = DRW_shgroup_create(sh, psl->edit_mesh_verts_ps[i]);

View File

@@ -299,21 +299,10 @@ GPUShader *OVERLAY_shader_depth_only(void)
GPUShader *OVERLAY_shader_edit_mesh_vert(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->edit_mesh_vert) {
sh_data->edit_mesh_vert = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_common_lib_glsl,
datatoc_edit_mesh_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_common_globals_lib_glsl,
datatoc_gpu_shader_point_varying_color_frag_glsl,
NULL},
.defs = (const char *[]){sh_cfg->def, "#define VERT\n", NULL},
});
sh_data->edit_mesh_vert = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_vert_clipped" : "overlay_edit_mesh_vert");
}
return sh_data->edit_mesh_vert;
}
@@ -321,47 +310,14 @@ GPUShader *OVERLAY_shader_edit_mesh_vert(void)
GPUShader *OVERLAY_shader_edit_mesh_edge(bool use_flat_interp)
{
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];
GPUShader **sh = use_flat_interp ? &sh_data->edit_mesh_edge_flat : &sh_data->edit_mesh_edge;
if (*sh == NULL) {
/* Use geometry shader to draw edge wire-frame. This ensure us
* the same result across platforms and more flexibility.
* But we pay the cost of running a geometry shader.
* In the future we might consider using only the vertex shader
* and loading data manually with buffer textures. */
const bool use_geom_shader = true;
const bool use_smooth_wires = (U.gpu_flag & USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE) == 0;
const char *geom_sh_code[] = {use_geom_shader ? sh_cfg->lib : NULL,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_geom_glsl,
NULL};
const char *vert_sh_code[] = {sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_common_lib_glsl,
datatoc_edit_mesh_vert_glsl,
NULL};
const char *frag_sh_code[] = {sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_common_lib_glsl,
datatoc_edit_mesh_frag_glsl,
NULL};
const char *defs[] = {sh_cfg->def,
use_geom_shader ? "#define USE_GEOM_SHADER\n" : "",
use_smooth_wires ? "#define USE_SMOOTH_WIRE\n" : "",
use_flat_interp ? "#define FLAT\n" : "",
"#define EDGE\n",
NULL};
*sh = GPU_shader_create_from_arrays({
.vert = vert_sh_code,
.frag = frag_sh_code,
.geom = geom_sh_code,
.defs = defs,
});
*sh = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ?
(use_flat_interp ? "overlay_edit_mesh_edge_flat_clipped" :
"overlay_edit_mesh_edge_clipped") :
(use_flat_interp ? "overlay_edit_mesh_edge_flat" : "overlay_edit_mesh_edge"));
}
return *sh;
}
@@ -722,19 +678,10 @@ GPUShader *OVERLAY_shader_edit_lattice_wire(void)
GPUShader *OVERLAY_shader_edit_mesh_face(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->edit_mesh_face) {
sh_data->edit_mesh_face = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_common_lib_glsl,
datatoc_edit_mesh_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define FACE\n", NULL},
});
sh_data->edit_mesh_face = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_face_clipped" : "overlay_edit_mesh_face");
}
return sh_data->edit_mesh_face;
}
@@ -742,19 +689,10 @@ GPUShader *OVERLAY_shader_edit_mesh_face(void)
GPUShader *OVERLAY_shader_edit_mesh_facedot(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->edit_mesh_facedot) {
sh_data->edit_mesh_facedot = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_common_lib_glsl,
datatoc_edit_mesh_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define FACEDOT\n", NULL},
});
sh_data->edit_mesh_facedot = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_facedot_clipped" : "overlay_edit_mesh_facedot");
}
return sh_data->edit_mesh_facedot;
}
@@ -762,18 +700,10 @@ GPUShader *OVERLAY_shader_edit_mesh_facedot(void)
GPUShader *OVERLAY_shader_edit_mesh_normal(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->edit_mesh_normals) {
sh_data->edit_mesh_normals = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_normal_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL},
});
sh_data->edit_mesh_normals = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_normal_clipped" : "overlay_edit_mesh_normal");
}
return sh_data->edit_mesh_normals;
}
@@ -781,17 +711,10 @@ GPUShader *OVERLAY_shader_edit_mesh_normal(void)
GPUShader *OVERLAY_shader_edit_mesh_analysis(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->edit_mesh_analysis) {
sh_data->edit_mesh_analysis = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_analysis_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_edit_mesh_analysis_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, NULL},
});
sh_data->edit_mesh_analysis = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_analysis_clipped" : "overlay_edit_mesh_analysis");
}
return sh_data->edit_mesh_analysis;
}
@@ -799,18 +722,10 @@ GPUShader *OVERLAY_shader_edit_mesh_analysis(void)
GPUShader *OVERLAY_shader_edit_mesh_skin_root(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->edit_mesh_skin_root) {
sh_data->edit_mesh_skin_root = GPU_shader_create_from_arrays({
.vert = (const char *[]){sh_cfg->lib,
datatoc_common_globals_lib_glsl,
datatoc_common_view_lib_glsl,
datatoc_edit_mesh_skin_root_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL},
});
sh_data->edit_mesh_skin_root = GPU_shader_create_from_info_name(
draw_ctx->sh_cfg ? "overlay_edit_mesh_skin_root_clipped" : "overlay_edit_mesh_skin_root");
}
return sh_data->edit_mesh_skin_root;
}

View File

@@ -1,6 +1,3 @@
out vec4 fragColor;
in vec4 weightColor;
void main()
{

View File

@@ -1,10 +1,6 @@
in vec3 pos;
in float weight;
uniform sampler1D weightTex;
out vec4 weightColor;
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
vec3 weight_to_rgb(float t)
{
@@ -29,7 +25,5 @@ void main()
gl_Position = point_world_to_ndc(world_pos);
weightColor = vec4(weight_to_rgb(weight), 1.0);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(world_pos);
#endif
view_clipping_distances(world_pos);
}

View File

@@ -1,7 +1,4 @@
uniform bool selectFaces = true;
uniform bool selectEdges = true;
vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, float bweight)
{
vec4 color = vec4(0.0);

View File

@@ -12,35 +12,33 @@
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
uniform sampler2D depthTex;
uniform float alpha = 1.0;
flat in vec4 finalColorOuter_f;
in vec4 finalColor_f;
noperspective in float edgeCoord_f;
out vec4 FragColor;
bool test_occlusion()
{
return gl_FragCoord.z > texelFetch(depthTex, ivec2(gl_FragCoord.xy), 0).r;
}
float edge_step(float dist)
{
if (do_smooth_wire) {
return smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
}
else {
return step(0.5, dist);
}
}
void main()
{
float dist = abs(edgeCoord_f) - max(sizeEdge - 0.5, 0.0);
float dist = abs(geometry_out.edgeCoord) - max(sizeEdge - 0.5, 0.0);
float dist_outer = dist - max(sizeEdge, 1.0);
#ifdef USE_SMOOTH_WIRE
float mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
float mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer);
#else
float mix_w = step(0.5, dist);
float mix_w_outer = step(0.5, dist_outer);
#endif
float mix_w = edge_step(dist);
float mix_w_outer = edge_step(dist_outer);
/* Line color & alpha. */
FragColor = mix(finalColorOuter_f, finalColor_f, 1.0 - mix_w * finalColorOuter_f.a);
fragColor = mix(geometry_out.finalColorOuter,
geometry_out.finalColor,
1.0 - mix_w * geometry_out.finalColorOuter.a);
/* Line edges shape. */
FragColor.a *= 1.0 - (finalColorOuter_f.a > 0.0 ? mix_w_outer : mix_w);
fragColor.a *= 1.0 - (geometry_out.finalColorOuter.a > 0.0 ? mix_w_outer : mix_w);
FragColor.a *= test_occlusion() ? alpha : 1.0;
fragColor.a *= test_occlusion() ? alpha : 1.0;
}

View File

@@ -1,26 +1,18 @@
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
in vec4 finalColor[2];
in vec4 finalColorOuter[2];
in int selectOverride[2];
flat out vec4 finalColorOuter_f;
out vec4 finalColor_f;
noperspective out float edgeCoord_f;
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
void do_vertex(vec4 color, vec4 pos, float coord, vec2 offset)
{
finalColor_f = color;
edgeCoord_f = coord;
geometry_out.finalColor = color;
geometry_out.edgeCoord = coord;
gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0 * pos.w;
/* Correct but fails due to an AMD compiler bug, see: T62792.
* Do inline instead. */
#if 0
world_clip_planes_set_clip_distance(gl_in[i].gl_ClipDistance);
view_clipping_distances_set(gl_in[i]);
#endif
EmitVertex();
}
@@ -54,33 +46,30 @@ void main()
vec2 line = ss_pos[0] - ss_pos[1];
line = abs(line) * sizeViewport.xy;
finalColorOuter_f = finalColorOuter[0];
geometry_out.finalColorOuter = geometry_in[0].finalColorOuter;
float half_size = sizeEdge;
/* Enlarge edge for flag display. */
half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge, 1.0) : 0.0;
half_size += (geometry_out.finalColorOuter.a > 0.0) ? max(sizeEdge, 1.0) : 0.0;
#ifdef USE_SMOOTH_WIRE
/* Add 1 px for AA */
half_size += 0.5;
#endif
if (do_smooth_wire) {
/* Add 1 px for AA */
half_size += 0.5;
}
vec3 edge_ofs = vec3(half_size * sizeViewportInv.xy, 0.0);
vec3 edge_ofs = vec3(half_size * drw_view.viewport_size_inverse, 0.0);
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;
#ifdef USE_WORLD_CLIP_PLANES
/* Due to an AMD glitch, this line was moved out of the `do_vertex`
* function (see T62792). */
world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance);
#endif
do_vertex(finalColor[0], pos0, half_size, edge_ofs.xy);
do_vertex(finalColor[0], pos0, -half_size, -edge_ofs.xy);
view_clipping_distances_set(gl_in[0]);
do_vertex(geometry_in[0].finalColor, pos0, half_size, edge_ofs.xy);
do_vertex(geometry_in[0].finalColor, pos0, -half_size, -edge_ofs.xy);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
#endif
vec4 final_color = (selectOverride[0] == 0) ? finalColor[1] : finalColor[0];
view_clipping_distances_set(gl_in[1]);
vec4 final_color = (geometry_in[0].selectOverride == 0) ? geometry_in[1].finalColor :
geometry_in[0].finalColor;
do_vertex(final_color, pos1, half_size, edge_ofs.xy);
do_vertex(final_color, pos1, -half_size, -edge_ofs.xy);

View File

@@ -1,16 +1,6 @@
uniform float normalSize;
uniform float normalScreenSize;
uniform bool isConstantScreenSizeNormals;
uniform sampler2D depthTex;
uniform float alpha = 1.0;
in vec3 pos;
in vec4 lnor;
in vec4 vnor;
in vec4 norAndFlag;
flat out vec4 finalColor;
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
bool test_occlusion()
{
@@ -75,7 +65,5 @@ void main()
finalColor.a *= (test_occlusion()) ? alpha : 1.0;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(world_pos);
#endif
view_clipping_distances(world_pos);
}

View File

@@ -1,12 +1,6 @@
/* ---- Instantiated Attrs ---- */
in vec3 pos;
/* ---- Per instance Attrs ---- */
in float size;
in vec3 local_pos;
flat out vec4 finalColor;
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
void main()
{
@@ -19,7 +13,5 @@ void main()
/* Manual stipple: one segment out of 2 is transparent. */
finalColor = ((gl_VertexID & 1) == 0) ? colorSkinRoot : vec4(0.0);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(pos_4d.xyz);
#endif
view_clipping_distances(pos_4d.xyz);
}

View File

@@ -1,26 +1,13 @@
uniform sampler2D depthTex;
uniform float alpha = 1.0;
uniform ivec4 dataMask = ivec4(0xFF);
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(edit_mesh_common_lib.glsl)
in ivec4 data;
in vec3 pos;
#ifndef FACEDOT
in vec3 vnor;
#else
in vec4 norAndFlag;
# define vnor norAndFlag.xyz
#endif
out vec4 finalColor;
#ifdef VERT
out float vertexCrease;
#endif
#ifdef EDGE
out vec4 finalColorOuter;
#endif
#ifdef USE_GEOM_SHADER
out int selectOverride;
/* Ugly but needed to keep the same vertex shader code for other passes. */
# define finalColor geometry_in.finalColor
# define finalColorOuter geometry_in.finalColorOuter
# define selectOverride geometry_in.selectOverride
#endif
bool test_occlusion()
@@ -108,7 +95,5 @@ void main()
finalColor.rgb = non_linear_blend_color(colorEditMeshMiddle.rgb, finalColor.rgb, facing);
#endif
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(world_pos);
#endif
view_clipping_distances(world_pos);
}

View File

@@ -0,0 +1,164 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
/* -------------------------------------------------------------------- */
/** \name Edit Mesh
* \{ */
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_color_iface, "").flat(Type::VEC4, "finalColor");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common)
.define("blender_srgb_to_framebuffer_space(a)", "a")
.sampler(0, ImageType::DEPTH_2D, "depthTex")
.fragment_out(0, Type::VEC4, "fragColor")
.push_constant(Type::BOOL, "selectFaces")
.push_constant(Type::BOOL, "selectEdges")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::IVEC4, "dataMask")
.vertex_source("edit_mesh_vert.glsl")
.additional_info("draw_modelmat", "draw_globals");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface, "")
.smooth(Type::VEC4, "finalColor")
.smooth(Type::FLOAT, "vertexCrease");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert)
.do_static_compilation(true)
.builtins(BuiltinBits::POINT_SIZE)
.define("srgbTarget", "false") /* Colors are already in linear space. */
.define("VERT")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.vertex_out(overlay_edit_mesh_vert_iface)
.fragment_source("gpu_shader_point_varying_color_frag.glsl")
.additional_info("overlay_edit_mesh_common");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_iface, "geometry_in")
.smooth(Type::VEC4, "finalColor")
.smooth(Type::VEC4, "finalColorOuter")
.smooth(Type::INT, "selectOverride");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_geom_iface, "geometry_out")
.smooth(Type::VEC4, "finalColor")
.flat(Type::VEC4, "finalColorOuter")
.no_perspective(Type::FLOAT, "edgeCoord");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge)
.do_static_compilation(true)
.define("EDGE")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.push_constant(Type::BOOL, "do_smooth_wire")
.vertex_out(overlay_edit_mesh_edge_iface)
.geometry_out(overlay_edit_mesh_edge_geom_iface)
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
.geometry_source("edit_mesh_geom.glsl")
.fragment_source("edit_mesh_frag.glsl")
.additional_info("overlay_edit_mesh_common");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat)
.do_static_compilation(true)
.define("FLAT")
.additional_info("overlay_edit_mesh_edge");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face)
.do_static_compilation(true)
.define("srgbTarget", "false") /* Colors are already in linear space. */
.define("FACE")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.vertex_out(overlay_edit_mesh_color_iface)
.fragment_source("gpu_shader_3D_smooth_color_frag.glsl")
.additional_info("overlay_edit_mesh_common");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot)
.do_static_compilation(true)
.define("FACEDOT")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(2, Type::VEC4, "norAndFlag")
.define("vnor", "norAndFlag.xyz")
.vertex_out(overlay_edit_mesh_color_iface)
.fragment_source("gpu_shader_point_varying_color_frag.glsl")
.additional_info("overlay_edit_mesh_common");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal)
.do_static_compilation(true)
.define("srgbTarget", "false") /* Colors are already in linear space. */
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::VEC4, "lnor")
.vertex_in(2, Type::VEC4, "vnor")
.vertex_in(3, Type::VEC4, "norAndFlag")
.sampler(0, ImageType::DEPTH_2D, "depthTex")
.push_constant(Type::FLOAT, "normalSize")
.push_constant(Type::FLOAT, "normalScreenSize")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::BOOL, "isConstantScreenSizeNormals")
.vertex_out(overlay_edit_mesh_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("edit_mesh_normal_vert.glsl")
.fragment_source("gpu_shader_flat_color_frag.glsl")
.additional_info("draw_modelmat_instanced_attr", "draw_globals");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_analysis_iface, "").smooth(Type::VEC4, "weightColor");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_analysis)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::FLOAT, "weight")
.sampler(0, ImageType::FLOAT_1D, "weightTex")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_out(overlay_edit_mesh_analysis_iface)
.vertex_source("edit_mesh_analysis_vert.glsl")
.fragment_source("edit_mesh_analysis_frag.glsl")
.additional_info("draw_modelmat");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root)
.do_static_compilation(true)
.define("srgbTarget", "false") /* Colors are already in linear space. */
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::FLOAT, "size")
.vertex_in(2, Type::VEC3, "local_pos")
.vertex_out(overlay_edit_mesh_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("edit_mesh_skin_root_vert.glsl")
.fragment_source("gpu_shader_flat_color_frag.glsl")
.additional_info("draw_modelmat_instanced_attr", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_vert", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_edge_flat", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_face", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_facedot", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_normal", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_analysis_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_analysis", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root_clipped)
.do_static_compilation(true)
.additional_info("overlay_edit_mesh_skin_root", "drw_clipped");
/** \} */

View File

@@ -229,8 +229,8 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
# define colorFaceFront globalsBlock.colorFaceFront
# define colorUVShadow globalsBlock.colorUVShadow
# define screenVecs globalsBlock.screenVecs
# define sizeViewport globalsBlock.sizeViewport.xy
# define sizeViewportInv globalsBlock.sizeViewport.zw
# define sizeViewport globalsBlock.sizeViewport.xy
# define sizePixel globalsBlock.sizePixel
# define pixelFac globalsBlock.pixelFac
# define sizeObjectCenter globalsBlock.sizeObjectCenter

View File

@@ -414,6 +414,7 @@ list(APPEND INC ${CMAKE_CURRENT_BINARY_DIR})
set(SRC_SHADER_CREATE_INFOS
../draw/engines/gpencil/shaders/infos/gpencil_info.hh
../draw/engines/gpencil/shaders/infos/gpencil_vfx_info.hh
../draw/engines/overlay/shaders/infos/edit_mode_info.hh
../draw/engines/workbench/shaders/infos/workbench_composite_info.hh
../draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh
../draw/engines/workbench/shaders/infos/workbench_effect_cavity_info.hh

View File

@@ -1,10 +1,10 @@
#ifndef USE_GPU_SHADER_CREATE_INFO
in vec4 finalColor;
out vec4 fragColor;
#endif
#if defined(VERT)
# if defined(VERT)
in float vertexCrease;
# endif
#endif
void main()