Overlay: Remove macros for globals uniform buffer access

Pull Request: https://projects.blender.org/blender/blender/pulls/138068
This commit is contained in:
Clément Foucault
2025-04-26 11:28:24 +02:00
committed by Gitea
parent cac80a9e3c
commit 7714998537
67 changed files with 272 additions and 353 deletions

View File

@@ -400,7 +400,8 @@ void Resources::update_theme_settings(const DRWContext *ctx, const State &state)
}
gb.pixel_fac = (state.rv3d) ? state.rv3d->pixsize : 1.0f;
gb.size_viewport = float4(ctx->viewport_size_get(), 1.0f / ctx->viewport_size_get());
gb.size_viewport = ctx->viewport_size_get();
gb.size_viewport_inv = 1.0f / gb.size_viewport;
if (state.v3d) {
const View3DShading &shading = state.v3d->shading;

View File

@@ -281,7 +281,8 @@ BLI_STATIC_ASSERT_ALIGN(ThemeColors, 16)
/* All values in this struct are premultiplied by U.pixelsize. */
struct ThemeSizes {
float pixel;
float pixel; /* Equivalent to U.pixelsize. */
float object_center;
float light_center;
@@ -304,7 +305,8 @@ struct UniformData {
/** Other global states. */
float4 size_viewport; /* Packed as float4. */
float2 size_viewport;
float2 size_viewport_inv;
float fresnel_mix_edit;
float pixel_fac;
@@ -314,117 +316,9 @@ struct UniformData {
BLI_STATIC_ASSERT_ALIGN(UniformData, 16)
#ifdef GPU_SHADER
/* The uniform_buf mostly contains theme properties.
* This alias has better semantic and shorter syntax. */
# define theme uniform_buf
/* Keep compatibility_with old global scope syntax. */
/* TODO(@fclem) Mass rename and remove the camel case. */
# define colorWire theme.colors.wire
# define colorWireEdit theme.colors.wire_edit
# define colorActive theme.colors.active
# define colorSelect theme.colors.select
# define colorLibrarySelect theme.colors.library_select
# define colorLibrary theme.colors.library
# define colorTransform theme.colors.transform
# define colorLight theme.colors.light
# define colorSpeaker theme.colors.speaker
# define colorCamera theme.colors.camera
# define colorCameraPath theme.colors.camera_path
# define colorEmpty theme.colors.empty
# define colorVertex theme.colors.vert
# define colorVertexSelect theme.colors.vert_select
# define colorVertexUnreferenced theme.colors.vert_unreferenced
# define colorVertexMissingData theme.colors.vert_missing_data
# define colorEditMeshActive theme.colors.edit_mesh_active
# define colorEdgeSelect theme.colors.edge_select
# define colorEdgeModeSelect theme.colors.edge_mode_select
# define colorEdgeSeam theme.colors.edge_seam
# define colorEdgeSharp theme.colors.edge_sharp
# define colorEdgeCrease theme.colors.edge_crease
# define colorEdgeBWeight theme.colors.edge_bweight
# define colorEdgeFaceSelect theme.colors.edge_face_select
# define colorEdgeFreestyle theme.colors.edge_freestyle
# define colorFace theme.colors.face
# define colorFaceSelect theme.colors.face_select
# define colorFaceModeSelect theme.colors.face_mode_select
# define colorFaceRetopology theme.colors.face_retopology
# define colorFaceFreestyle theme.colors.face_freestyle
# define colorGpencilVertex theme.colors.gpencil_vertex
# define colorGpencilVertexSelect theme.colors.gpencil_vertex_select
# define colorNormal theme.colors.normal
# define colorVNormal theme.colors.vnormal
# define colorLNormal theme.colors.lnormal
# define colorFaceDot theme.colors.facedot
# define colorSkinRoot theme.colors.skinroot
# define colorDeselect theme.colors.deselect
# define colorOutline theme.colors.outline
# define colorLightNoAlpha theme.colors.light_no_alpha
# define colorBackground theme.colors.background
# define colorBackgroundGradient theme.colors.background_gradient
# define colorCheckerPrimary theme.colors.checker_primary
# define colorCheckerSecondary theme.colors.checker_secondary
# define colorClippingBorder theme.colors.clipping_border
# define colorEditMeshMiddle theme.colors.edit_mesh_middle
# define colorHandleFree theme.colors.handle_free
# define colorHandleAuto theme.colors.handle_auto
# define colorHandleVect theme.colors.handle_vect
# define colorHandleAlign theme.colors.handle_align
# define colorHandleAutoclamp theme.colors.handle_autoclamp
# define colorHandleSelFree theme.colors.handle_sel_free
# define colorHandleSelAuto theme.colors.handle_sel_auto
# define colorHandleSelVect theme.colors.handle_sel_vect
# define colorHandleSelAlign theme.colors.handle_sel_align
# define colorHandleSelAutoclamp theme.colors.handle_sel_autoclamp
# define colorNurbUline theme.colors.nurb_uline
# define colorNurbVline theme.colors.nurb_vline
# define colorNurbSelUline theme.colors.nurb_sel_uline
# define colorNurbSelVline theme.colors.nurb_sel_vline
# define colorActiveSpline theme.colors.active_spline
# define colorBonePose theme.colors.bone_pose
# define colorBonePoseActive theme.colors.bone_pose_active
# define colorBonePoseActiveUnsel theme.colors.bone_pose_active_unsel
# define colorBonePoseConstraint theme.colors.bone_pose_constraint
# define colorBonePoseIK theme.colors.bone_pose_ik
# define colorBonePoseSplineIK theme.colors.bone_pose_spline_ik
# define colorBonePoseTarget theme.colors.bone_pose_no_target
# define colorBoneSolid theme.colors.bone_solid
# define colorBoneLocked theme.colors.bone_locked
# define colorBoneActive theme.colors.bone_active
# define colorBoneActiveUnsel theme.colors.bone_active_unsel
# define colorBoneSelect theme.colors.bone_select
# define colorBoneIKLine theme.colors.bone_ik_line
# define colorBoneIKLineNoTarget theme.colors.bone_ik_line_no_target
# define colorBoneIKLineSpline theme.colors.bone_ik_line_spline
# define colorText theme.colors.text
# define colorTextHi theme.colors.text_hi
# define colorBundleSolid theme.colors.bundle_solid
# define colorMballRadius theme.colors.mball_radius
# define colorMballRadiusSelect theme.colors.mball_radius_select
# define colorMballStiffness theme.colors.mball_stiffness
# define colorMballStiffnessSelect theme.colors.mball_stiffness_select
# define colorCurrentFrame theme.colors.current_frame
# define colorBeforeFrame theme.colors.before_frame
# define colorAfterFrame theme.colors.after_frame
# define colorGrid theme.colors.grid
# define colorGridEmphasis theme.colors.grid_emphasis
# define colorGridAxisX theme.colors.grid_axis_x
# define colorGridAxisY theme.colors.grid_axis_y
# define colorGridAxisZ theme.colors.grid_axis_z
# define colorFaceBack theme.colors.face_back
# define colorFaceFront theme.colors.face_front
# define colorUVShadow theme.colors.uv_shadow
# define sizeViewport float2(uniform_buf.size_viewport.xy)
# define sizeViewportInv float2(uniform_buf.size_viewport.zw)
# define sizePixel theme.sizes.pixel
# define pixelFac uniform_buf.pixel_fac
# define sizeObjectCenter theme.sizes.object_center
# define sizeLightCenter theme.sizes.light_center
# define sizeLightCircle theme.sizes.light_circle
# define sizeLightCircleShadow theme.sizes.light_circle_shadow
# define sizeVertex theme.sizes.vert
# define sizeEdge theme.sizes.edge
# define sizeFaceDot theme.sizes.face_dot
# define sizeChecker theme.sizes.checker
# define sizeVertexGpencil theme.sizes.vertex_gpencil
# define fresnelMixEdit theme.fresnel_mix_edit
#endif
struct ExtraInstanceData {

View File

@@ -80,7 +80,7 @@ void neighbor_blend(float line_coverage,
void main()
{
int2 center_texel = int2(gl_FragCoord.xy);
float line_kernel = sizePixel * 0.5f - 0.5f;
float line_kernel = theme.sizes.pixel * 0.5f - 0.5f;
frag_color = texelFetch(color_tx, center_texel, 0);

View File

@@ -34,7 +34,8 @@ void main()
gl_Position = drw_point_world_to_homogenous(world_pos);
final_color = data_buf[gl_InstanceID].color_;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
view_clipping_distances(world_pos);
}

View File

@@ -13,7 +13,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_armature_envelope_outline)
/* project to screen space */
float2 proj(float4 pos)
{
return (0.5f * (pos.xy / pos.w) + 0.5f) * sizeViewport;
return (0.5f * (pos.xy / pos.w) + 0.5f) * uniform_buf.size_viewport;
}
float2 compute_dir(float2 v0, float2 v1, float2 v2)
@@ -148,7 +148,7 @@ void main()
float2 ofs_dir = compute_dir(ss0, ss1, ss2);
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += ofs_dir * sizeViewportInv * gl_Position.w;
gl_Position.xy += ofs_dir * uniform_buf.size_viewport_inv * gl_Position.w;
edge_start = edge_pos = proj(gl_Position);

View File

@@ -48,7 +48,7 @@ VertOut vertex_main(VertIn v_in)
v_out.ws_P = transform_point(model_mat, v_in.ls_P);
v_out.vs_P = drw_point_world_to_view(v_out.ws_P);
v_out.hs_P = drw_point_view_to_homogenous(v_out.vs_P);
v_out.ss_P = drw_perspective_divide(v_out.hs_P).xy * sizeViewport;
v_out.ss_P = drw_perspective_divide(v_out.hs_P).xy * uniform_buf.size_viewport;
v_out.inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0f);
v_out.color_size = bone_color;
@@ -77,11 +77,12 @@ void emit_vertex(const uint strip_index,
gl_Position = hs_P;
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += offset * sizeViewportInv * gl_Position.w;
gl_Position.xy += offset * uniform_buf.size_viewport_inv * gl_Position.w;
/* Improve AA bleeding inside bone silhouette. */
gl_Position.z -= (is_persp) ? 1e-4f : 1e-6f;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
view_clipping_distances(ws_P);
}

View File

@@ -131,9 +131,9 @@ void geometry_main(VertOut geom_in[2],
screen_space_pos[0] = pos0.xy / pos0.w;
screen_space_pos[1] = pos1.xy / pos1.w;
/* `sizeEdge` is defined as the distance from the center to the outer edge. As such to get the
total width it needs to be doubled. */
wire_width = geom_in[0].wire_width * (sizeEdge * 2);
/* `theme.sizes.edge` is defined as the distance from the center to the outer edge. As such to
get the total width it needs to be doubled. */
wire_width = geom_in[0].wire_width * (theme.sizes.edge * 2);
float half_size = max(wire_width / 2.0f, 0.5f);
if (do_smooth_wire) {
@@ -141,9 +141,9 @@ void geometry_main(VertOut geom_in[2],
half_size += 0.5f;
}
float2 line = (screen_space_pos[0] - screen_space_pos[1]) * sizeViewport;
float2 line = (screen_space_pos[0] - screen_space_pos[1]) * uniform_buf.size_viewport;
float2 line_norm = normalize(float2(line[1], -line[0]));
float2 edge_ofs = (half_size * line_norm) * sizeViewportInv;
float2 edge_ofs = (half_size * line_norm) * uniform_buf.size_viewport_inv;
float4 final_color = geom_in[0].final_color;
do_vertex(0,

View File

@@ -14,7 +14,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_armature_sphere_outline)
/* project to screen space */
float2 proj(float4 pos)
{
return (0.5f * (pos.xy / pos.w) + 0.5f) * sizeViewport;
return (0.5f * (pos.xy / pos.w) + 0.5f) * uniform_buf.size_viewport;
}
void main()
@@ -74,7 +74,7 @@ void main()
/* Offset away from the center to avoid overlap with solid shape. */
float2 ofs_dir = normalize(proj(gl_Position) - proj(center));
gl_Position.xy += ofs_dir * sizeViewportInv * gl_Position.w;
gl_Position.xy += ofs_dir * uniform_buf.size_viewport_inv * gl_Position.w;
edge_start = edge_pos = proj(gl_Position);

View File

@@ -15,7 +15,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_armature_stick)
/* project to screen space */
float2 proj(float4 hs_P)
{
return (0.5f * (hs_P.xy / hs_P.w) + 0.5f) * sizeViewport;
return (0.5f * (hs_P.xy / hs_P.w) + 0.5f) * uniform_buf.size_viewport;
}
void main()
@@ -69,9 +69,9 @@ void main()
vpos *= (data_buf[gl_InstanceID].wire_color.a > 0.0f) ? 1.0f : 0.5f;
if (final_inner_color.a > 0.0f) {
float stick_size = sizePixel * 5.0f;
float stick_size = theme.sizes.pixel * 5.0f;
gl_Position = (is_head) ? p0 : p1;
gl_Position.xy += stick_size * (vpos * sizeViewportInv);
gl_Position.xy += stick_size * (vpos * uniform_buf.size_viewport_inv);
gl_Position.z += (is_bone) ? 0.0f : 1e-6f; /* Avoid Z fighting of head/tails. */
view_clipping_distances((is_head ? boneStart_4d : boneEnd_4d).xyz);
}

View File

@@ -21,7 +21,8 @@ void main()
float3 world_pos = data_buf[gl_VertexID].pos_.xyz;
gl_Position = drw_point_world_to_homogenous(world_pos);
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
view_clipping_distances(world_pos);
}

View File

@@ -46,12 +46,12 @@ void main()
switch (type) {
case BG_SOLID:
bg_col = colorBackground.rgb;
bg_col = theme.colors.background.rgb;
break;
case BG_GRADIENT:
/* XXX do interpolation in a non-linear space to have a better visual result. */
col_high = pow(colorBackground.rgb, float3(1.0f / 2.2f));
col_low = pow(colorBackgroundGradient.rgb, float3(1.0f / 2.2f));
col_high = pow(theme.colors.background.rgb, float3(1.0f / 2.2f));
col_low = pow(theme.colors.background_gradient.rgb, float3(1.0f / 2.2f));
bg_col = mix(col_low, col_high, screen_uv.y);
/* Convert back to linear. */
bg_col = pow(bg_col, float3(2.2f));
@@ -60,8 +60,8 @@ void main()
break;
case BG_RADIAL: {
/* Do interpolation in a non-linear space to have a better visual result. */
col_high = pow(colorBackground.rgb, float3(1.0f / 2.2f));
col_low = pow(colorBackgroundGradient.rgb, float3(1.0f / 2.2f));
col_high = pow(theme.colors.background.rgb, float3(1.0f / 2.2f));
col_low = pow(theme.colors.background_gradient.rgb, float3(1.0f / 2.2f));
float2 uv_n = screen_uv - 0.5f;
bg_col = mix(col_high, col_low, length(uv_n) * M_SQRT2);
@@ -73,10 +73,10 @@ void main()
break;
}
case BG_CHECKER: {
float size = sizeChecker * sizePixel;
float size = theme.sizes.checker * theme.sizes.pixel;
int2 p = int2(floor(gl_FragCoord.xy / size));
bool check = mod(p.x, 2) == mod(p.y, 2);
bg_col = (check) ? colorCheckerPrimary.rgb : colorCheckerSecondary.rgb;
bg_col = (check) ? theme.colors.checker_primary.rgb : theme.colors.checker_secondary.rgb;
break;
}
case BG_MASK:

View File

@@ -25,7 +25,7 @@ float4x4 extract_matrix_packed_data(float4x4 mat, out float4 dataA, out float4 d
return mat;
}
/* edge_start and edge_pos needs to be in the range [0..sizeViewport]. */
/* edge_start and edge_pos needs to be in the range [0..uniform_buf.size_viewport]. */
float4 pack_line_data(float2 frag_co, float2 edge_start, float2 edge_pos)
{
float2 edge = edge_start - edge_pos;

View File

@@ -40,7 +40,7 @@ void main()
if (!gp_stroke_order3d) {
/* Stroke order 2D. Project to gp_depth_plane. */
bool is_persp = drw_view().winmat[3][3] == 0.0f;
float2 uvs = float2(gl_FragCoord.xy) * sizeViewportInv;
float2 uvs = float2(gl_FragCoord.xy) * uniform_buf.size_viewport_inv;
float3 pos_ndc = float3(uvs, gl_FragCoord.z) * 2.0f - 1.0f;
float4 pos_world = drw_view().viewinv * (drw_view().wininv * float4(pos_ndc, 1.0f));
float3 pos = pos_world.xyz / pos_world.w;

View File

@@ -20,7 +20,7 @@ void main()
float unused_strength;
float2 unused_uv;
gl_Position = gpencil_vertex(float4(sizeViewport, sizeViewportInv),
gl_Position = gpencil_vertex(float4(uniform_buf.size_viewport, uniform_buf.size_viewport_inv),
world_pos,
unused_N,
unused_color,

View File

@@ -58,13 +58,13 @@ void do_vertex(const uint i,
if (all(is_subpixel)) {
float2 ofs = (i == 0) ? float2(-1.0f) : ((i == 1) ? float2(2.0f, -1.0f) : float2(-1.0f, 2.0f));
/* HACK: Fix cases where the triangle is too small make it cover at least one pixel. */
gl_Position.xy += sizeViewportInv * geom_in.hs_P.w * ofs;
gl_Position.xy += uniform_buf.size_viewport_inv * geom_in.hs_P.w * ofs;
}
/* Test if the triangle is almost parallel with the view to avoid precision issues. */
else if (any(is_subpixel) || is_coplanar) {
/* HACK: Fix cases where the triangle is Parallel to the view by deforming it slightly. */
float2 ofs = (i == 0) ? float2(-1.0f) : ((i == 1) ? float2(1.0f, -1.0f) : float2(1.0f));
gl_Position.xy += sizeViewportInv * geom_in.hs_P.w * ofs;
gl_Position.xy += uniform_buf.size_viewport_inv * geom_in.hs_P.w * ofs;
}
else {
/* Triangle expansion should happen here, but we decide to not implement it for
@@ -85,7 +85,7 @@ void geometry_main(VertOut geom_in[3],
/* Compute NDC bound box. */
float4 bbox = float4(min(min(pos0.xy, pos1.xy), pos2.xy), max(max(pos0.xy, pos1.xy), pos2.xy));
/* Convert to pixel space. */
bbox = (bbox * 0.5f + 0.5f) * sizeViewport.xyxy;
bbox = (bbox * 0.5f + 0.5f) * uniform_buf.size_viewport.xyxy;
/* Detect failure cases where triangles would produce no fragments. */
bool2 is_subpixel = lessThan(bbox.zw - bbox.xy, float2(1.0f));
/* View aligned triangle. */

View File

@@ -27,7 +27,7 @@ void main()
* covers at least a whole pixel. */
int i = gl_VertexID % 3;
float2 ofs = (i == 0) ? float2(-1.0f) : ((i == 1) ? float2(2.0f, -1.0f) : float2(-1.0f, 2.0f));
gl_Position.xy += sizeViewportInv * gl_Position.w * ofs;
gl_Position.xy += uniform_buf.size_viewport_inv * gl_Position.w * ofs;
#endif
view_clipping_distances(world_pos);

View File

@@ -132,46 +132,47 @@ void geometry_main(VertOut geom_in[2],
float4 inner_color;
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
inner_color = (edge_selected) ? theme.colors.handle_sel_free : theme.colors.handle_free;
}
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
inner_color = (edge_selected) ? theme.colors.handle_sel_auto : theme.colors.handle_auto;
}
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
inner_color = (edge_selected) ? theme.colors.handle_sel_vect : theme.colors.handle_vect;
}
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
inner_color = (edge_selected) ? theme.colors.handle_sel_align : theme.colors.handle_align;
}
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
inner_color = (edge_selected) ? theme.colors.handle_sel_autoclamp :
theme.colors.handle_autoclamp;
}
else {
bool is_selected = (((geom_in[1].flag & geom_in[0].flag) & VERT_SELECTED) != 0u);
bool is_u_segment = (((geom_in[1].flag ^ geom_in[0].flag) & EVEN_U_BIT) != 0u);
if (is_u_segment) {
inner_color = (is_selected) ? colorNurbSelUline : colorNurbUline;
inner_color = (is_selected) ? theme.colors.nurb_sel_uline : theme.colors.nurb_uline;
}
else {
inner_color = (is_selected) ? colorNurbSelVline : colorNurbVline;
inner_color = (is_selected) ? theme.colors.nurb_sel_vline : theme.colors.nurb_vline;
}
}
/* Minimize active color bleeding on inner_color. */
float4 active_color = mix(colorActiveSpline, inner_color, 0.25f);
float4 active_color = mix(theme.colors.active_spline, inner_color, 0.25f);
float4 outer_color = (is_active_nurb != 0u) ? active_color : float4(inner_color.rgb, 0.0f);
float2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
float2 offset = sizeEdge * 4.0f * sizeViewportInv; /* 4.0f is eyeballed */
float2 offset = theme.sizes.edge * 4.0f * uniform_buf.size_viewport_inv; /* 4.0f is eyeballed */
if (abs(v1_2.x * sizeViewport.x) < abs(v1_2.y * sizeViewport.y)) {
if (abs(v1_2.x * uniform_buf.size_viewport.x) < abs(v1_2.y * uniform_buf.size_viewport.y)) {
offset.y = 0.0f;
}
else {
offset.x = 0.0f;
}
float4 border_color = float4(colorActiveSpline.rgb, 0.0f);
float4 border_color = float4(theme.colors.active_spline.rgb, 0.0f);
/* Draw the transparent border (AA). */
if (is_active_nurb != 0u) {
offset *= 0.75f; /* Don't make the active "halo" appear very thick. */

View File

@@ -44,7 +44,7 @@ void main()
float3 world_pos = drw_point_object_to_world(ls_P);
gl_Position = drw_point_world_to_homogenous(world_pos);
final_color = colorWireEdit;
final_color = theme.colors.wire_edit;
view_clipping_distances(world_pos);
}

View File

@@ -16,19 +16,19 @@ void main()
bool is_gpencil = ((data & EDGE_FREESTYLE) != 0u);
if ((data & VERT_SELECTED) != 0u) {
if ((data & VERT_ACTIVE) != 0u) {
final_color = colorEditMeshActive;
final_color = theme.colors.edit_mesh_active;
}
else {
final_color = (!is_gpencil) ? colorVertexSelect : colorGpencilVertexSelect;
final_color = (!is_gpencil) ? theme.colors.vert_select : theme.colors.gpencil_vertex_select;
}
}
else {
final_color = (!is_gpencil) ? colorVertex : colorGpencilVertex;
final_color = (!is_gpencil) ? theme.colors.vert : theme.colors.gpencil_vertex;
}
float3 world_pos = drw_point_object_to_world(pos);
gl_Position = drw_point_world_to_homogenous(world_pos);
gl_PointSize = (!is_gpencil) ? sizeVertex * 2.0f : sizeVertexGpencil * 2.0f;
gl_PointSize = (!is_gpencil) ? theme.sizes.vert * 2.0f : theme.sizes.vertex_gpencil * 2.0f;
view_clipping_distances(world_pos);
bool show_handle = show_curve_handles;

View File

@@ -23,7 +23,7 @@ void main()
float3 world_pos = drw_point_object_to_world(final_pos);
gl_Position = drw_point_world_to_homogenous(world_pos);
final_color = colorWireEdit;
final_color = theme.colors.wire_edit;
view_clipping_distances(world_pos);
}

View File

@@ -162,11 +162,11 @@ void geometry_main(VertOut geom_in[2],
}
/* Minimize active color bleeding on inner_color. */
float4 active_color = mix(colorActiveSpline, inner_color, 0.25f);
float4 active_color = mix(theme.colors.active_spline, inner_color, 0.25f);
float4 outer_color = is_active ? active_color : float4(inner_color.rgb, 0.0f);
float2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
float2 offset = sizeEdge * 4.0f * sizeViewportInv; /* 4.0f is eyeballed */
float2 offset = theme.sizes.edge * 4.0f * uniform_buf.size_viewport_inv; /* 4.0f is eyeballed */
if (abs(v1_2.x) <= M_TAN_PI_BY_8 * abs(v1_2.y)) {
offset.y = 0.0f;
@@ -178,7 +178,7 @@ void geometry_main(VertOut geom_in[2],
offset.x = 0.0f;
}
float4 border_color = float4(colorActiveSpline.rgb, 0.0f);
float4 border_color = float4(theme.colors.active_spline.rgb, 0.0f);
/* Draw the transparent border (AA). */
if (is_active) {
offset *= 0.75f; /* Don't make the active "halo" appear very thick. */

View File

@@ -31,5 +31,6 @@ void main()
final_color = color;
/* Convert to screen position [0..sizeVp]. */
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
}

View File

@@ -13,13 +13,13 @@ VERTEX_SHADER_CREATE_INFO(overlay_edit_lattice_point)
void main()
{
if ((data & VERT_SELECTED) != 0u) {
final_color = colorVertexSelect;
final_color = theme.colors.vert_select;
}
else if ((data & VERT_ACTIVE) != 0u) {
final_color = colorEditMeshActive;
final_color = theme.colors.edit_mesh_active;
}
else {
final_color = colorVertex;
final_color = theme.colors.vert;
}
float3 world_pos = drw_point_object_to_world(pos);
@@ -28,7 +28,7 @@ void main()
/* Small offset in Z */
gl_Position.z -= 3e-4f;
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
view_clipping_distances(world_pos);
}

View File

@@ -16,7 +16,7 @@ float3 weight_to_rgb(float t)
{
if (t == no_active_weight) {
/* No weight. */
return colorWire.rgb;
return theme.colors.wire.rgb;
}
if (t > 1.0f || t < 0.0f) {
/* Error color */

View File

@@ -11,20 +11,21 @@ SHADER_LIBRARY_CREATE_INFO(overlay_edit_mesh_common)
float4 EDIT_MESH_edge_color_outer(uint edge_flag, uint face_flag, float crease, float bweight)
{
float4 color = float4(0.0f);
color = ((edge_flag & EDGE_FREESTYLE) != 0u) ? colorEdgeFreestyle : color;
color = ((edge_flag & EDGE_SHARP) != 0u) ? colorEdgeSharp : color;
color = (crease > 0.0f) ? float4(colorEdgeCrease.rgb, crease) : color;
color = (bweight > 0.0f) ? float4(colorEdgeBWeight.rgb, bweight) : color;
color = ((edge_flag & EDGE_SEAM) != 0u) ? colorEdgeSeam : color;
color = ((edge_flag & EDGE_FREESTYLE) != 0u) ? theme.colors.edge_freestyle : color;
color = ((edge_flag & EDGE_SHARP) != 0u) ? theme.colors.edge_sharp : color;
color = (crease > 0.0f) ? float4(theme.colors.edge_crease.rgb, crease) : color;
color = (bweight > 0.0f) ? float4(theme.colors.edge_bweight.rgb, bweight) : color;
color = ((edge_flag & EDGE_SEAM) != 0u) ? theme.colors.edge_seam : color;
return color;
}
float4 EDIT_MESH_edge_color_inner(uint edge_flag)
{
float4 color = colorWireEdit;
float4 selected_edge_col = (select_edge) ? colorEdgeModeSelect : colorEdgeSelect;
float4 color = theme.colors.wire_edit;
float4 selected_edge_col = (select_edge) ? theme.colors.edge_mode_select :
theme.colors.edge_select;
color = ((edge_flag & EDGE_SELECTED) != 0u) ? selected_edge_col : color;
color = ((edge_flag & EDGE_ACTIVE) != 0u) ? colorEditMeshActive : color;
color = ((edge_flag & EDGE_ACTIVE) != 0u) ? theme.colors.edit_mesh_active : color;
color.a = 1.0f;
return color;
}
@@ -32,9 +33,10 @@ float4 EDIT_MESH_edge_color_inner(uint edge_flag)
float4 EDIT_MESH_edge_vertex_color(uint vertex_flag)
{
/* Edge color in vertex selection mode. */
float4 selected_edge_col = (select_edge) ? colorEdgeModeSelect : colorEdgeSelect;
float4 selected_edge_col = (select_edge) ? theme.colors.edge_mode_select :
theme.colors.edge_select;
bool edge_selected = (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0u;
float4 color = (edge_selected) ? selected_edge_col : colorWireEdit;
float4 color = (edge_selected) ? selected_edge_col : theme.colors.wire_edit;
color.a = 1.0f;
return color;
}
@@ -42,17 +44,17 @@ float4 EDIT_MESH_edge_vertex_color(uint vertex_flag)
float4 EDIT_MESH_vertex_color(uint vertex_flag, float vertex_crease)
{
if ((vertex_flag & VERT_ACTIVE) != 0u) {
return float4(colorEditMeshActive.xyz, 1.0f);
return float4(theme.colors.edit_mesh_active.xyz, 1.0f);
}
else if ((vertex_flag & VERT_SELECTED) != 0u) {
return colorVertexSelect;
return theme.colors.vert_select;
}
else {
/* Full crease color if not selected nor active. */
if (vertex_crease > 0.0f) {
return mix(colorVertex, colorEdgeCrease, vertex_crease);
return mix(theme.colors.vert, theme.colors.edge_crease, vertex_crease);
}
return colorVertex;
return theme.colors.vert;
}
}
@@ -62,13 +64,14 @@ float4 EDIT_MESH_face_color(uint face_flag)
bool face_selected = (face_flag & FACE_SELECTED) != 0u;
bool face_active = (face_flag & FACE_ACTIVE) != 0u;
bool face_retopo = (retopology_offset > 0.0f);
float4 selected_face_col = (select_face) ? colorFaceModeSelect : colorFaceSelect;
float4 color = colorFace;
color = face_retopo ? colorFaceRetopology : color;
color = face_freestyle ? colorFaceFreestyle : color;
float4 selected_face_col = (select_face) ? theme.colors.face_mode_select :
theme.colors.face_select;
float4 color = theme.colors.face;
color = face_retopo ? theme.colors.face_retopology : color;
color = face_freestyle ? theme.colors.face_freestyle : color;
color = face_selected ? selected_face_col : color;
if (select_face && face_active) {
color = mix(selected_face_col, colorEditMeshActive, 0.5f);
color = mix(selected_face_col, theme.colors.edit_mesh_active, 0.5f);
color.a = selected_face_col.a;
}
if (wire_shading) {
@@ -76,7 +79,7 @@ float4 EDIT_MESH_face_color(uint face_flag)
color.a = (face_selected) ? color.a * 0.6f : color.a;
}
else {
/* Don't always fill 'colorFace'. */
/* Don't always fill 'theme.colors.face'. */
color.a = (select_face || face_selected || face_active || face_freestyle || face_retopo) ?
color.a :
0.0f;
@@ -87,12 +90,12 @@ float4 EDIT_MESH_face_color(uint face_flag)
float4 EDIT_MESH_facedot_color(float facedot_flag)
{
if (facedot_flag < 0.0f) {
return float4(colorEditMeshActive.xyz, 1.0f);
return float4(theme.colors.edit_mesh_active.xyz, 1.0f);
}
else if (facedot_flag > 0.0f) {
return colorFaceDot;
return theme.colors.facedot;
}
else {
return colorVertex;
return theme.colors.vert;
}
}

View File

@@ -114,19 +114,19 @@ void geometry_main(VertOut geom_in[2], uint out_vert_id, uint out_prim_id, uint
ss_pos[1] = pos1.xy / pos1.w;
float2 line = ss_pos[0] - ss_pos[1];
line = abs(line) * sizeViewport;
line = abs(line) * uniform_buf.size_viewport;
geometry_flat_out.final_color_outer = geom_in[0].final_color_outer;
float half_size = sizeEdge;
float half_size = theme.sizes.edge;
/* Enlarge edge for flag display. */
half_size += (geometry_flat_out.final_color_outer.a > 0.0f) ? max(sizeEdge, 1.0f) : 0.0f;
half_size += (geometry_flat_out.final_color_outer.a > 0.0f) ? max(theme.sizes.edge, 1.0f) : 0.0f;
if (do_smooth_wire) {
/* Add 1px for AA */
half_size += 0.5f;
}
float3 edge_ofs = float3(half_size * sizeViewportInv, 0.0f);
float3 edge_ofs = float3(half_size * uniform_buf.size_viewport_inv, 0.0f);
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;

View File

@@ -23,8 +23,8 @@ float edge_step(float dist)
void main()
{
float dist = abs(geometry_noperspective_out.edge_coord) - max(sizeEdge - 0.5f, 0.0f);
float dist_outer = dist - max(sizeEdge, 1.0f);
float dist = abs(geometry_noperspective_out.edge_coord) - max(theme.sizes.edge - 0.5f, 0.0f);
float dist_outer = dist - max(theme.sizes.edge, 1.0f);
float mix_w = edge_step(dist);
float mix_w_outer = edge_step(dist_outer);
/* Line color & alpha. */

View File

@@ -65,7 +65,7 @@ VertOut vertex_main(VertIn vert_in)
#if defined(VERT)
vertex_crease = float(m_data.z >> 4) / 15.0f;
vert_out.final_color = EDIT_MESH_vertex_color(m_data.y, vertex_crease);
gl_PointSize = sizeVertex * ((vertex_crease > 0.0f) ? 3.0f : 2.0f);
gl_PointSize = theme.sizes.vert * ((vertex_crease > 0.0f) ? 3.0f : 2.0f);
/* Make selected and active vertex always on top. */
if ((data.x & VERT_SELECTED) != 0u) {
vert_out.gpu_position.z -= 5e-7f * abs(vert_out.gpu_position.w);
@@ -114,7 +114,7 @@ VertOut vertex_main(VertIn vert_in)
bool occluded = test_occlusion(vert_out.gpu_position);
gl_PointSize = sizeFaceDot;
gl_PointSize = theme.sizes.face_dot;
# ifdef GLSL_CPP_STUBS
/* Fixes warning in C++ compilation about unused variable. */
@@ -135,8 +135,8 @@ VertOut vertex_main(VertIn vert_in)
/* Do interpolation in a non-linear space to have a better visual result. */
vert_out.final_color.rgb = mix(
vert_out.final_color.rgb,
non_linear_blend_color(colorEditMeshMiddle.rgb, vert_out.final_color.rgb, facing),
fresnelMixEdit);
non_linear_blend_color(theme.colors.edit_mesh_middle.rgb, vert_out.final_color.rgb, facing),
theme.fresnel_mix_edit);
#endif
vert_out.gpu_position.z -= ndc_offset_factor * ndc_offset;

View File

@@ -63,7 +63,7 @@ void main()
}
# endif
final_color = colorNormal;
final_color = theme.colors.normal;
#elif defined(VERT_NORMAL)
# if defined(FLOAT_NORMAL)
@@ -72,7 +72,7 @@ void main()
# else
nor = gpu_attr_load_uint_1010102_snorm(vnor, gpu_attr_0, vert_i).xyz;
# endif
final_color = colorVNormal;
final_color = theme.colors.vnormal;
#elif defined(LOOP_NORMAL)
# if defined(FLOAT_NORMAL)
@@ -86,7 +86,7 @@ void main()
nor = gpu_attr_load_uint_1010102_snorm(lnor, gpu_attr_0, vert_i).xyz;
}
# endif
final_color = colorLNormal;
final_color = theme.colors.lnormal;
#else
@@ -96,21 +96,21 @@ void main()
return;
}
nor = lnor.xyz;
final_color = colorLNormal;
final_color = theme.colors.lnormal;
}
else if (!all(equal(vnor.xyz, float3(0)))) {
if (vnor.w < 0.0f) {
return;
}
nor = vnor.xyz;
final_color = colorVNormal;
final_color = theme.colors.vnormal;
}
else {
nor = norAndFlag.xyz;
if (all(equal(nor, float3(0)))) {
return;
}
final_color = colorNormal;
final_color = theme.colors.normal;
}
float3 ls_pos = pos;
#endif
@@ -125,10 +125,10 @@ void main()
float dist_fac = length(drw_view_position() - world_pos);
float cos_fac = dot(drw_view_forward(), drw_world_incident_vector(world_pos));
world_pos += n * normal_screen_size * dist_fac * cos_fac * uniform_buf.pixel_fac *
sizePixel;
theme.sizes.pixel;
}
else {
float frustrum_fac = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, n) * sizePixel;
float frustrum_fac = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, n) * theme.sizes.pixel;
world_pos += n * normal_screen_size * frustrum_fac;
}
}

View File

@@ -29,13 +29,13 @@ void main()
float theta = M_TAU * (float(vert_id) / 63.0f);
float3 circle_P = float3(cos(theta), 0.0f, sin(theta));
final_color = colorSkinRoot;
final_color = theme.colors.skinroot;
#else
float3 lP = local_pos;
float circle_size = size;
float3 circle_P = pos;
/* Manual stipple: one segment out of 2 is transparent. */
final_color = ((gl_VertexID & 1) == 0) ? colorSkinRoot : float4(0.0f);
final_color = ((gl_VertexID & 1) == 0) ? theme.colors.skinroot : float4(0.0f);
#endif
float3 screen_pos = (right * circle_P.x + up * circle_P.z) * circle_size;
float4 pos_4d = drw_modelmat() * float4(lP + screen_pos, 1.0f);

View File

@@ -52,7 +52,7 @@ void main()
#if defined(VERT)
vertex_crease = float(m_data.z >> 4) / 15.0f;
final_color = EDIT_MESH_vertex_color(m_data.y, vertex_crease);
gl_PointSize = sizeVertex * ((vertex_crease > 0.0f) ? 3.0f : 2.0f);
gl_PointSize = theme.sizes.vert * ((vertex_crease > 0.0f) ? 3.0f : 2.0f);
/* Make selected and active vertex always on top. */
if ((data.x & VERT_SELECTED) != 0u) {
gl_Position.z -= 5e-7f * abs(gl_Position.w);
@@ -96,7 +96,7 @@ void main()
/* Bias Face-dot Z position in clip-space. */
gl_Position.z -= (drw_view().winmat[3][3] == 0.0f) ? 0.00035f : 1e-6f;
gl_PointSize = sizeFaceDot;
gl_PointSize = theme.sizes.face_dot;
bool occluded = test_occlusion();
@@ -113,9 +113,10 @@ void main()
facing = 1.0f - abs(facing) * 0.2f;
/* Do interpolation in a non-linear space to have a better visual result. */
final_color.rgb = mix(final_color.rgb,
non_linear_blend_color(colorEditMeshMiddle.rgb, final_color.rgb, facing),
fresnelMixEdit);
final_color.rgb = mix(
final_color.rgb,
non_linear_blend_color(theme.colors.edit_mesh_middle.rgb, final_color.rgb, facing),
theme.fresnel_mix_edit);
#endif
gl_Position.z -= ndc_offset_factor * ndc_offset;

View File

@@ -20,7 +20,7 @@ float3 weight_to_rgb(float t)
{
if (t == no_active_weight) {
/* No weight. */
return colorWire.rgb;
return theme.colors.wire.rgb;
}
if (t > 1.0f || t < 0.0f) {
/* Error color */
@@ -52,8 +52,10 @@ void main()
final_color = float4(weight_to_rgb(selection), 1.0f);
}
else {
float4 color_selected = use_grease_pencil ? colorGpencilVertexSelect : colorVertexSelect;
float4 color_not_selected = use_grease_pencil ? colorGpencilVertex : colorVertex;
float4 color_selected = use_grease_pencil ? theme.colors.gpencil_vertex_select :
theme.colors.vert_select;
float4 color_not_selected = use_grease_pencil ? theme.colors.gpencil_vertex :
theme.colors.vert;
final_color = mix(color_not_selected, color_selected, selection);
#if 1 /* Should be checking CURVES_POINT */
@@ -73,7 +75,7 @@ void main()
#endif
}
float vsize = use_grease_pencil ? sizeVertexGpencil : sizeVertex;
float vsize = use_grease_pencil ? theme.sizes.vertex_gpencil : theme.sizes.vert;
gl_PointSize = vsize * 2.0f * end_point_size_factor;
view_clipping_distances(world_pos);

View File

@@ -16,7 +16,7 @@ float3 weight_to_rgb(float t)
{
if (t == no_active_weight) {
/* No weight. */
return colorWire.rgb;
return theme.colors.wire.rgb;
}
if (t > 1.0f || t < 0.0f) {
/* Error color */
@@ -36,8 +36,9 @@ void main()
final_color = float4(weight_to_rgb(selection), 1.0f);
}
else {
float4 use_color = use_grease_pencil ? colorGpencilVertexSelect : colorVertexSelect;
final_color = mix(colorWireEdit, use_color, selection);
float4 use_color = use_grease_pencil ? theme.colors.gpencil_vertex_select :
theme.colors.vert_select;
final_color = mix(theme.colors.wire_edit, use_color, selection);
}
view_clipping_distances(world_pos);

View File

@@ -12,7 +12,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_edit_pointcloud)
void main()
{
final_color = colorVertexSelect;
final_color = theme.colors.vert_select;
float radius = pos_rad.w;
float3 world_pos = drw_point_object_to_world(pos_rad.xyz);
@@ -26,6 +26,6 @@ void main()
/* Small offset in Z for depth precision. */
gl_Position.z -= 3e-4f;
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
view_clipping_distances(world_pos);
}

View File

@@ -23,32 +23,33 @@ void main()
/* TODO(@ideasman42): The current wire-edit color contrast enough against the selection.
* Look into changing the default theme color instead of reducing contrast with edge-select.
*/
inner_color = (selection_fac != 0.0f) ? colorEdgeSelect : (colorWireEdit * 0.5f);
inner_color = (selection_fac != 0.0f) ? theme.colors.edge_select :
(theme.colors.wire_edit * 0.5f);
}
else {
inner_color = mix(colorWireEdit, colorEdgeSelect, selection_fac);
inner_color = mix(theme.colors.wire_edit, theme.colors.edge_select, selection_fac);
}
outer_color = float4(float3(0.0f), 1.0f);
}
else if (OVERLAY_UVLineStyle(line_style) == OVERLAY_UV_LINE_STYLE_DASH) {
if (fract(line_distance / dash_length) < 0.5f) {
inner_color = mix(float4(float3(0.35f), 1.0f), colorEdgeSelect, selection_fac);
inner_color = mix(float4(float3(0.35f), 1.0f), theme.colors.edge_select, selection_fac);
}
}
else if (OVERLAY_UVLineStyle(line_style) == OVERLAY_UV_LINE_STYLE_BLACK) {
float4 base_color = float4(float3(0.0f), 1.0f);
inner_color = mix(base_color, colorEdgeSelect, selection_fac);
inner_color = mix(base_color, theme.colors.edge_select, selection_fac);
}
else if (OVERLAY_UVLineStyle(line_style) == OVERLAY_UV_LINE_STYLE_WHITE) {
float4 base_color = float4(1.0f);
inner_color = mix(base_color, colorEdgeSelect, selection_fac);
inner_color = mix(base_color, theme.colors.edge_select, selection_fac);
}
else if (OVERLAY_UVLineStyle(line_style) == OVERLAY_UV_LINE_STYLE_SHADOW) {
inner_color = colorUVShadow;
inner_color = theme.colors.uv_shadow;
}
float dist = abs(edge_coord) - max(sizeEdge - 0.5f, 0.0f);
float dist_outer = dist - max(sizeEdge, 1.0f);
float dist = abs(edge_coord) - max(theme.sizes.edge - 0.5f, 0.0f);
float dist_outer = dist - max(theme.sizes.edge, 1.0f);
float mix_w;
float mix_w_outer;

View File

@@ -46,8 +46,8 @@ VertOut vertex_main(VertIn v_in)
float3 world_pos = float3(v_in.uv, 0.0f);
vert_out.hs_P = drw_point_world_to_homogenous(world_pos);
/* Snap vertices to the pixel grid to reduce artifacts. */
float2 half_viewport_res = sizeViewport * 0.5f;
float2 half_pixel_offset = sizeViewportInv * 0.5f;
float2 half_viewport_res = uniform_buf.size_viewport * 0.5f;
float2 half_pixel_offset = uniform_buf.size_viewport_inv * 0.5f;
vert_out.hs_P.xy = floor(vert_out.hs_P.xy * half_viewport_res) / half_viewport_res +
half_pixel_offset;
@@ -108,11 +108,11 @@ void geometry_main(VertOut geom_in[2],
float2 ss_pos0 = drw_perspective_divide(geom_in[0].hs_P).xy;
float2 ss_pos1 = drw_perspective_divide(geom_in[1].hs_P).xy;
float half_size = sizeEdge;
float half_size = theme.sizes.edge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (OVERLAY_UVLineStyle(line_style) == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (do_smooth_wire ? 1.0f : 3.0f), 1.0f) :
max(theme.sizes.edge * (do_smooth_wire ? 1.0f : 3.0f), 1.0f) :
0.0f;
/* Add 1 PX for AA. */
if (do_smooth_wire) {
@@ -121,7 +121,7 @@ void geometry_main(VertOut geom_in[2],
float2 line_dir = normalize(ss_pos0 - ss_pos1);
float2 line_perp = float2(-line_dir.y, line_dir.x);
float2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
float2 edge_ofs = line_perp * uniform_buf.size_viewport_inv * ceil(half_size);
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
edge_ofs *= 2.0f;

View File

@@ -14,6 +14,7 @@ void main()
float3 world_pos = float3(au, 0.0f);
gl_Position = drw_point_world_to_homogenous(world_pos);
final_color = ((flag & FACE_UV_SELECT) != 0u) ? colorFaceDot : float4(colorWire.rgb, 1.0f);
final_color = ((flag & FACE_UV_SELECT) != 0u) ? theme.colors.facedot :
float4(theme.colors.wire.rgb, 1.0f);
gl_PointSize = dot_size;
}

View File

@@ -21,7 +21,7 @@ void main()
eObjectInfoFlag ob_flag = drw_object_infos().flag;
bool is_object_active = flag_test(ob_flag, OBJECT_ACTIVE);
final_color = (is_selected) ? colorFaceSelect : colorFace;
final_color = (is_active) ? colorEditMeshActive : final_color;
final_color = (is_selected) ? theme.colors.face_select : theme.colors.face;
final_color = (is_active) ? theme.colors.edit_mesh_active : final_color;
final_color.a *= is_object_active ? uv_opacity : (uv_opacity * 0.25f);
}

View File

@@ -17,7 +17,7 @@ void main()
bool is_selected = (flag & (VERT_UV_SELECT | FACE_UV_SELECT)) != 0u;
bool is_pinned = (flag & VERT_UV_PINNED) != 0u;
float4 deselect_col = (is_pinned) ? pinned_col : float4(color.rgb, 1.0f);
fill_color = (is_selected) ? colorVertexSelect : deselect_col;
fill_color = (is_selected) ? theme.colors.vert_select : deselect_col;
outline_color = (is_pinned) ? pinned_col : float4(fill_color.rgb, 0.0f);
float3 world_pos = float3(au, 0.0f);

View File

@@ -14,20 +14,21 @@ VERTEX_SHADER_CREATE_INFO(overlay_extra_groundline)
void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
final_color = colorLight;
final_color = theme.colors.light;
/* Relative to DPI scaling. Have constant screen size. */
float3 screen_pos = drw_view().viewinv[0].xyz * pos.x + drw_view().viewinv[1].xyz * pos.y;
float3 inst_pos = data_buf[gl_InstanceID].xyz;
float3 p = inst_pos;
p.z *= (pos.z == 0.0f) ? 0.0f : 1.0f;
float screen_size = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, p) * sizePixel;
float screen_size = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, p) * theme.sizes.pixel;
float3 world_pos = p + screen_pos * screen_size;
gl_Position = drw_point_world_to_homogenous(world_pos);
/* Convert to screen position [0..sizeVp]. */
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
view_clipping_distances(world_pos);
}

View File

@@ -15,16 +15,16 @@ VERTEX_SHADER_CREATE_INFO(draw_modelmat)
float4 color_from_id(float color_id)
{
if (is_transform) {
return colorTransform;
return theme.colors.transform;
}
else if (color_id == 1.0f) {
return colorActive;
return theme.colors.active;
}
else /* 2.0f */ {
return colorSelect;
return theme.colors.select;
}
return colorTransform;
return theme.colors.transform;
}
void main()
@@ -50,7 +50,7 @@ void main()
float3 ws_cell_location = (model_mat * float4(ls_cell_location, 1.0f)).xyz;
gl_Position = drw_point_world_to_homogenous(ws_cell_location);
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
final_color = color_from_id(color_id);
@@ -61,7 +61,7 @@ void main()
if (z_delta > 0.0f) {
float fac = 1.0f - z_delta * 10000.0f;
/* Smooth blend to avoid flickering. */
final_color = mix(colorBackground, final_color, clamp(fac, 0.2f, 1.0f));
final_color = mix(theme.colors.background, final_color, clamp(fac, 0.2f, 1.0f));
}
view_clipping_distances(ws_cell_location);

View File

@@ -13,7 +13,7 @@ void main()
float fac = dist * dist * 4.0f;
/* Non linear blend. */
float4 col1 = sqrt(colorEditMeshMiddle);
float4 col1 = sqrt(theme.colors.edit_mesh_middle);
float4 col2 = sqrt(final_color);
frag_color = mix(col1, col2, 0.45f + fac * 0.65f);
frag_color *= frag_color;

View File

@@ -18,7 +18,7 @@ void main()
float3 world_pos = (drw_modelmat() * float4(data_buf[gl_VertexID].pos_.xyz, 1.0f)).xyz;
gl_Position = drw_point_world_to_homogenous(world_pos);
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
view_clipping_distances(world_pos);
}

View File

@@ -19,17 +19,17 @@ void main()
float3 world_pos = drw_point_object_to_world(data_buf[gl_VertexID].pos_.xyz);
gl_Position = drw_point_world_to_homogenous(world_pos);
gl_PointSize = sizeObjectCenter;
float radius = 0.5f * sizeObjectCenter;
float outline_width = sizePixel;
gl_PointSize = theme.sizes.object_center;
float radius = 0.5f * theme.sizes.object_center;
float outline_width = theme.sizes.pixel;
radii[0] = radius;
radii[1] = radius - 1.0f;
radii[2] = radius - outline_width;
radii[3] = radius - outline_width - 1.0f;
radii /= sizeObjectCenter;
radii /= theme.sizes.object_center;
fill_color = data_buf[gl_VertexID].color_;
outline_color = colorOutline;
outline_color = theme.colors.outline;
#ifdef SELECT_ENABLE
/* Selection frame-buffer can be very small.

View File

@@ -170,7 +170,7 @@ void main()
/* Relative to DPI scaling. Have constant screen size. */
float3 screen_pos = drw_view().viewinv[0].xyz * vpos.x + drw_view().viewinv[1].xyz * vpos.y;
float3 p = (obmat * float4(vofs, 1.0f)).xyz;
float screen_size = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, p) * sizePixel;
float screen_size = mul_project_m4_v3_zfac(uniform_buf.pixel_fac, p) * theme.sizes.pixel;
world_pos = p + screen_pos * screen_size;
}
else if ((vclass & VCLASS_SCREENALIGNED) != 0) {
@@ -210,13 +210,15 @@ void main()
gl_Position = drw_point_world_to_homogenous(world_pos);
/* Convert to screen position [0..sizeVp]. */
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
#if defined(SELECT_ENABLE)
/* HACK: to avoid losing sub-pixel object in selections, we add a bit of randomness to the
* wire to at least create one fragment that will pass the occlusion query. */
/* TODO(fclem): Limit this workaround to selection. It's not very noticeable but still... */
gl_Position.xy += sizeViewportInv * gl_Position.w * ((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
gl_Position.xy += uniform_buf.size_viewport_inv * gl_Position.w *
((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
#endif
view_clipping_distances(world_pos);

View File

@@ -14,7 +14,7 @@ VERTEX_SHADER_CREATE_INFO(draw_modelmat)
float2 screen_position(float4 p)
{
return ((p.xy / p.w) * 0.5f + 0.5f) * sizeViewport;
return ((p.xy / p.w) * 0.5f + 0.5f) * uniform_buf.size_viewport;
}
void main()
@@ -32,7 +32,8 @@ void main()
/* HACK: to avoid losing sub-pixel object in selections, we add a bit of randomness to the
* wire to at least create one fragment that will pass the occlusion query. */
/* TODO(fclem): Limit this workaround to selection. It's not very noticeable but still... */
gl_Position.xy += sizeViewportInv * gl_Position.w * ((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
gl_Position.xy += uniform_buf.size_viewport_inv * gl_Position.w *
((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
#endif
stipple_coord = stipple_start = screen_position(gl_Position);
@@ -46,7 +47,7 @@ void main()
if (colorid != 0) {
/* TH_CAMERA_PATH is the only color code at the moment.
* Checking `colorid != 0` to avoid having to sync its value with the GLSL code. */
final_color = colorCameraPath;
final_color = theme.colors.camera_path;
final_color.a = 0.0f; /* No Stipple */
}
else {

View File

@@ -8,7 +8,7 @@ FRAGMENT_SHADER_CREATE_INFO(overlay_facing_base)
void main()
{
frag_color = gl_FrontFacing ? colorFaceFront : colorFaceBack;
frag_color = gl_FrontFacing ? theme.colors.face_front : theme.colors.face_back;
/* Pre-multiply the output as we do not do any blending in the frame-buffer. */
frag_color.rgb *= frag_color.a;
}

View File

@@ -147,13 +147,13 @@ void main()
float gridB = get_grid(grid_pos, grid_fwidth, float2(scaleBx, scaleBy));
float gridC = get_grid(grid_pos, grid_fwidth, float2(scaleCx, scaleCy));
out_color = colorGrid;
out_color = theme.colors.grid;
out_color.a *= gridA * blend;
out_color = mix(out_color, mix(colorGrid, colorGridEmphasis, blend), gridB);
out_color = mix(out_color, colorGridEmphasis, gridC);
out_color = mix(out_color, mix(theme.colors.grid, theme.colors.grid_emphasis, blend), gridB);
out_color = mix(out_color, theme.colors.grid_emphasis, gridC);
}
else {
out_color = float4(colorGrid.rgb, 0.0f);
out_color = float4(theme.colors.grid.rgb, 0.0f);
}
if (flag_test(grid_flag, (SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_AXIS_Z))) {
@@ -178,15 +178,15 @@ void main()
if (flag_test(grid_flag, SHOW_AXIS_X)) {
out_color.a = max(out_color.a, axes.x);
out_color.rgb = (axes.x < 1e-8f) ? out_color.rgb : colorGridAxisX.rgb;
out_color.rgb = (axes.x < 1e-8f) ? out_color.rgb : theme.colors.grid_axis_x.rgb;
}
if (flag_test(grid_flag, SHOW_AXIS_Y)) {
out_color.a = max(out_color.a, axes.y);
out_color.rgb = (axes.y < 1e-8f) ? out_color.rgb : colorGridAxisY.rgb;
out_color.rgb = (axes.y < 1e-8f) ? out_color.rgb : theme.colors.grid_axis_y.rgb;
}
if (flag_test(grid_flag, SHOW_AXIS_Z)) {
out_color.a = max(out_color.a, axes.z);
out_color.rgb = (axes.z < 1e-8f) ? out_color.rgb : colorGridAxisZ.rgb;
out_color.rgb = (axes.z < 1e-8f) ? out_color.rgb : theme.colors.grid_axis_z.rgb;
}
}

View File

@@ -48,23 +48,25 @@ VertOut vertex_main(VertIn vert_in)
/* Optionally transform from view space to world space for screen space motion paths. */
vert_out.ws_P = transform_point(camera_space_matrix, vert_in.P);
vert_out.hs_P = drw_point_world_to_homogenous(vert_out.ws_P);
vert_out.ss_P = drw_ndc_to_screen(drw_perspective_divide(vert_out.hs_P)).xy * sizeViewport;
vert_out.ss_P = drw_ndc_to_screen(drw_perspective_divide(vert_out.hs_P)).xy *
uniform_buf.size_viewport;
int frame = int(vert_in.vert_id) + cache_start;
float3 blend_base = (abs(frame - frame_current) == 0) ?
colorCurrentFrame.rgb :
colorBackground.rgb; /* "bleed" CFRAME color to ease color blending */
float3 blend_base =
(abs(frame - frame_current) == 0) ?
theme.colors.current_frame.rgb :
theme.colors.background.rgb; /* "bleed" CFRAME color to ease color blending */
bool use_custom_color = custom_color_pre.x >= 0.0f;
if (frame < frame_current) {
vert_out.color.rgb = use_custom_color ? custom_color_pre : colorBeforeFrame.rgb;
vert_out.color.rgb = use_custom_color ? custom_color_pre : theme.colors.before_frame.rgb;
}
else if (frame > frame_current) {
vert_out.color.rgb = use_custom_color ? custom_color_post : colorAfterFrame.rgb;
vert_out.color.rgb = use_custom_color ? custom_color_post : theme.colors.after_frame.rgb;
}
else /* if (frame == frame_current) */ {
vert_out.color.rgb = use_custom_color ? colorCurrentFrame.rgb : blend_base;
vert_out.color.rgb = use_custom_color ? theme.colors.current_frame.rgb : blend_base;
}
vert_out.color.a = 1.0f;
@@ -105,10 +107,10 @@ void geometry_main(VertOut geom_in[2],
float2 ss_P0 = geom_in[0].ss_P;
float2 ss_P1 = geom_in[1].ss_P;
float2 edge_dir = orthogonal(normalize(ss_P1 - ss_P0 + 1e-8f)) * sizeViewportInv;
float2 edge_dir = orthogonal(normalize(ss_P1 - ss_P0 + 1e-8f)) * uniform_buf.size_viewport_inv;
bool is_persp = (drw_view().winmat[3][3] == 0.0f);
float line_size = float(line_thickness) * sizePixel;
float line_size = float(line_thickness) * theme.sizes.pixel;
GeomOut geom_out;

View File

@@ -22,7 +22,7 @@ void main()
int frame = gl_VertexID + cacheStart;
bool use_custom_color = custom_color_pre.x >= 0.0f;
final_color = (use_custom_color) ? float4(custom_color_pre, 1.0f) : colorVertex;
final_color = (use_custom_color) ? float4(custom_color_pre, 1.0f) : theme.colors.vert;
/* Bias to reduce z fighting with the path */
gl_Position.z -= 1e-4f;
@@ -34,7 +34,7 @@ void main()
/* Draw special dot where the current frame is. */
if (frame == frameCurrent) {
gl_PointSize = float(pt_size + 8);
final_color = colorCurrentFrame;
final_color = theme.colors.current_frame;
/* Bias more to get these on top of keyframes */
gl_Position.z -= 1e-4f;
}
@@ -54,13 +54,13 @@ void main()
/* Overrides the color to highlight points that are keyframes. */
if ((uint(flag) & MOTIONPATH_VERT_KEY) != 0u) {
gl_PointSize = float(pt_size + 5);
final_color = colorVertexSelect;
final_color = theme.colors.vert_select;
/* Bias more to get these on top of regular points */
gl_Position.z -= 1e-4f;
}
}
gl_PointSize *= sizePixel;
gl_PointSize *= theme.sizes.pixel;
view_clipping_distances(pos);
}

View File

@@ -44,7 +44,7 @@ bool4 gather_edges(float2 uv, uint ref)
#ifdef GPU_ARB_texture_gather
ids = textureGather(outline_id_tx, uv);
#else
float3 ofs = float3(0.5f, 0.5f, -0.5f) * sizeViewportInv.xyy;
float3 ofs = float3(0.5f, 0.5f, -0.5f) * uniform_buf.size_viewport_inv.xyy;
ids.x = textureLod(outline_id_tx, uv - ofs.xz, 0.0f).r;
ids.y = textureLod(outline_id_tx, uv + ofs.xy, 0.0f).r;
ids.z = textureLod(outline_id_tx, uv + ofs.xz, 0.0f).r;
@@ -169,8 +169,8 @@ void main()
uint ref = textureLod(outline_id_tx, screen_uv, 0.0f).r;
uint ref_col = ref;
float2 uvs = gl_FragCoord.xy * sizeViewportInv;
float3 ofs = float3(sizeViewportInv, 0.0f);
float2 uvs = gl_FragCoord.xy * uniform_buf.size_viewport_inv;
float3 ofs = float3(uniform_buf.size_viewport_inv, 0.0f);
float2 depth_uv = uvs;
@@ -236,13 +236,13 @@ void main()
frag_color = float4(0.0f);
}
else if (color_id == 1u) {
frag_color = colorSelect;
frag_color = theme.colors.select;
}
else if (color_id == 3u) {
frag_color = colorActive;
frag_color = theme.colors.active;
}
else {
frag_color = colorTransform;
frag_color = theme.colors.transform;
}
float ref_depth = textureLod(outline_depth_tx, depth_uv, 0.0f).r;
@@ -280,13 +280,13 @@ void main()
switch (edge_case) {
/* Straight lines. */
case YPOS:
extra_edges = gather_edges(uvs + sizeViewportInv * float2(2.5f, 0.5f), ref);
extra_edges2 = gather_edges(uvs + sizeViewportInv * float2(-2.5f, 0.5f), ref);
extra_edges = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(2.5f, 0.5f), ref);
extra_edges2 = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(-2.5f, 0.5f), ref);
straight_line_dir(extra_edges, extra_edges2, line_start, line_end);
break;
case YNEG:
extra_edges = gather_edges(uvs + sizeViewportInv * float2(-2.5f, -0.5f), ref);
extra_edges2 = gather_edges(uvs + sizeViewportInv * float2(2.5f, -0.5f), ref);
extra_edges = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(-2.5f, -0.5f), ref);
extra_edges2 = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(2.5f, -0.5f), ref);
extra_edges = rotate_180(extra_edges);
extra_edges2 = rotate_180(extra_edges2);
straight_line_dir(extra_edges, extra_edges2, line_start, line_end);
@@ -294,8 +294,8 @@ void main()
line_end = rotate_180(line_end);
break;
case XPOS:
extra_edges = gather_edges(uvs + sizeViewportInv * float2(0.5f, 2.5f), ref);
extra_edges2 = gather_edges(uvs + sizeViewportInv * float2(0.5f, -2.5f), ref);
extra_edges = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(0.5f, 2.5f), ref);
extra_edges2 = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(0.5f, -2.5f), ref);
extra_edges = rotate_90(extra_edges);
extra_edges2 = rotate_90(extra_edges2);
straight_line_dir(extra_edges, extra_edges2, line_start, line_end);
@@ -303,8 +303,8 @@ void main()
line_end = rotate_90(line_end);
break;
case XNEG:
extra_edges = gather_edges(uvs + sizeViewportInv * float2(-0.5f, 2.5f), ref);
extra_edges2 = gather_edges(uvs + sizeViewportInv * float2(-0.5f, -2.5f), ref);
extra_edges = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(-0.5f, 2.5f), ref);
extra_edges2 = gather_edges(uvs + uniform_buf.size_viewport_inv * float2(-0.5f, -2.5f), ref);
extra_edges = rotate_270(extra_edges);
extra_edges2 = rotate_270(extra_edges2);
straight_line_dir(extra_edges, extra_edges2, line_start, line_end);

View File

@@ -19,13 +19,13 @@ uint outline_colorid_get()
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_transform) {
return 0u; /* colorTransform */
return 0u; /* theme.colors.transform */
}
else if (is_active) {
return 3u; /* colorActive */
return 3u; /* theme.colors.active */
}
else {
return 1u; /* colorSelect */
return 1u; /* theme.colors.select */
}
return 0u;
@@ -49,7 +49,7 @@ void main()
if (hairThicknessRes > 1) {
/* Calculate the thickness, thick-time, world-position taken into account the outline. */
float outline_width = drw_point_world_to_homogenous(center_wpos).w * 1.25f *
uniform_buf.size_viewport.w * drw_view().wininv[1][1];
uniform_buf.size_viewport_inv.y * drw_view().wininv[1][1];
thickness += outline_width;
float thick_time = float(gl_VertexID % hairThicknessRes) / float(hairThicknessRes - 1);
thick_time = thickness * (thick_time * 2.0f - 1.0f);

View File

@@ -32,7 +32,7 @@ void main()
if (!gp_stroke_order3d) {
/* Stroke order 2D. Project to gp_depth_plane. */
bool is_persp = drw_view().winmat[3][3] == 0.0f;
float2 uvs = float2(gl_FragCoord.xy) * sizeViewportInv;
float2 uvs = float2(gl_FragCoord.xy) * uniform_buf.size_viewport_inv;
float3 pos_ndc = float3(uvs, gl_FragCoord.z) * 2.0f - 1.0f;
float4 pos_world = drw_view().viewinv * (drw_view().wininv * float4(pos_ndc, 1.0f));
float3 pos = pos_world.xyz / pos_world.w;

View File

@@ -18,13 +18,13 @@ uint outline_colorid_get()
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_transform) {
return 0u; /* colorTransform */
return 0u; /* theme.colors.transform */
}
else if (is_active) {
return 3u; /* colorActive */
return 3u; /* theme.colors.active */
}
else {
return 1u; /* colorSelect */
return 1u; /* theme.colors.select */
}
return 0u;
@@ -38,7 +38,7 @@ void main()
float unused_strength;
float2 unused_uv;
gl_Position = gpencil_vertex(float4(sizeViewport, sizeViewportInv),
gl_Position = gpencil_vertex(float4(uniform_buf.size_viewport, uniform_buf.size_viewport_inv),
world_pos,
unused_N,
unused_color,

View File

@@ -19,13 +19,13 @@ uint outline_colorid_get()
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_transform) {
return 0u; /* colorTransform */
return 0u; /* theme.colors.transform */
}
else if (is_active) {
return 3u; /* colorActive */
return 3u; /* theme.colors.active */
}
else {
return 1u; /* colorSelect */
return 1u; /* theme.colors.select */
}
return 0u;

View File

@@ -18,13 +18,13 @@ uint outline_colorid_get()
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_transform) {
return 0u; /* colorTransform */
return 0u; /* theme.colors.transform */
}
else if (is_active) {
return 3u; /* colorActive */
return 3u; /* theme.colors.active */
}
else {
return 1u; /* colorSelect */
return 1u; /* theme.colors.select */
}
return 0u;

View File

@@ -20,13 +20,13 @@ uint outline_colorid_get()
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_transform) {
return 0u; /* colorTransform */
return 0u; /* theme.colors.transform */
}
else if (is_active) {
return 3u; /* colorActive */
return 3u; /* theme.colors.active */
}
else {
return 1u; /* colorSelect */
return 1u; /* theme.colors.select */
}
return 0u;

View File

@@ -25,10 +25,10 @@ void main()
gl_Position = float4(-2.0f, -2.0f, -2.0f, 1.0f);
}
final_color = (is_select) ? float4(1.0f) : colorWire;
final_color = (is_select) ? float4(1.0f) : theme.colors.wire;
final_color.a = nor.w;
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
view_clipping_distances(world_pos);
}

View File

@@ -79,7 +79,7 @@ void main()
/* Missing vertex group alert color. Uniform in practice. */
if (alert > 1.1f) {
color = apply_color_fac(colorVertexMissingData);
color = apply_color_fac(theme.colors.vert_missing_data);
}
/* Weights are available */
else {
@@ -98,7 +98,7 @@ void main()
}
/* Zero weight alert color. Nonlinear blend to reduce impact. */
float4 color_unreferenced = apply_color_fac(colorVertexUnreferenced);
float4 color_unreferenced = apply_color_fac(theme.colors.vert_unreferenced);
color = mix(weight_color, color_unreferenced, alert * alert);
}

View File

@@ -27,7 +27,7 @@ void main()
constexpr float4 colSel = float4(1.0f);
final_color = (is_select) ? colSel : colorWire;
final_color = (is_select) ? colSel : theme.colors.wire;
/* Weight paint needs a light color to contrasts with dark weights. */
if (!use_select) {

View File

@@ -29,24 +29,24 @@ void wire_color_get(out float3 rim_col, out float3 wire_col)
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_from_set) {
rim_col = colorWire.rgb;
wire_col = colorWire.rgb;
rim_col = theme.colors.wire.rgb;
wire_col = theme.colors.wire.rgb;
}
else if (is_selected && use_coloring) {
if (is_transform) {
rim_col = colorTransform.rgb;
rim_col = theme.colors.transform.rgb;
}
else if (is_active) {
rim_col = colorActive.rgb;
rim_col = theme.colors.active.rgb;
}
else {
rim_col = colorSelect.rgb;
rim_col = theme.colors.select.rgb;
}
wire_col = colorWire.rgb;
wire_col = theme.colors.wire.rgb;
}
else {
rim_col = colorWire.rgb;
wire_col = colorBackground.rgb;
rim_col = theme.colors.wire.rgb;
wire_col = theme.colors.background.rgb;
}
}
@@ -94,7 +94,8 @@ void main()
gl_Position = drw_point_world_to_homogenous(ws_P);
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
float3 rim_col, wire_col;
if (color_type == V3D_SHADING_OBJECT_COLOR || color_type == V3D_SHADING_RANDOM_COLOR) {

View File

@@ -93,7 +93,8 @@ void main()
world_pos += rotate(shape_pos, part.rotation);
}
gl_Position = drw_point_world_to_homogenous(world_pos);
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = edge_pos = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
view_clipping_distances(world_pos);
}

View File

@@ -22,8 +22,8 @@ void main()
gl_Position = drw_point_world_to_homogenous(world_pos);
/* World sized points. */
gl_PointSize = sizePixel * draw_size * drw_view().winmat[1][1] * uniform_buf.size_viewport.y /
gl_Position.w;
gl_PointSize = theme.sizes.pixel * draw_size * drw_view().winmat[1][1] *
uniform_buf.size_viewport.y / gl_Position.w;
/* Coloring */
if (part_val < 0.0f) {

View File

@@ -25,7 +25,7 @@ void main()
float midStroke = 0.5f * rad_squared;
if (vertex_crease > 0.0f && dist_squared > midStroke) {
frag_color.rgb = mix(final_color.rgb, colorEdgeCrease.rgb, vertex_crease);
frag_color.rgb = mix(final_color.rgb, theme.colors.edge_crease.rgb, vertex_crease);
}
#else
frag_color = final_color;

View File

@@ -19,5 +19,6 @@ void main()
final_color.a *= opacity;
/* Convert to screen position [0..sizeVp]. */
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_pos = edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) *
uniform_buf.size_viewport;
}

View File

@@ -45,10 +45,10 @@ void main()
float2 dir = line_output.xy * 2.0f - 1.0f;
bool dir_horiz = abs(dir.x) > abs(dir.y);
float2 uv = gl_FragCoord.xy * sizeViewportInv;
float2 uv = gl_FragCoord.xy * uniform_buf.size_viewport_inv;
float depth_occluder = texture(depth_tx, uv).r;
float depth_min = depth_occluder;
float2 uv_offset = sizeViewportInv;
float2 uv_offset = uniform_buf.size_viewport_inv;
if (dir_horiz) {
uv_offset.y = 0.0f;
}

View File

@@ -30,24 +30,24 @@ void wire_color_get(out float3 rim_col, out float3 wire_col)
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
if (is_from_set) {
rim_col = colorWire.rgb;
wire_col = colorWire.rgb;
rim_col = theme.colors.wire.rgb;
wire_col = theme.colors.wire.rgb;
}
else if (is_selected && use_coloring) {
if (is_transform) {
rim_col = colorTransform.rgb;
rim_col = theme.colors.transform.rgb;
}
else if (is_active) {
rim_col = colorActive.rgb;
rim_col = theme.colors.active.rgb;
}
else {
rim_col = colorSelect.rgb;
rim_col = theme.colors.select.rgb;
}
wire_col = colorWire.rgb;
wire_col = theme.colors.wire.rgb;
}
else {
rim_col = colorWire.rgb;
wire_col = colorBackground.rgb;
rim_col = theme.colors.wire.rgb;
wire_col = theme.colors.background.rgb;
}
}
@@ -97,7 +97,7 @@ void main()
float3 wpos = drw_point_object_to_world(pos);
#if defined(POINTS)
gl_PointSize = sizeVertex * 2.0f;
gl_PointSize = theme.sizes.vert * 2.0f;
#elif defined(CURVES)
float facing = no_nor_facing;
#else
@@ -127,7 +127,7 @@ void main()
wofs = drw_normal_world_to_view(wofs);
/* Push vertex half a pixel (maximum) in normal direction. */
gl_Position.xy += wofs.xy * sizeViewportInv * gl_Position.w;
gl_Position.xy += wofs.xy * uniform_buf.size_viewport_inv * gl_Position.w;
/* Push the vertex towards the camera. Helps a bit. */
gl_Position.z -= facing_ratio * curvature * 1.0e-6f * gl_Position.w;
@@ -153,7 +153,7 @@ void main()
#else
/* Convert to screen position [0..sizeVp]. */
edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * sizeViewport;
edge_start = ((gl_Position.xy / gl_Position.w) * 0.5f + 0.5f) * uniform_buf.size_viewport;
edge_pos = edge_start;
# if !defined(SELECT_ENABLE)
@@ -179,7 +179,8 @@ void main()
# if defined(SELECT_ENABLE)
/* HACK: to avoid losing sub-pixel object in selections, we add a bit of randomness to the
* wire to at least create one fragment that will pass the occlusion query. */
gl_Position.xy += sizeViewportInv * gl_Position.w * ((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
gl_Position.xy += uniform_buf.size_viewport_inv * gl_Position.w *
((gl_VertexID % 2 == 0) ? -1.0f : 1.0f);
# endif
#endif