Refactor: Overlay: Port "next" shaders declarations to static CreateInfos

Use static CreateInfos for Overlay-Next shaders using a similar approach to Workbench shader variations.

Remove unused infos and shader sources.
Remove the `gpu_shader_create_info_get_unfinalized_copy` workaround.

Pull Request: https://projects.blender.org/blender/blender/pulls/131514
This commit is contained in:
Miguel Pozo
2024-12-12 23:05:00 +01:00
committed by Clément Foucault
parent 6fa5295c1d
commit b295df7345
74 changed files with 1780 additions and 3965 deletions

View File

@@ -618,15 +618,11 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_armature_envelope_outline_vert.glsl
engines/overlay/shaders/overlay_armature_envelope_solid_frag.glsl
engines/overlay/shaders/overlay_armature_envelope_solid_vert.glsl
engines/overlay/shaders/overlay_armature_shape_outline_geom.glsl
engines/overlay/shaders/overlay_armature_shape_outline_next_vert.glsl
engines/overlay/shaders/overlay_armature_shape_outline_vert.glsl
engines/overlay/shaders/overlay_armature_shape_solid_frag.glsl
engines/overlay/shaders/overlay_armature_shape_solid_vert.glsl
engines/overlay/shaders/overlay_armature_shape_wire_next_vert.glsl
engines/overlay/shaders/overlay_armature_shape_wire_vert.glsl
engines/overlay/shaders/overlay_armature_shape_wire_frag.glsl
engines/overlay/shaders/overlay_armature_shape_wire_geom.glsl
engines/overlay/shaders/overlay_armature_sphere_outline_vert.glsl
engines/overlay/shaders/overlay_armature_sphere_solid_frag.glsl
engines/overlay/shaders/overlay_armature_sphere_solid_vert.glsl
@@ -644,17 +640,12 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_depth_only_mesh_conservative_vert.glsl
engines/overlay/shaders/overlay_depth_only_pointcloud_vert.glsl
engines/overlay/shaders/overlay_depth_only_vert.glsl
engines/overlay/shaders/overlay_edit_curve_handle_geom.glsl
engines/overlay/shaders/overlay_edit_curve_handle_next_vert.glsl
engines/overlay/shaders/overlay_edit_curve_handle_vert.glsl
engines/overlay/shaders/overlay_edit_curve_point_vert.glsl
engines/overlay/shaders/overlay_edit_curves_handle_geom.glsl
engines/overlay/shaders/overlay_edit_curves_handle_next_vert.glsl
engines/overlay/shaders/overlay_edit_curves_handle_vert.glsl
engines/overlay/shaders/overlay_edit_curve_wire_vert.glsl
engines/overlay/shaders/overlay_edit_curve_wire_next_vert.glsl
engines/overlay/shaders/overlay_edit_gpencil_canvas_vert.glsl
engines/overlay/shaders/overlay_edit_gpencil_guide_vert.glsl
engines/overlay/shaders/overlay_edit_gpencil_vert.glsl
engines/overlay/shaders/overlay_edit_lattice_point_vert.glsl
engines/overlay/shaders/overlay_edit_lattice_wire_vert.glsl
@@ -663,7 +654,6 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_edit_mesh_common_lib.glsl
engines/overlay/shaders/overlay_edit_mesh_depth_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_frag.glsl
engines/overlay/shaders/overlay_edit_mesh_geom.glsl
engines/overlay/shaders/overlay_edit_mesh_normal_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl
engines/overlay/shaders/overlay_edit_mesh_vert.glsl
@@ -675,10 +665,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_edit_particle_point_vert.glsl
engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl
engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl
engines/overlay/shaders/overlay_edit_uv_edges_geom.glsl
engines/overlay/shaders/overlay_edit_uv_edges_vert.glsl
engines/overlay/shaders/overlay_edit_uv_edges_next_frag.glsl
engines/overlay/shaders/overlay_edit_uv_edges_next_vert.glsl
engines/overlay/shaders/overlay_edit_uv_face_dots_vert.glsl
engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl
engines/overlay/shaders/overlay_edit_uv_image_mask_frag.glsl
@@ -704,14 +691,11 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_image_frag.glsl
engines/overlay/shaders/overlay_image_vert.glsl
engines/overlay/shaders/overlay_motion_path_line_frag.glsl
engines/overlay/shaders/overlay_motion_path_line_geom.glsl
engines/overlay/shaders/overlay_motion_path_line_next_vert.glsl
engines/overlay/shaders/overlay_motion_path_line_vert.glsl
engines/overlay/shaders/overlay_motion_path_point_vert.glsl
engines/overlay/shaders/overlay_outline_detect_frag.glsl
engines/overlay/shaders/overlay_outline_prepass_curves_vert.glsl
engines/overlay/shaders/overlay_outline_prepass_frag.glsl
engines/overlay/shaders/overlay_outline_prepass_geom.glsl
engines/overlay/shaders/overlay_outline_prepass_gpencil_frag.glsl
engines/overlay/shaders/overlay_outline_prepass_gpencil_vert.glsl
engines/overlay/shaders/overlay_outline_prepass_pointcloud_vert.glsl
@@ -721,8 +705,6 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_paint_point_vert.glsl
engines/overlay/shaders/overlay_paint_texture_frag.glsl
engines/overlay/shaders/overlay_paint_texture_vert.glsl
engines/overlay/shaders/overlay_paint_vertcol_frag.glsl
engines/overlay/shaders/overlay_paint_vertcol_vert.glsl
engines/overlay/shaders/overlay_paint_weight_frag.glsl
engines/overlay/shaders/overlay_paint_weight_vert.glsl
engines/overlay/shaders/overlay_paint_wire_vert.glsl
@@ -733,7 +715,6 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_particle_shape_frag.glsl
engines/overlay/shaders/overlay_point_varying_color_frag.glsl
engines/overlay/shaders/overlay_point_varying_color_varying_outline_aa_frag.glsl
engines/overlay/shaders/overlay_pointcloud_only_vert.glsl
engines/overlay/shaders/overlay_sculpt_curves_cage_vert.glsl
engines/overlay/shaders/overlay_sculpt_curves_selection_frag.glsl
engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl

View File

@@ -119,10 +119,10 @@ class Bounds : Overlay {
call_buffers_.capsule_cap.append(data, select_id);
mat.z_axis() *= -1;
mat.location().z = center.z - std::max(0.0f, size.z - size.x);
data.object_to_world_ = object_mat * mat;
data.object_to_world = object_mat * mat;
call_buffers_.capsule_cap.append(data, select_id);
mat.z_axis().z = std::max(0.0f, size.z * 2.0f - size.x * 2.0f);
data.object_to_world_ = object_mat * mat;
data.object_to_world = object_mat * mat;
call_buffers_.capsule_body.append(data, select_id);
break;
}

View File

@@ -26,7 +26,7 @@ struct CameraInstanceData : public ExtraInstanceData {
float &volume_end = color_[3];
float &depth = color_[3];
float &focus = color_[3];
float4x4 &matrix = object_to_world_;
float4x4 &matrix = object_to_world;
float &dist_color_id = matrix[0][3];
float &corner_x = matrix[0][3];
float &corner_y = matrix[1][3];
@@ -38,7 +38,7 @@ struct CameraInstanceData : public ExtraInstanceData {
float &mist_end = matrix[3][3];
CameraInstanceData(const CameraInstanceData &data)
: CameraInstanceData(data.object_to_world_, data.color_)
: CameraInstanceData(data.object_to_world, data.color_)
{
}
@@ -805,7 +805,7 @@ class Cameras : Overlay {
/* Connecting line between cameras. */
call_buffers_.stereo_connect_lines.append(stereodata.matrix.location(),
instdata.object_to_world_.location(),
instdata.object_to_world.location(),
res.theme_settings.color_wire,
cam_select_id);
}

View File

@@ -69,7 +69,7 @@ class ForceFields : Overlay {
ExtraInstanceData data(
ob->object_to_world(), res.object_background_blend_color(ob_ref, state), 1.0f);
float4x4 &matrix = data.object_to_world_;
float4x4 &matrix = data.object_to_world;
float &size_x = matrix[0][3];
float &size_y = matrix[1][3];
float &size_z = matrix[2][3];

View File

@@ -74,7 +74,7 @@ class Lights : Overlay {
float4 &theme_color = data.color_;
/* Pack render data into object matrix. */
float4x4 &matrix = data.object_to_world_;
float4x4 &matrix = data.object_to_world;
float &area_size_x = matrix[0].w;
float &area_size_y = matrix[1].w;
float &spot_cosine = matrix[0].w;

View File

@@ -89,7 +89,7 @@ class LightProbes : Overlay {
const select::ID select_id = res.select_id(ob_ref);
const float4 color = res.object_wire_color(ob_ref, state);
ExtraInstanceData data(ob->object_to_world(), color, 1.0f);
float4x4 &matrix = data.object_to_world_;
float4x4 &matrix = data.object_to_world;
float &clip_start = matrix[2].w;
float &clip_end = matrix[3].w;
float &draw_size = matrix[3].w;
@@ -109,7 +109,7 @@ class LightProbes : Overlay {
const float f = 1.0f - prb->falloff;
ExtraInstanceData data(ob->object_to_world(), color, prb->distinf);
attenuation.append(data, select_id);
data.object_to_world_[3].w = prb->distinf * f;
data.object_to_world[3].w = prb->distinf * f;
attenuation.append(data, select_id);
}

View File

@@ -365,110 +365,113 @@ class ShaderModule {
public:
/** Shaders */
ShaderPtr attribute_viewer_mesh;
ShaderPtr attribute_viewer_pointcloud;
ShaderPtr attribute_viewer_curve;
ShaderPtr attribute_viewer_curves;
ShaderPtr anti_aliasing = shader("overlay_antialiasing");
ShaderPtr armature_degrees_of_freedom;
ShaderPtr armature_degrees_of_freedom = shader_clippable("overlay_armature_dof");
ShaderPtr attribute_viewer_mesh = shader_clippable("overlay_viewer_attribute_mesh");
ShaderPtr attribute_viewer_pointcloud = shader_clippable("overlay_viewer_attribute_pointcloud");
ShaderPtr attribute_viewer_curve = shader_clippable("overlay_viewer_attribute_curve");
ShaderPtr attribute_viewer_curves = shader_clippable("overlay_viewer_attribute_curves");
ShaderPtr background_fill = shader("overlay_background");
ShaderPtr background_clip_bound = shader("overlay_clipbound");
ShaderPtr curve_edit_points;
ShaderPtr curve_edit_line;
ShaderPtr curve_edit_handles = shader("overlay_edit_curves_handle_next");
ShaderPtr extra_point;
ShaderPtr facing;
ShaderPtr curve_edit_points = shader_clippable("overlay_edit_curves_point");
ShaderPtr curve_edit_line = shader_clippable("overlay_edit_particle_strand");
ShaderPtr curve_edit_handles = shader_clippable("overlay_edit_curves_handle");
ShaderPtr facing = shader_clippable("overlay_facing");
ShaderPtr grid = shader("overlay_grid_next");
ShaderPtr grid_background;
ShaderPtr grid_grease_pencil = shader("overlay_gpencil_canvas");
ShaderPtr grid_image;
ShaderPtr legacy_curve_edit_wires;
ShaderPtr grid_background = shader("overlay_grid_background");
ShaderPtr grid_grease_pencil = shader_clippable("overlay_gpencil_canvas");
ShaderPtr grid_image = shader("overlay_grid_image");
ShaderPtr lattice_points = shader_clippable("overlay_edit_lattice_point");
ShaderPtr lattice_wire = shader_clippable("overlay_edit_lattice_wire");
ShaderPtr legacy_curve_edit_handles = shader_clippable("overlay_edit_curve_handle");
ShaderPtr legacy_curve_edit_normals = shader("overlay_edit_curve_normals");
ShaderPtr legacy_curve_edit_handles = shader("overlay_edit_curve_handle_next");
ShaderPtr legacy_curve_edit_points;
ShaderPtr motion_path_line = shader("overlay_motion_path_line_next");
ShaderPtr motion_path_vert = shader("overlay_motion_path_point");
ShaderPtr mesh_analysis;
ShaderPtr mesh_edit_depth;
ShaderPtr mesh_edit_edge = shader("overlay_edit_mesh_edge_next");
ShaderPtr mesh_edit_face = shader("overlay_edit_mesh_face_next");
ShaderPtr mesh_edit_vert = shader("overlay_edit_mesh_vert_next");
ShaderPtr mesh_edit_facedot = shader("overlay_edit_mesh_facedot_next");
ShaderPtr mesh_edit_skin_root;
ShaderPtr mesh_face_normal, mesh_face_normal_subdiv;
ShaderPtr mesh_loop_normal, mesh_loop_normal_subdiv;
ShaderPtr mesh_vert_normal;
ShaderPtr outline_prepass_mesh;
ShaderPtr outline_prepass_wire = shader("overlay_outline_prepass_wire_next");
ShaderPtr outline_prepass_curves;
ShaderPtr outline_prepass_pointcloud;
ShaderPtr outline_prepass_gpencil;
ShaderPtr legacy_curve_edit_points = shader_clippable("overlay_edit_curve_point");
ShaderPtr legacy_curve_edit_wires = shader_clippable("overlay_edit_curve_wire");
ShaderPtr light_spot_cone = shader_clippable("overlay_extra_spot_cone");
ShaderPtr mesh_analysis = shader_clippable("overlay_edit_mesh_analysis");
ShaderPtr mesh_edit_depth = shader_clippable("overlay_edit_mesh_depth");
ShaderPtr mesh_edit_edge = shader("overlay_edit_mesh_edge");
ShaderPtr mesh_edit_face = shader_clippable("overlay_edit_mesh_face");
ShaderPtr mesh_edit_facedot = shader("overlay_edit_mesh_facedot");
ShaderPtr mesh_edit_vert = shader_clippable("overlay_edit_mesh_vert");
ShaderPtr mesh_edit_skin_root = shader_clippable("overlay_edit_mesh_skin_root");
ShaderPtr mesh_face_normal = shader_clippable("overlay_mesh_face_normal");
ShaderPtr mesh_face_normal_subdiv = shader_clippable("overlay_mesh_face_normal_subdiv");
ShaderPtr mesh_loop_normal = shader_clippable("overlay_mesh_loop_normal");
ShaderPtr mesh_loop_normal_subdiv = shader_clippable("overlay_mesh_loop_normal_subdiv");
ShaderPtr mesh_vert_normal = shader_clippable("overlay_mesh_vert_normal");
ShaderPtr motion_path_line = shader_clippable("overlay_motion_path_line");
ShaderPtr motion_path_vert = shader_clippable("overlay_motion_path_point");
ShaderPtr outline_detect = shader("overlay_outline_detect");
ShaderPtr particle_edit_vert;
ShaderPtr particle_edit_edge;
ShaderPtr paint_region_edge;
ShaderPtr paint_region_face;
ShaderPtr paint_region_vert;
ShaderPtr paint_texture;
ShaderPtr paint_weight;
ShaderPtr paint_weight_fake_shading; /* TODO(fclem): Specialization constant. */
ShaderPtr sculpt_mesh;
ShaderPtr sculpt_curves;
ShaderPtr sculpt_curves_cage;
ShaderPtr uniform_color;
ShaderPtr uv_analysis_stretch_angle;
ShaderPtr uv_analysis_stretch_area;
ShaderPtr uv_brush_stencil;
ShaderPtr uv_edit_edge = shader("overlay_edit_uv_edges_next");
ShaderPtr uv_edit_face;
ShaderPtr uv_edit_facedot;
ShaderPtr uv_edit_vert;
ShaderPtr uv_image_borders;
ShaderPtr uv_paint_mask;
ShaderPtr outline_prepass_curves = shader_clippable("overlay_outline_prepass_curves");
ShaderPtr outline_prepass_gpencil = shader_clippable("overlay_outline_prepass_gpencil");
ShaderPtr outline_prepass_mesh = shader_clippable("overlay_outline_prepass_mesh");
ShaderPtr outline_prepass_pointcloud = shader_clippable("overlay_outline_prepass_pointcloud");
ShaderPtr outline_prepass_wire = shader_clippable("overlay_outline_prepass_wire");
ShaderPtr paint_region_edge = shader_clippable("overlay_paint_wire");
ShaderPtr paint_region_face = shader_clippable("overlay_paint_face");
ShaderPtr paint_region_vert = shader_clippable("overlay_paint_point");
ShaderPtr paint_texture = shader_clippable("overlay_paint_texture");
ShaderPtr paint_weight = shader_clippable("overlay_paint_weight");
/* TODO(fclem): Specialization constant. */
ShaderPtr paint_weight_fake_shading = shader_clippable("overlay_paint_weight_fake_shading");
ShaderPtr particle_edit_vert = shader_clippable("overlay_edit_particle_point");
ShaderPtr particle_edit_edge = shader_clippable("overlay_edit_particle_strand");
ShaderPtr sculpt_curves = shader_clippable("overlay_sculpt_curves_selection");
ShaderPtr sculpt_curves_cage = shader_clippable("overlay_sculpt_curves_cage");
ShaderPtr sculpt_mesh = shader_clippable("overlay_sculpt_mask");
ShaderPtr uniform_color = shader_clippable("overlay_uniform_color");
ShaderPtr uv_analysis_stretch_angle = shader("overlay_edit_uv_stretching_angle");
ShaderPtr uv_analysis_stretch_area = shader("overlay_edit_uv_stretching_area");
ShaderPtr uv_brush_stencil = shader("overlay_edit_uv_stencil_image");
ShaderPtr uv_edit_edge = shader("overlay_edit_uv_edges");
ShaderPtr uv_edit_face = shader("overlay_edit_uv_faces");
ShaderPtr uv_edit_facedot = shader("overlay_edit_uv_face_dots");
ShaderPtr uv_edit_vert = shader("overlay_edit_uv_verts");
ShaderPtr uv_image_borders = shader("overlay_edit_uv_tiled_image_borders");
ShaderPtr uv_paint_mask = shader("overlay_edit_uv_mask_image");
ShaderPtr uv_wireframe = shader("overlay_wireframe_uv");
ShaderPtr xray_fade;
ShaderPtr xray_fade = shader("overlay_xray_fade");
/** Selectable Shaders */
ShaderPtr armature_envelope_fill;
ShaderPtr armature_envelope_outline;
ShaderPtr armature_shape_outline;
ShaderPtr armature_shape_fill;
ShaderPtr armature_shape_wire;
ShaderPtr armature_sphere_outline;
ShaderPtr armature_sphere_fill;
ShaderPtr armature_stick;
ShaderPtr armature_wire;
ShaderPtr depth_curves = selectable_shader("overlay_depth_curves");
ShaderPtr depth_grease_pencil = selectable_shader("overlay_depth_gpencil");
ShaderPtr depth_mesh = selectable_shader("overlay_depth_mesh");
ShaderPtr depth_mesh_conservative = selectable_shader("overlay_depth_mesh_conservative");
ShaderPtr depth_point_cloud = selectable_shader("overlay_depth_pointcloud");
ShaderPtr extra_grid;
ShaderPtr extra_shape;
ShaderPtr extra_wire_object;
ShaderPtr extra_wire;
ShaderPtr extra_loose_points;
ShaderPtr extra_ground_line;
ShaderPtr fluid_grid_lines_flags;
ShaderPtr fluid_grid_lines_flat;
ShaderPtr fluid_grid_lines_range;
ShaderPtr fluid_velocity_streamline;
ShaderPtr fluid_velocity_mac;
ShaderPtr fluid_velocity_needle;
ShaderPtr image_plane;
ShaderPtr image_plane_depth_bias;
ShaderPtr lattice_points;
ShaderPtr lattice_wire;
ShaderPtr light_spot_cone;
ShaderPtr particle_dot;
ShaderPtr particle_shape;
ShaderPtr particle_hair;
ShaderPtr wireframe_mesh;
ShaderPtr wireframe_curve;
ShaderPtr wireframe_points; /* Draw objects without edges for the wireframe overlay. */
ShaderPtr armature_envelope_fill = shader_selectable("overlay_armature_envelope_solid");
ShaderPtr armature_envelope_outline = shader_selectable("overlay_armature_envelope_outline");
ShaderPtr armature_shape_outline = shader_selectable("overlay_armature_shape_outline");
ShaderPtr armature_shape_fill = shader_selectable("overlay_armature_shape_solid");
ShaderPtr armature_shape_wire = shader_selectable("overlay_armature_shape_wire");
ShaderPtr armature_sphere_outline = shader_selectable("overlay_armature_sphere_outline");
ShaderPtr armature_sphere_fill = shader_selectable("overlay_armature_sphere_solid");
ShaderPtr armature_stick = shader_selectable("overlay_armature_stick");
ShaderPtr armature_wire = shader_selectable("overlay_armature_wire");
ShaderPtr depth_curves = shader_selectable("overlay_depth_curves");
ShaderPtr depth_grease_pencil = shader_selectable("overlay_depth_gpencil");
ShaderPtr depth_mesh = shader_selectable("overlay_depth_mesh");
ShaderPtr depth_mesh_conservative = shader_selectable("overlay_depth_mesh_conservative");
ShaderPtr depth_point_cloud = shader_selectable("overlay_depth_pointcloud");
ShaderPtr extra_shape = shader_selectable("overlay_extra");
ShaderPtr extra_point = shader_selectable("overlay_extra_point");
ShaderPtr extra_wire = shader_selectable("overlay_extra_wire");
ShaderPtr extra_wire_object = shader_selectable("overlay_extra_wire_object");
ShaderPtr extra_loose_points = shader_selectable("overlay_extra_loose_point");
ShaderPtr extra_grid = shader_selectable("overlay_extra_grid");
ShaderPtr extra_ground_line = shader_selectable("overlay_extra_groundline");
ShaderPtr image_plane = shader_selectable("overlay_image");
ShaderPtr image_plane_depth_bias = shader_selectable("overlay_image_depth_bias");
ShaderPtr particle_dot = shader_selectable("overlay_particle_dot");
ShaderPtr particle_shape = shader_selectable("overlay_particle_shape");
ShaderPtr particle_hair = shader_selectable("overlay_particle_hair");
ShaderPtr wireframe_mesh = shader_selectable("overlay_wireframe");
/* Draw objects without edges for the wireframe overlay. */
ShaderPtr wireframe_points = shader_selectable("overlay_wireframe_points");
ShaderPtr wireframe_curve = shader_selectable("overlay_wireframe_curve");
ShaderModule(const SelectionType selection_type, const bool clipping_enabled);
ShaderPtr fluid_grid_lines_flags = shader_selectable_no_clip("overlay_volume_gridlines_flags");
ShaderPtr fluid_grid_lines_flat = shader_selectable_no_clip("overlay_volume_gridlines_flat");
ShaderPtr fluid_grid_lines_range = shader_selectable_no_clip("overlay_volume_gridlines_range");
ShaderPtr fluid_velocity_streamline = shader_selectable_no_clip(
"overlay_volume_velocity_streamline");
ShaderPtr fluid_velocity_mac = shader_selectable_no_clip("overlay_volume_velocity_mac");
ShaderPtr fluid_velocity_needle = shader_selectable_no_clip("overlay_volume_velocity_needle");
/** Module */
/** Only to be used by Instance constructor. */
@@ -476,15 +479,16 @@ class ShaderModule {
static void module_free();
private:
ShaderModule(const SelectionType selection_type, const bool clipping_enabled)
: selection_type_(selection_type), clipping_enabled_(clipping_enabled){};
ShaderPtr shader(const char *create_info_name)
{
return ShaderPtr(GPU_shader_create_from_info_name(create_info_name));
}
ShaderPtr shader(const char *create_info_name,
FunctionRef<void(gpu::shader::ShaderCreateInfo &info)> patch);
ShaderPtr selectable_shader(const char *create_info_name);
ShaderPtr selectable_shader(const char *create_info_name,
FunctionRef<void(gpu::shader::ShaderCreateInfo &info)> patch);
ShaderPtr shader_clippable(const char *create_info_name);
ShaderPtr shader_selectable(const char *create_info_name);
ShaderPtr shader_selectable_no_clip(const char *create_info_name);
};
struct GreasePencilDepthPlane {

View File

@@ -12,631 +12,45 @@ namespace blender::draw::overlay {
ShaderModule *ShaderModule::g_shader_modules[2][2] = {{nullptr}};
ShaderModule::ShaderPtr ShaderModule::shader(
const char *create_info_name,
const FunctionRef<void(gpu::shader::ShaderCreateInfo &info)> patch)
ShaderModule::ShaderPtr ShaderModule::shader_clippable(const char *create_info_name)
{
/* Perform a copy for patching. */
gpu::shader::ShaderCreateInfo info(create_info_name);
GPU_shader_create_info_get_unfinalized_copy(create_info_name,
reinterpret_cast<GPUShaderCreateInfo &>(info));
patch(info);
info.define("OVERLAY_NEXT");
std::string name = create_info_name;
if (clipping_enabled_) {
info.define("USE_WORLD_CLIP_PLANES");
name += "_clipped";
}
return ShaderPtr(
GPU_shader_create_from_info(reinterpret_cast<const GPUShaderCreateInfo *>(&info)));
return ShaderPtr(GPU_shader_create_from_info_name(name.c_str()));
}
ShaderModule::ShaderPtr ShaderModule::selectable_shader(const char *create_info_name)
ShaderModule::ShaderPtr ShaderModule::shader_selectable(const char *create_info_name)
{
/* TODO: This is what it should be like with all variations defined with create infos. */
// std::string create_info_name = base_create_info;
// create_info_name += SelectEngineT::shader_suffix;
// create_info_name += clipping_enabled_ ? "_clipped" : "";
// this->shader_ = GPU_shader_create_from_info_name(create_info_name.c_str());
/* WORKAROUND: ... but for now, we have to patch the create info used by the old engine. */
/* Perform a copy for patching. */
gpu::shader::ShaderCreateInfo info(create_info_name);
GPU_shader_create_info_get_unfinalized_copy(create_info_name,
reinterpret_cast<GPUShaderCreateInfo &>(info));
info.define("OVERLAY_NEXT");
std::string name = create_info_name;
if (selection_type_ != SelectionType::DISABLED) {
info.define("SELECT_ENABLE");
info.depth_write(gpu::shader::DepthWrite::UNCHANGED);
/* Replace additional info. */
for (StringRefNull &str : info.additional_infos_) {
if (str == "draw_modelmat_new") {
str = "draw_modelmat_new_with_custom_id";
}
}
info.additional_info("select_id_patch");
name += "_selectable";
}
if (clipping_enabled_) {
info.define("USE_WORLD_CLIP_PLANES");
name += "_clipped";
}
return ShaderPtr(
GPU_shader_create_from_info(reinterpret_cast<const GPUShaderCreateInfo *>(&info)));
return ShaderPtr(GPU_shader_create_from_info_name(name.c_str()));
}
ShaderModule::ShaderPtr ShaderModule::selectable_shader(
const char *create_info_name,
const FunctionRef<void(gpu::shader::ShaderCreateInfo &info)> patch)
ShaderModule::ShaderPtr ShaderModule::shader_selectable_no_clip(const char *create_info_name)
{
/* Perform a copy for patching. */
gpu::shader::ShaderCreateInfo info(create_info_name);
GPU_shader_create_info_get_unfinalized_copy(create_info_name,
reinterpret_cast<GPUShaderCreateInfo &>(info));
patch(info);
info.define("OVERLAY_NEXT");
std::string name = create_info_name;
if (selection_type_ != SelectionType::DISABLED) {
info.define("SELECT_ENABLE");
info.depth_write(gpu::shader::DepthWrite::UNCHANGED);
/* Replace additional info. */
for (StringRefNull &str : info.additional_infos_) {
if (str == "draw_modelmat_new") {
str = "draw_modelmat_new_with_custom_id";
}
}
info.additional_info("select_id_patch");
name += "_selectable";
}
if (clipping_enabled_) {
info.define("USE_WORLD_CLIP_PLANES");
}
return ShaderPtr(
GPU_shader_create_from_info(reinterpret_cast<const GPUShaderCreateInfo *>(&info)));
return ShaderPtr(GPU_shader_create_from_info_name(name.c_str()));
}
using namespace blender::gpu::shader;
static void shader_patch_common(gpu::shader::ShaderCreateInfo &info)
{
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
}
static void shader_patch_edit_mesh_normal_common(gpu::shader::ShaderCreateInfo &info)
{
shader_patch_common(info);
info.defines_.clear(); /* Removes WORKAROUND_INDEX_LOAD_INCLUDE. */
info.vertex_inputs_.clear();
info.additional_info("gpu_index_buffer_load");
info.storage_buf(1, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY);
}
ShaderModule::ShaderModule(const SelectionType selection_type, const bool clipping_enabled)
: selection_type_(selection_type), clipping_enabled_(clipping_enabled)
{
/** Shaders */
attribute_viewer_mesh = shader(
"overlay_viewer_attribute_mesh", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"overlay_viewer_attribute_common", "draw_view", "draw_modelmat_new", "draw_globals");
});
attribute_viewer_pointcloud = shader("overlay_viewer_attribute_pointcloud",
[](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("overlay_viewer_attribute_common",
"draw_pointcloud_new",
"draw_globals",
"draw_view",
"draw_modelmat_new");
});
attribute_viewer_curve = shader(
"overlay_viewer_attribute_curve", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"overlay_viewer_attribute_common", "draw_view", "draw_globals", "draw_modelmat_new");
});
attribute_viewer_curves = shader("overlay_viewer_attribute_curves",
[](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("overlay_viewer_attribute_common",
"draw_hair_new",
"draw_view",
"draw_globals",
"draw_modelmat_new");
});
armature_degrees_of_freedom = shader(
"overlay_armature_dof", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "ExtraInstanceData", "data_buf[]");
info.define("inst_obmat", "data_buf[gl_InstanceID].object_to_world_");
info.define("color", "data_buf[gl_InstanceID].color_");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
curve_edit_points = shader("overlay_edit_curves_point", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
});
curve_edit_line = shader("overlay_edit_particle_strand",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
extra_point = selectable_shader("overlay_extra_point", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.vertex_inputs_.pop_last();
info.push_constants_.pop_last();
info.additional_info("draw_view", "draw_modelmat_new", "draw_globals")
.typedef_source("overlay_shader_shared.h")
.storage_buf(0, Qualifier::READ, "VertexData", "data_buf[]")
.define("pos", "data_buf[gl_VertexID].pos_.xyz")
.define("ucolor", "data_buf[gl_VertexID].color_");
});
grid_background = shader("overlay_grid_background", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.push_constant(gpu::shader::Type::VEC3, "tile_scale");
info.define("tile_pos", "vec3(0.0)");
});
grid_image = shader("overlay_grid_image", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.storage_buf(0, Qualifier::READ, "vec3", "tile_pos_buf[]")
.define("tile_pos", "tile_pos_buf[gl_InstanceID]")
.define("tile_scale", "vec3(1.0)");
;
});
legacy_curve_edit_wires = shader(
"overlay_edit_curve_wire",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
legacy_curve_edit_points = shader(
"overlay_edit_curve_point",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
mesh_analysis = shader("overlay_edit_mesh_analysis",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
mesh_edit_face = shader("overlay_edit_mesh_face", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("overlay_edit_mesh_common");
});
mesh_edit_vert = shader("overlay_edit_mesh_vert", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("overlay_edit_mesh_common");
});
mesh_edit_depth = shader("overlay_edit_mesh_depth",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
mesh_edit_skin_root = shader(
"overlay_edit_mesh_skin_root", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
/* TODO(fclem): Use correct vertex format. For now we read the format manually. */
info.storage_buf(0, Qualifier::READ, "float", "size[]", Frequency::GEOMETRY);
info.vertex_inputs_.clear();
info.define("VERTEX_PULL");
});
mesh_face_normal = shader("overlay_edit_mesh_normal", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_edit_mesh_normal_common(info);
info.define("FACE_NORMAL");
info.push_constant(gpu::shader::Type::BOOL, "hq_normals");
info.storage_buf(0, Qualifier::READ, "uint", "norAndFlag[]", Frequency::GEOMETRY);
});
mesh_face_normal_subdiv = shader(
"overlay_edit_mesh_normal", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_edit_mesh_normal_common(info);
info.define("FACE_NORMAL");
info.define("FLOAT_NORMAL");
info.storage_buf(0, Qualifier::READ, "vec4", "norAndFlag[]", Frequency::GEOMETRY);
});
mesh_loop_normal = shader("overlay_edit_mesh_normal", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_edit_mesh_normal_common(info);
info.define("LOOP_NORMAL");
info.push_constant(gpu::shader::Type::BOOL, "hq_normals");
info.storage_buf(0, Qualifier::READ, "uint", "lnor[]", Frequency::GEOMETRY);
});
mesh_loop_normal_subdiv = shader(
"overlay_edit_mesh_normal", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_edit_mesh_normal_common(info);
info.define("LOOP_NORMAL");
info.define("FLOAT_NORMAL");
info.storage_buf(0, Qualifier::READ, "vec4", "lnor[]", Frequency::GEOMETRY);
});
mesh_vert_normal = shader("overlay_edit_mesh_normal", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_edit_mesh_normal_common(info);
info.define("VERT_NORMAL");
info.storage_buf(0, Qualifier::READ, "uint", "vnor[]", Frequency::GEOMETRY);
});
outline_prepass_mesh = shader(
"overlay_outline_prepass_mesh", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("draw_object_infos_new", "overlay_outline_prepass");
});
outline_prepass_curves = shader(
"overlay_outline_prepass_curves", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("draw_hair_new", "draw_object_infos_new", "overlay_outline_prepass");
});
outline_prepass_pointcloud = shader(
"overlay_outline_prepass_pointcloud", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info(
"draw_pointcloud_new", "draw_object_infos_new", "overlay_outline_prepass");
});
outline_prepass_gpencil = shader(
"overlay_outline_prepass_gpencil", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("draw_gpencil_new", "draw_object_infos_new");
});
particle_edit_vert = shader(
"overlay_edit_particle_point",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
particle_edit_edge = shader(
"overlay_edit_particle_strand",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
paint_region_edge = shader("overlay_paint_wire", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
});
paint_region_face = shader("overlay_paint_face", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
});
paint_region_vert = shader("overlay_paint_point", [](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
});
paint_texture = shader("overlay_paint_texture",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
paint_weight = shader("overlay_paint_weight",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
paint_weight_fake_shading = shader("overlay_paint_weight",
[](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.define("FAKE_SHADING");
info.push_constant(gpu::shader::Type::VEC3, "light_dir");
});
sculpt_mesh = shader("overlay_sculpt_mask",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
sculpt_curves = shader("overlay_sculpt_curves_selection",
[](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("draw_hair_new");
});
sculpt_curves_cage = shader(
"overlay_sculpt_curves_cage",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
uv_analysis_stretch_angle = shader("overlay_edit_uv_stretching_angle",
[](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("overlay_edit_uv_stretching");
});
uv_analysis_stretch_area = shader("overlay_edit_uv_stretching_area",
[](gpu::shader::ShaderCreateInfo &info) {
shader_patch_common(info);
info.additional_info("overlay_edit_uv_stretching");
});
uv_edit_vert = shader("overlay_edit_uv_verts",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
uv_edit_face = shader("overlay_edit_uv_faces",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
uv_edit_facedot = shader("overlay_edit_uv_face_dots",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
uv_image_borders = shader("overlay_edit_uv_tiled_image_borders",
[](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.push_constant(gpu::shader::Type::VEC3, "tile_pos");
info.define("tile_scale", "vec3(1.0)");
info.additional_info("draw_view");
});
uv_brush_stencil = shader("overlay_edit_uv_stencil_image",
[](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.push_constant(gpu::shader::Type::VEC2, "brush_offset");
info.push_constant(gpu::shader::Type::VEC2, "brush_scale");
info.additional_info("draw_view");
});
uv_paint_mask = shader("overlay_edit_uv_mask_image", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.push_constant(gpu::shader::Type::VEC2, "brush_offset");
info.push_constant(gpu::shader::Type::VEC2, "brush_scale");
info.additional_info("draw_view");
});
xray_fade = shader("overlay_xray_fade", [](gpu::shader::ShaderCreateInfo &info) {
info.sampler(2, ImageType::DEPTH_2D, "xrayDepthTexInfront");
info.sampler(3, ImageType::DEPTH_2D, "depthTexInfront");
});
/** Selectable Shaders */
armature_envelope_fill = selectable_shader(
"overlay_armature_envelope_solid", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_info("draw_globals");
info.storage_buf(0, Qualifier::READ, "BoneEnvelopeData", "data_buf[]");
info.define("headSphere", "data_buf[gl_InstanceID].head_sphere");
info.define("tailSphere", "data_buf[gl_InstanceID].tail_sphere");
info.define("xAxis", "data_buf[gl_InstanceID].x_axis.xyz");
info.define("stateColor", "data_buf[gl_InstanceID].state_color.xyz");
info.define("boneColor", "data_buf[gl_InstanceID].bone_color_and_wire_width.xyz");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
armature_envelope_outline = selectable_shader(
"overlay_armature_envelope_outline", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "BoneEnvelopeData", "data_buf[]");
info.define("headSphere", "data_buf[gl_InstanceID].head_sphere");
info.define("tailSphere", "data_buf[gl_InstanceID].tail_sphere");
info.define("outlineColorSize", "data_buf[gl_InstanceID].bone_color_and_wire_width");
info.define("xAxis", "data_buf[gl_InstanceID].x_axis.xyz");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
armature_shape_outline = selectable_shader("overlay_armature_shape_outline_next",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
armature_shape_fill = selectable_shader(
"overlay_armature_shape_solid", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "mat4", "data_buf[]");
info.define("inst_obmat", "data_buf[gl_InstanceID]");
info.vertex_inputs_.pop_last();
});
armature_shape_wire = selectable_shader("overlay_armature_shape_wire_next",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
armature_sphere_outline = selectable_shader(
"overlay_armature_sphere_outline", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "mat4", "data_buf[]");
info.define("inst_obmat", "data_buf[gl_InstanceID]");
info.vertex_inputs_.pop_last();
});
armature_sphere_fill = selectable_shader(
"overlay_armature_sphere_solid", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "mat4", "data_buf[]");
info.define("inst_obmat", "data_buf[gl_InstanceID]");
info.vertex_inputs_.pop_last();
});
armature_stick = selectable_shader(
"overlay_armature_stick", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("overlay_frag_output",
"overlay_armature_common",
"draw_resource_handle_new",
"draw_modelmat_new",
"draw_globals");
info.storage_buf(0, Qualifier::READ, "BoneStickData", "data_buf[]");
info.define("boneStart", "data_buf[gl_InstanceID].bone_start.xyz");
info.define("boneEnd", "data_buf[gl_InstanceID].bone_end.xyz");
info.define("wireColor", "data_buf[gl_InstanceID].wire_color");
info.define("boneColor", "data_buf[gl_InstanceID].bone_color");
info.define("headColor", "data_buf[gl_InstanceID].head_color");
info.define("tailColor", "data_buf[gl_InstanceID].tail_color");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_in(1, gpu::shader::Type::INT, "vclass");
info.define("flag", "vclass");
});
armature_wire = selectable_shader(
"overlay_armature_wire", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_view",
"overlay_frag_output",
"draw_resource_handle_new",
"draw_modelmat_new",
"draw_globals");
info.storage_buf(0, Qualifier::READ, "VertexData", "data_buf[]");
info.define("pos", "data_buf[gl_VertexID].pos_.xyz");
info.define("color", "data_buf[gl_VertexID].color_");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
facing = shader("overlay_facing", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
fluid_grid_lines_flags = selectable_shader(
"overlay_volume_gridlines_flags", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
});
fluid_grid_lines_flat = selectable_shader(
"overlay_volume_gridlines_flat", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
});
fluid_grid_lines_range = selectable_shader(
"overlay_volume_gridlines_range", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_gridlines");
});
fluid_velocity_streamline = selectable_shader(
"overlay_volume_velocity_streamline", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
});
fluid_velocity_mac = selectable_shader(
"overlay_volume_velocity_mac", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
});
fluid_velocity_needle = selectable_shader(
"overlay_volume_velocity_needle", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("draw_volume_new", "draw_view", "overlay_volume_velocity");
});
extra_shape = selectable_shader("overlay_extra", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "ExtraInstanceData", "data_buf[]");
info.define("color", "data_buf[gl_InstanceID].color_");
info.define("inst_obmat", "data_buf[gl_InstanceID].object_to_world_");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
extra_wire = selectable_shader("overlay_extra_wire", [](gpu::shader::ShaderCreateInfo &info) {
info.typedef_source("overlay_shader_shared.h");
info.storage_buf(0, Qualifier::READ, "VertexData", "data_buf[]");
info.push_constant(gpu::shader::Type::INT, "colorid");
info.define("pos", "data_buf[gl_VertexID].pos_.xyz");
info.define("color", "data_buf[gl_VertexID].color_");
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
});
extra_wire_object = selectable_shader(
"overlay_extra_wire", [](gpu::shader::ShaderCreateInfo &info) {
info.define("OBJECT_WIRE");
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
extra_loose_points = selectable_shader(
"overlay_extra_loose_point", [](gpu::shader::ShaderCreateInfo &info) {
info.typedef_source("overlay_shader_shared.h");
info.storage_buf(0, Qualifier::READ, "VertexData", "data_buf[]");
info.define("pos", "data_buf[gl_VertexID].pos_.xyz");
info.define("vertex_color", "data_buf[gl_VertexID].color_");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.additional_infos_.clear();
info.additional_info("draw_view", "draw_modelmat_new", "draw_globals");
});
lattice_points = shader("overlay_edit_lattice_point", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
lattice_wire = shader("overlay_edit_lattice_wire", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
extra_grid = selectable_shader("overlay_extra_grid", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
extra_ground_line = selectable_shader(
"overlay_extra_groundline", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "vec4", "data_buf[]");
info.define("inst_pos", "data_buf[gl_InstanceID].xyz");
info.vertex_inputs_.pop_last();
});
image_plane = selectable_shader("overlay_image", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_globals", "draw_modelmat_new", "draw_resource_handle_new");
});
image_plane_depth_bias = selectable_shader(
"overlay_image", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_globals", "draw_modelmat_new", "draw_resource_handle_new");
info.define("DEPTH_BIAS");
info.push_constant(gpu::shader::Type::MAT4, "depth_bias_winmat");
});
light_spot_cone = shader("overlay_extra", [](gpu::shader::ShaderCreateInfo &info) {
info.storage_buf(0, Qualifier::READ, "ExtraInstanceData", "data_buf[]");
info.define("color", "data_buf[gl_InstanceID].color_");
info.define("inst_obmat", "data_buf[gl_InstanceID].object_to_world_");
info.vertex_inputs_.pop_last();
info.vertex_inputs_.pop_last();
info.define("IS_SPOT_CONE");
});
particle_dot = selectable_shader("overlay_particle_dot",
[](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info("overlay_particle",
"draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
});
particle_shape = selectable_shader("overlay_particle_shape_next",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
particle_hair = selectable_shader("overlay_particle_hair_next",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
uniform_color = shader("overlay_uniform_color", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.additional_info(
"draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals");
});
wireframe_mesh = selectable_shader("overlay_wireframe", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.define("CUSTOM_DEPTH_BIAS_CONST");
info.specialization_constant(gpu::shader::Type::BOOL, "use_custom_depth_bias", true);
info.additional_info("draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_object_infos_new",
"draw_globals");
});
wireframe_points = selectable_shader("overlay_wireframe_points",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
wireframe_curve = selectable_shader("overlay_wireframe_curve",
[](gpu::shader::ShaderCreateInfo & /*info*/) {});
}
ShaderModule &ShaderModule::module_get(SelectionType selection_type, bool clipping_enabled)
{
int selection_index = selection_type == SelectionType::DISABLED ? 0 : 1;

View File

@@ -213,14 +213,14 @@ BLI_STATIC_ASSERT_ALIGN(ThemeColorData, 16)
struct ExtraInstanceData {
float4 color_;
float4x4 object_to_world_;
float4x4 object_to_world;
#if !defined(GPU_SHADER) && defined(__cplusplus)
ExtraInstanceData(const float4x4 &object_to_world, const float4 &color, float draw_size)
{
this->color_ = color;
this->object_to_world_ = object_to_world;
this->object_to_world_[3][3] = draw_size;
this->object_to_world = object_to_world;
this->object_to_world[3][3] = draw_size;
};
ExtraInstanceData with_color(const float4 &color) const
@@ -239,11 +239,11 @@ struct ExtraInstanceData {
float angle_max_z)
{
this->color_ = color;
this->object_to_world_ = object_to_world;
this->object_to_world_[0][3] = angle_min_x;
this->object_to_world_[1][3] = angle_min_z;
this->object_to_world_[2][3] = angle_max_x;
this->object_to_world_[3][3] = angle_max_z;
this->object_to_world = object_to_world;
this->object_to_world[0][3] = angle_min_x;
this->object_to_world[1][3] = angle_min_z;
this->object_to_world[2][3] = angle_max_x;
this->object_to_world[3][3] = angle_max_z;
};
#endif
};
@@ -276,6 +276,7 @@ BLI_STATIC_ASSERT_ALIGN(ParticlePointData, 16)
struct BoneEnvelopeData {
float4 head_sphere;
float4 tail_sphere;
/* TODO(pragma37): wire width is never used in the shader. */
float4 bone_color_and_wire_width;
float4 state_color;
float4 x_axis;

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_CREATE_INFO(overlay_antialiasing)
DO_STATIC_COMPILATION()
@@ -24,4 +24,6 @@ PUSH_CONSTANT(FLOAT, opacity)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_SOURCE("overlay_xray_fade_frag.glsl")
ADDITIONAL_INFO(draw_fullscreen)
SAMPLER(2, DEPTH_2D, xrayDepthTexInfront)
SAMPLER(3, DEPTH_2D, depthTexInfront)
GPU_SHADER_CREATE_END()

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_CREATE_INFO(overlay_frag_output)
FRAGMENT_OUT(0, VEC4, fragColor)
@@ -27,21 +27,16 @@ GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC2, pos)
/* Per instance. */
VERTEX_IN(1, MAT4, inst_obmat)
VERTEX_OUT(overlay_armature_wire_iface)
VERTEX_SOURCE("overlay_armature_sphere_outline_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, mat4, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_sphere_outline)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_sphere_outline)
GPU_SHADER_INTERFACE_INFO(overlay_armature_sphere_solid_iface)
FLAT(VEC3, finalStateColor)
@@ -55,7 +50,6 @@ DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC2, pos)
/* Per instance. */
VERTEX_IN(1, VEC4, color)
VERTEX_IN(2, MAT4, inst_obmat)
DEPTH_WRITE(DepthWrite::GREATER)
VERTEX_OUT(overlay_armature_sphere_solid_iface)
VERTEX_SOURCE("overlay_armature_sphere_solid_vert.glsl")
@@ -63,14 +57,10 @@ FRAGMENT_SOURCE("overlay_armature_sphere_solid_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
DEPTH_WRITE(DepthWrite::ANY)
STORAGE_BUF(0, READ, mat4, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_sphere_solid)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_sphere_solid)
/** \} */
@@ -96,28 +86,11 @@ GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
/* Per instance. */
VERTEX_IN(3, MAT4, inst_obmat)
VERTEX_OUT(overlay_armature_shape_outline_iface)
VERTEX_OUT(overlay_armature_shape_outline_flat_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2)
GEOMETRY_OUT(overlay_armature_wire_iface)
VERTEX_SOURCE("overlay_armature_shape_outline_vert.glsl")
GEOMETRY_SOURCE("overlay_armature_shape_outline_geom.glsl")
FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_next)
DO_STATIC_COMPILATION()
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
STORAGE_BUF(1, READ, mat4, data_buf[])
PUSH_CONSTANT(IVEC2, gpu_attr_0)
VERTEX_OUT(overlay_armature_shape_outline_no_geom_iface)
VERTEX_SOURCE("overlay_armature_shape_outline_next_vert.glsl")
VERTEX_SOURCE("overlay_armature_shape_outline_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
@@ -125,11 +98,7 @@ ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_shape_outline)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_shape_outline)
GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_solid_iface)
SMOOTH(VEC4, finalColor)
@@ -141,7 +110,6 @@ DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC3, nor)
/* Per instance. */
VERTEX_IN(2, MAT4, inst_obmat)
DEPTH_WRITE(DepthWrite::GREATER)
VERTEX_OUT(overlay_armature_shape_solid_iface)
VERTEX_SOURCE("overlay_armature_shape_solid_vert.glsl")
@@ -149,70 +117,25 @@ FRAGMENT_SOURCE("overlay_armature_shape_solid_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, mat4, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_solid_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_shape_solid)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_shape_solid)
GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_next_iface)
GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_iface)
FLAT(VEC4, finalColor)
FLAT(FLOAT, wire_width)
NO_PERSPECTIVE(FLOAT, edgeCoord)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_iface, geometry_in)
FLAT(VEC4, finalColor)
FLAT(FLOAT, wire_width)
GPU_SHADER_NAMED_INTERFACE_END(geometry_in)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_geom_iface, geometry_out)
FLAT(VEC4, finalColor)
FLAT(FLOAT, wire_width)
GPU_SHADER_NAMED_INTERFACE_END(geometry_out)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_geom_noperspective_iface,
geometry_noperspective_out)
NO_PERSPECTIVE(FLOAT, edgeCoord)
GPU_SHADER_NAMED_INTERFACE_END(geometry_noperspective_out)
GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire)
DO_STATIC_COMPILATION()
PUSH_CONSTANT(BOOL, do_smooth_wire)
VERTEX_IN(0, VEC3, pos)
/* Per instance. */
VERTEX_IN(2, MAT4, inst_obmat)
VERTEX_OUT(overlay_armature_shape_wire_iface)
VERTEX_SOURCE("overlay_armature_shape_wire_vert.glsl")
GEOMETRY_OUT(overlay_armature_shape_wire_geom_iface)
GEOMETRY_OUT(overlay_armature_shape_wire_geom_noperspective_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
GEOMETRY_SOURCE("overlay_armature_shape_wire_geom.glsl")
FRAGMENT_SOURCE("overlay_armature_shape_wire_frag.glsl")
TYPEDEF_SOURCE("overlay_shader_shared.h")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_shape_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_next)
DO_STATIC_COMPILATION()
DEFINE("NO_GEOM")
PUSH_CONSTANT(BOOL, do_smooth_wire)
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
STORAGE_BUF(1, READ, mat4, data_buf[])
PUSH_CONSTANT(IVEC2, gpu_attr_0)
DEFINE_VALUE("inst_obmat", "data_buf[gl_InstanceID]")
VERTEX_OUT(overlay_armature_shape_wire_next_iface)
VERTEX_SOURCE("overlay_armature_shape_wire_next_vert.glsl")
VERTEX_OUT(overlay_armature_shape_wire_iface)
VERTEX_SOURCE("overlay_armature_shape_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_shape_wire_frag.glsl")
TYPEDEF_SOURCE("overlay_shader_shared.h")
ADDITIONAL_INFO(overlay_frag_output)
@@ -221,6 +144,8 @@ ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_shape_wire)
/** \} */
/* -------------------------------------------------------------------- */
@@ -233,24 +158,16 @@ TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC2, pos0)
VERTEX_IN(1, VEC2, pos1)
VERTEX_IN(2, VEC2, pos2)
/* Per instance. */
VERTEX_IN(3, VEC4, headSphere)
VERTEX_IN(4, VEC4, tailSphere)
VERTEX_IN(5, VEC4, outlineColorSize)
VERTEX_IN(6, VEC3, xAxis)
VERTEX_OUT(overlay_armature_wire_iface)
VERTEX_SOURCE("overlay_armature_envelope_outline_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, BoneEnvelopeData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_envelope_outline_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_envelope_outline)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_envelope_outline)
GPU_SHADER_INTERFACE_INFO(overlay_armature_envelope_solid_iface)
FLAT(VEC3, finalStateColor)
@@ -262,25 +179,17 @@ GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
/* Per instance. Assumed to be in world coordinate already. */
VERTEX_IN(1, VEC4, headSphere)
VERTEX_IN(2, VEC4, tailSphere)
VERTEX_IN(3, VEC3, xAxis)
VERTEX_IN(4, VEC3, stateColor)
VERTEX_IN(5, VEC3, boneColor)
VERTEX_OUT(overlay_armature_envelope_solid_iface)
PUSH_CONSTANT(BOOL, isDistance)
VERTEX_SOURCE("overlay_armature_envelope_solid_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_envelope_solid_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, BoneEnvelopeData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_envelope_solid)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_armature_envelope_solid)
/** \} */
@@ -294,34 +203,22 @@ FLAT(VEC4, finalWireColor)
FLAT(VEC4, finalInnerColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_stick)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_armature_stick_base)
TYPEDEF_SOURCE("overlay_shader_shared.h")
/* Bone aligned screen space. */
VERTEX_IN(0, VEC2, pos)
VERTEX_IN(1, UINT, flag)
/* Per instance. Assumed to be in world coordinate already. */
VERTEX_IN(2, VEC3, boneStart)
VERTEX_IN(3, VEC3, boneEnd)
/* alpha encode if we do wire. If 0.0 we don't. */
VERTEX_IN(4, VEC4, wireColor)
VERTEX_IN(5, VEC4, boneColor)
VERTEX_IN(6, VEC4, headColor)
VERTEX_IN(7, VEC4, tailColor)
DEFINE_VALUE("do_wire", "(wireColor.a > 0.0)")
VERTEX_IN(1, INT, vclass)
VERTEX_OUT(overlay_armature_stick_iface)
VERTEX_SOURCE("overlay_armature_stick_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_stick_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, BoneStickData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_stick_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_stick)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_armature_stick, overlay_armature_stick_base)
/** \} */
@@ -333,22 +230,16 @@ GPU_SHADER_CREATE_INFO(overlay_armature_dof)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC2, pos)
/* Per instance. Assumed to be in world coordinate already. */
VERTEX_IN(1, VEC4, color)
VERTEX_IN(2, MAT4, inst_obmat)
VERTEX_OUT(overlay_armature_wire_iface)
VERTEX_SOURCE("overlay_armature_dof_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_dof_solid_frag.glsl")
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(overlay_armature_common)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, ExtraInstanceData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_dof_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_dof)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_armature_dof)
/** \} */
@@ -356,24 +247,19 @@ GPU_SHADER_CREATE_END()
/** \name Armature Wire
* \{ */
GPU_SHADER_CREATE_INFO(overlay_armature_wire)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_armature_wire_base)
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, color)
PUSH_CONSTANT(FLOAT, alpha)
VERTEX_OUT(overlay_armature_wire_iface)
VERTEX_SOURCE("overlay_armature_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_frag_output)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, VertexData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_armature_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_armature_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_armature_wire, overlay_armature_wire_base)
/** \} */

View File

@@ -0,0 +1,53 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "gpu_shader_create_info.hh"
GPU_SHADER_CREATE_INFO(overlay_clipped)
DEFINE("OVERLAY_NEXT") /* Needed for view_clipping_lib. */
DEFINE("USE_WORLD_CLIP_PLANES")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_select)
DEFINE("SELECT_ENABLE")
DEPTH_WRITE(DepthWrite::UNCHANGED)
ADDITIONAL_INFO(select_id_patch)
GPU_SHADER_CREATE_END()
#define OVERLAY_INFO_CLIP_VARIATION(name) \
GPU_SHADER_CREATE_INFO(name##_clipped) \
DO_STATIC_COMPILATION() \
ADDITIONAL_INFO(name) \
ADDITIONAL_INFO(overlay_clipped) \
GPU_SHADER_CREATE_END()
#define OVERLAY_INFO_SELECT_VARIATION(name) \
GPU_SHADER_CREATE_INFO(name##_selectable) \
DO_STATIC_COMPILATION() \
ADDITIONAL_INFO(name) \
ADDITIONAL_INFO(overlay_select) \
GPU_SHADER_CREATE_END()
#define OVERLAY_INFO_VARIATIONS(name) \
OVERLAY_INFO_SELECT_VARIATION(name) \
OVERLAY_INFO_CLIP_VARIATION(name) \
OVERLAY_INFO_CLIP_VARIATION(name##_selectable)
#define OVERLAY_INFO_VARIATIONS_MODELMAT(name, base_info) \
GPU_SHADER_CREATE_INFO(name) \
DO_STATIC_COMPILATION() \
ADDITIONAL_INFO(base_info) \
ADDITIONAL_INFO(draw_modelmat_new) \
GPU_SHADER_CREATE_END() \
\
GPU_SHADER_CREATE_INFO(name##_selectable) \
DO_STATIC_COMPILATION() \
ADDITIONAL_INFO(base_info) \
ADDITIONAL_INFO(draw_modelmat_new_with_custom_id) \
ADDITIONAL_INFO(overlay_select) \
GPU_SHADER_CREATE_END() \
\
OVERLAY_INFO_CLIP_VARIATION(name) \
OVERLAY_INFO_CLIP_VARIATION(name##_selectable)

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_INTERFACE_INFO(overlay_edit_flat_color_iface)
FLAT(VEC4, finalColor)
@@ -39,14 +39,13 @@ VERTEX_IN(0, VEC3, pos)
PUSH_CONSTANT(FLOAT, retopologyOffset)
VERTEX_SOURCE("overlay_edit_mesh_depth_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_depth_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_depth)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_mesh_depth)
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface)
SMOOTH(VEC4, finalColor)
@@ -63,31 +62,14 @@ VERTEX_IN(2, VEC3, vnor)
VERTEX_SOURCE("overlay_edit_mesh_vert.glsl")
VERTEX_OUT(overlay_edit_mesh_vert_iface)
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert_next)
DO_STATIC_COMPILATION()
BUILTINS(BuiltinBits::POINT_SIZE)
DEFINE("VERT")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UVEC4, data)
VERTEX_IN(2, VEC3, vnor)
VERTEX_SOURCE("overlay_edit_mesh_vertex_vert.glsl")
VERTEX_OUT(overlay_edit_mesh_vert_iface)
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(overlay_edit_mesh_common)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_iface, geometry_in)
SMOOTH(VEC4, finalColor_)
SMOOTH(VEC4, finalColorOuter_)
SMOOTH(UINT, selectOverride_)
GPU_SHADER_NAMED_INTERFACE_END(geometry_in)
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_mesh_vert)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_geom_iface, geometry_out)
SMOOTH(VEC4, finalColor)
@@ -100,29 +82,10 @@ GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_geom_noperspective_iface,
NO_PERSPECTIVE(FLOAT, edgeCoord)
GPU_SHADER_NAMED_INTERFACE_END(geometry_noperspective_out)
/* TODO(pragma37): This one is not selectable? */
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge)
DO_STATIC_COMPILATION()
DEFINE("EDGE")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UVEC4, data)
VERTEX_IN(2, VEC3, vnor)
PUSH_CONSTANT(BOOL, do_smooth_wire)
VERTEX_SOURCE("overlay_edit_mesh_vert.glsl")
VERTEX_OUT(overlay_edit_mesh_edge_iface)
GEOMETRY_OUT(overlay_edit_mesh_edge_geom_iface)
GEOMETRY_OUT(overlay_edit_mesh_edge_geom_flat_iface)
GEOMETRY_OUT(overlay_edit_mesh_edge_geom_noperspective_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
GEOMETRY_SOURCE("overlay_edit_mesh_geom.glsl")
FRAGMENT_SOURCE("overlay_edit_mesh_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
/* Vertex Pull version for overlay next. */
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_next)
DO_STATIC_COMPILATION()
DEFINE("EDGE")
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
STORAGE_BUF_FREQ(1, READ, uint, vnor[], GEOMETRY)
STORAGE_BUF_FREQ(2, READ, uint, data[], GEOMETRY)
@@ -143,12 +106,6 @@ ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat)
DO_STATIC_COMPILATION()
DEFINE("FLAT")
ADDITIONAL_INFO(overlay_edit_mesh_edge)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face)
DO_STATIC_COMPILATION()
DEFINE("FACE")
@@ -157,25 +114,15 @@ VERTEX_IN(1, UVEC4, data)
VERTEX_SOURCE("overlay_edit_mesh_vert.glsl")
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_next)
DO_STATIC_COMPILATION()
DEFINE("FACE")
DEFINE_VALUE("vnor", "vec3(0.0)")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UVEC4, data)
VERTEX_SOURCE("overlay_edit_mesh_face_vert.glsl")
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(overlay_edit_mesh_common)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_mesh_face)
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot)
DO_STATIC_COMPILATION()
DEFINE("FACEDOT")
@@ -183,20 +130,6 @@ VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UVEC4, data)
VERTEX_IN(2, VEC4, norAndFlag)
DEFINE_VALUE("vnor", "norAndFlag.xyz")
VERTEX_SOURCE("overlay_edit_mesh_vert.glsl")
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot_next)
DO_STATIC_COMPILATION()
DEFINE("FACEDOT")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UVEC4, data)
VERTEX_IN(2, VEC4, norAndFlag)
DEFINE_VALUE("vnor", "norAndFlag.xyz")
VERTEX_SOURCE("overlay_edit_mesh_facedot_vert.glsl")
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
@@ -207,15 +140,8 @@ ADDITIONAL_INFO(overlay_edit_mesh_common)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal)
DO_STATIC_COMPILATION()
DEFINE("WORKAROUND_INDEX_LOAD_INCLUDE")
/* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */
PUSH_CONSTANT(IVEC2, gpu_attr_0)
PUSH_CONSTANT(IVEC2, gpu_attr_1)
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, lnor)
VERTEX_IN(2, VEC4, vnor)
VERTEX_IN(3, VEC4, norAndFlag)
SAMPLER(0, DEPTH_2D, depthTex)
PUSH_CONSTANT(FLOAT, normalSize)
PUSH_CONSTANT(FLOAT, normalScreenSize)
@@ -225,10 +151,87 @@ VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_mesh_normal_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_modelmat_instanced_attr)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_mesh_face_normal)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(gpu_index_buffer_load)
STORAGE_BUF_FREQ(1, READ, float, pos[], GEOMETRY)
DEFINE("FACE_NORMAL")
PUSH_CONSTANT(BOOL, hq_normals)
STORAGE_BUF_FREQ(0, READ, uint, norAndFlag[], GEOMETRY)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_mesh_face_normal)
GPU_SHADER_CREATE_INFO(overlay_mesh_face_normal_subdiv)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(gpu_index_buffer_load)
STORAGE_BUF_FREQ(1, READ, float, pos[], GEOMETRY)
DEFINE("FACE_NORMAL")
DEFINE("FLOAT_NORMAL")
STORAGE_BUF_FREQ(0, READ, vec4, norAndFlag[], GEOMETRY)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_mesh_face_normal_subdiv)
GPU_SHADER_CREATE_INFO(overlay_mesh_loop_normal)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(gpu_index_buffer_load)
STORAGE_BUF_FREQ(1, READ, float, pos[], GEOMETRY)
DEFINE("LOOP_NORMAL")
PUSH_CONSTANT(BOOL, hq_normals)
STORAGE_BUF_FREQ(0, READ, uint, lnor[], GEOMETRY)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_mesh_loop_normal)
GPU_SHADER_CREATE_INFO(overlay_mesh_loop_normal_subdiv)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(gpu_index_buffer_load)
STORAGE_BUF_FREQ(1, READ, float, pos[], GEOMETRY)
DEFINE("LOOP_NORMAL")
DEFINE("FLOAT_NORMAL")
STORAGE_BUF_FREQ(0, READ, vec4, lnor[], GEOMETRY)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_mesh_loop_normal_subdiv)
GPU_SHADER_CREATE_INFO(overlay_mesh_vert_normal)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(gpu_index_buffer_load)
STORAGE_BUF_FREQ(1, READ, float, pos[], GEOMETRY)
DEFINE("VERT_NORMAL")
STORAGE_BUF_FREQ(0, READ, uint, vnor[], GEOMETRY)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_mesh_vert_normal)
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_analysis_iface)
SMOOTH(VEC4, weightColor)
GPU_SHADER_INTERFACE_END()
@@ -243,69 +246,30 @@ FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_OUT(overlay_edit_mesh_analysis_iface)
VERTEX_SOURCE("overlay_edit_mesh_analysis_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_mesh_analysis_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_mesh_analysis)
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, FLOAT, size)
VERTEX_IN(2, VEC3, local_pos)
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_mesh_skin_root_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_modelmat_instanced_attr)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
/* TODO(fclem): Use correct vertex format. For now we read the format manually. */
STORAGE_BUF_FREQ(0, READ, float, size[], GEOMETRY)
DEFINE("VERTEX_PULL")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_vert)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_edge)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_edge_flat)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_face)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_facedot)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_normal)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_analysis_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_analysis)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_mesh_skin_root)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_mesh_skin_root)
/** \} */
@@ -313,68 +277,14 @@ GPU_SHADER_CREATE_END()
/** \name Edit UV
* \{ */
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_iface, geom_in)
SMOOTH(FLOAT, selectionFac)
GPU_SHADER_NAMED_INTERFACE_END(geom_in)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_flat_iface, geom_flat_in)
FLAT(VEC2, stippleStart)
GPU_SHADER_NAMED_INTERFACE_END(geom_flat_in)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_noperspective_iface, geom_noperspective_in)
NO_PERSPECTIVE(VEC2, stipplePos)
GPU_SHADER_NAMED_INTERFACE_END(geom_noperspective_in)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_iface, geom_out)
SMOOTH(FLOAT, selectionFac)
GPU_SHADER_NAMED_INTERFACE_END(geom_out)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_flat_iface, geom_flat_out)
FLAT(VEC2, stippleStart)
GPU_SHADER_NAMED_INTERFACE_END(geom_flat_out)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_noperspective_iface, geom_noperspective_out)
NO_PERSPECTIVE(FLOAT, edgeCoord)
NO_PERSPECTIVE(VEC2, stipplePos)
GPU_SHADER_NAMED_INTERFACE_END(geom_noperspective_out)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_common)
VERTEX_IN(0, VEC2, au)
VERTEX_IN(1, INT, flag)
PUSH_CONSTANT(INT, lineStyle)
PUSH_CONSTANT(BOOL, doSmoothWire)
PUSH_CONSTANT(FLOAT, alpha)
PUSH_CONSTANT(FLOAT, dashLength)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges)
ADDITIONAL_INFO(overlay_edit_uv_edges_common)
DO_STATIC_COMPILATION()
VERTEX_OUT(overlay_edit_uv_iface)
VERTEX_OUT(overlay_edit_uv_flat_iface)
VERTEX_OUT(overlay_edit_uv_noperspective_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
GEOMETRY_OUT(overlay_edit_uv_geom_iface)
GEOMETRY_OUT(overlay_edit_uv_geom_flat_iface)
GEOMETRY_OUT(overlay_edit_uv_geom_noperspective_iface)
VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl")
GEOMETRY_SOURCE("overlay_edit_uv_edges_geom.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_select)
DO_STATIC_COMPILATION()
DEFINE("USE_EDGE_SELECT")
ADDITIONAL_INFO(overlay_edit_uv_edges)
GPU_SHADER_CREATE_END()
GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_next_iface)
GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_iface)
SMOOTH(FLOAT, selectionFac)
FLAT(VEC2, stippleStart)
NO_PERSPECTIVE(FLOAT, edgeCoord)
NO_PERSPECTIVE(VEC2, stipplePos)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_next)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges)
DO_STATIC_COMPILATION()
STORAGE_BUF_FREQ(0, READ, float, au[], GEOMETRY)
STORAGE_BUF_FREQ(1, READ, uint, data[], GEOMETRY)
@@ -385,10 +295,10 @@ PUSH_CONSTANT(BOOL, doSmoothWire)
PUSH_CONSTANT(FLOAT, alpha)
PUSH_CONSTANT(FLOAT, dashLength)
SPECIALIZATION_CONSTANT(BOOL, use_edge_select, false)
VERTEX_OUT(overlay_edit_uv_next_iface)
VERTEX_OUT(overlay_edit_uv_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_edges_next_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl")
VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
@@ -405,7 +315,9 @@ VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_faces_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
@@ -418,7 +330,9 @@ VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_face_dots_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
@@ -439,7 +353,9 @@ VERTEX_OUT(overlay_edit_uv_vert_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_verts_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_verts_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
@@ -450,7 +366,9 @@ PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl")
FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
PUSH_CONSTANT(VEC3, tile_pos)
DEFINE_VALUE("tile_scale", "vec3(1.0)")
ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
GPU_SHADER_INTERFACE_INFO(edit_uv_image_iface)
@@ -468,7 +386,9 @@ PUSH_CONSTANT(BOOL, imgAlphaBlend)
PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_SOURCE("overlay_image_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
PUSH_CONSTANT(VEC2, brush_offset)
PUSH_CONSTANT(VEC2, brush_scale)
ADDITIONAL_INFO(draw_view);
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_uv_mask_image)
@@ -481,7 +401,9 @@ PUSH_CONSTANT(FLOAT, opacity)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_image_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_image_mask_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
PUSH_CONSTANT(VEC2, brush_offset)
PUSH_CONSTANT(VEC2, brush_scale)
ADDITIONAL_INFO(draw_view)
GPU_SHADER_CREATE_END()
/** \} */
@@ -505,9 +427,11 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_area)
DO_STATIC_COMPILATION()
VERTEX_IN(1, FLOAT, ratio)
PUSH_CONSTANT(FLOAT, totalAreaRatio)
ADDITIONAL_INFO(overlay_edit_uv_stretching)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(overlay_edit_uv_stretching)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_angle)
@@ -515,9 +439,11 @@ DO_STATIC_COMPILATION()
DEFINE("STRETCH_ANGLE")
VERTEX_IN(1, VEC2, uv_angles)
VERTEX_IN(2, FLOAT, angle)
ADDITIONAL_INFO(overlay_edit_uv_stretching)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(overlay_edit_uv_stretching)
GPU_SHADER_CREATE_END()
/** \} */
@@ -526,31 +452,9 @@ GPU_SHADER_CREATE_END()
/** \name Edit Curve
* \{ */
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_curve_handle_iface, vert)
FLAT(UINT, flag)
GPU_SHADER_NAMED_INTERFACE_END(vert)
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UINT, data)
VERTEX_OUT(overlay_edit_curve_handle_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10)
GEOMETRY_OUT(overlay_edit_smooth_color_iface)
PUSH_CONSTANT(BOOL, showCurveHandles)
PUSH_CONSTANT(INT, curveHandleDisplay)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curve_handle_vert.glsl")
GEOMETRY_SOURCE("overlay_edit_curve_handle_geom.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_next)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
STORAGE_BUF_FREQ(1, READ, uint, data[], GEOMETRY)
PUSH_CONSTANT(IVEC2, gpu_attr_0)
@@ -560,7 +464,7 @@ PUSH_CONSTANT(BOOL, showCurveHandles)
PUSH_CONSTANT(INT, curveHandleDisplay)
PUSH_CONSTANT(FLOAT, alpha)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curve_handle_next_vert.glsl")
VERTEX_SOURCE("overlay_edit_curve_handle_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
@@ -569,11 +473,7 @@ ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_curve_handle)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_curve_handle)
GPU_SHADER_CREATE_INFO(overlay_edit_curve_point)
DO_STATIC_COMPILATION()
@@ -586,15 +486,13 @@ PUSH_CONSTANT(INT, curveHandleDisplay)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curve_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curve_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_curve_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_curve_point)
GPU_SHADER_CREATE_INFO(overlay_edit_curve_wire)
DO_STATIC_COMPILATION()
@@ -607,16 +505,13 @@ VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curve_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_resource_id_uniform)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curve_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_curve_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_curve_wire)
GPU_SHADER_CREATE_INFO(overlay_edit_curve_normals)
DO_STATIC_COMPILATION()
@@ -647,38 +542,9 @@ GPU_SHADER_CREATE_END()
/** \name Edit Curves
* \{ */
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_curves_handle_iface, vert)
FLAT(UINT, flag)
FLAT(FLOAT, selection)
GPU_SHADER_NAMED_INTERFACE_END(vert)
GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UINT, data)
VERTEX_IN(2, FLOAT, selection)
VERTEX_OUT(overlay_edit_curves_handle_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10)
GEOMETRY_OUT(overlay_edit_smooth_color_iface)
PUSH_CONSTANT(INT, curveHandleDisplay)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curves_handle_vert.glsl")
GEOMETRY_SOURCE("overlay_edit_curves_handle_geom.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_curves_handle)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle_next)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
STORAGE_BUF_FREQ(1, READ, uint, data[], GEOMETRY)
STORAGE_BUF_FREQ(2, READ, float, selection[], GEOMETRY)
@@ -688,7 +554,7 @@ PUSH_CONSTANT(IVEC2, gpu_attr_2)
VERTEX_OUT(overlay_edit_smooth_color_iface)
PUSH_CONSTANT(INT, curveHandleDisplay)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_curves_handle_next_vert.glsl")
VERTEX_SOURCE("overlay_edit_curves_handle_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
@@ -697,6 +563,8 @@ ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_curves_handle)
GPU_SHADER_CREATE_INFO(overlay_edit_curves_point)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
@@ -717,41 +585,35 @@ PUSH_CONSTANT(INT, curveHandleDisplay)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_particle_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals);
GPU_SHADER_CREATE_INFO(overlay_edit_curves_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_curves_point)
ADDITIONAL_INFO(drw_clipped)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_curves_point)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Edit Lattice
* \{ */
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point_base)
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UINT, data)
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_lattice_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_lattice_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_edit_lattice_point, overlay_edit_lattice_point_base)
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_base)
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, FLOAT, weight)
SAMPLER(0, FLOAT_1D, weightTex)
@@ -759,15 +621,12 @@ VERTEX_OUT(overlay_edit_smooth_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_lattice_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_lattice_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_edit_lattice_wire, overlay_edit_lattice_wire_base)
/** \} */
@@ -786,15 +645,13 @@ VERTEX_OUT(overlay_edit_smooth_color_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_particle_strand_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_particle_strand)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_particle_strand)
GPU_SHADER_CREATE_INFO(overlay_edit_particle_point)
DO_STATIC_COMPILATION()
@@ -813,15 +670,13 @@ PUSH_CONSTANT(BOOL, doStrokeEndpoints)
#endif
VERTEX_SOURCE("overlay_edit_particle_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_particle_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_particle_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_edit_particle_point)
/** \} */
@@ -849,55 +704,6 @@ ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_wire)
DO_STATIC_COMPILATION()
VERTEX_OUT(overlay_edit_smooth_color_iface)
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(overlay_edit_gpencil)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_gpencil_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_point)
DO_STATIC_COMPILATION()
DEFINE("USE_POINTS")
VERTEX_OUT(overlay_edit_flat_color_iface)
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(overlay_edit_gpencil)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_gpencil_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
/* TODO(fclem): Refactor this to take list of point instead of drawing 1 point per drawcall. */
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, UINT, data)
VERTEX_OUT(overlay_edit_flat_color_iface)
PUSH_CONSTANT(VEC3, pPosition)
PUSH_CONSTANT(FLOAT, pSize)
PUSH_CONSTANT(VEC4, pColor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_gpencil_guide_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_edit_gpencil_guide_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
/** \} */
/* -------------------------------------------------------------------- */
@@ -906,44 +712,31 @@ GPU_SHADER_CREATE_END()
* Used to occlude edit geometry which might not be rendered by the render engine.
* \{ */
GPU_SHADER_CREATE_INFO(overlay_depth_only)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_SOURCE("overlay_depth_only_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_depth_only_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_depth_only)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_depth_mesh)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_depth_mesh_base)
VERTEX_IN(0, VEC3, pos)
VERTEX_SOURCE("overlay_depth_only_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_depth_mesh_conservative)
DO_STATIC_COMPILATION()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_depth_mesh, overlay_depth_mesh_base)
GPU_SHADER_CREATE_INFO(overlay_depth_mesh_conservative_base)
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
PUSH_CONSTANT(IVEC2, gpu_attr_0)
VERTEX_SOURCE("overlay_depth_only_mesh_conservative_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_depth_mesh_conservative,
overlay_depth_mesh_conservative_base)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_depth_only_gpencil_flat_iface, gp_interp_flat)
FLAT(VEC2, aspect)
FLAT(VEC4, sspos)
@@ -954,8 +747,7 @@ NO_PERSPECTIVE(VEC2, thickness)
NO_PERSPECTIVE(FLOAT, hardness)
GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective)
GPU_SHADER_CREATE_INFO(overlay_depth_gpencil)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_depth_gpencil_base)
TYPEDEF_SOURCE("gpencil_shader_shared.h")
VERTEX_OUT(overlay_depth_only_gpencil_flat_iface)
VERTEX_OUT(overlay_depth_only_gpencil_noperspective_iface)
@@ -965,35 +757,36 @@ DEPTH_WRITE(DepthWrite::ANY)
PUSH_CONSTANT(BOOL, gpStrokeOrder3d) /* TODO(fclem): Move to a GPencil object UBO. */
PUSH_CONSTANT(VEC4, gpDepthPlane) /* TODO(fclem): Move to a GPencil object UBO. */
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_gpencil_new)
ADDITIONAL_INFO(draw_object_infos_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_depth_pointcloud)
DO_STATIC_COMPILATION()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_depth_gpencil, overlay_depth_gpencil_base)
GPU_SHADER_CREATE_INFO(overlay_depth_pointcloud_base)
VERTEX_SOURCE("overlay_depth_only_pointcloud_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_pointcloud_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_depth_curves)
DO_STATIC_COMPILATION()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_depth_pointcloud, overlay_depth_pointcloud_base)
GPU_SHADER_CREATE_INFO(overlay_depth_curves_base)
VERTEX_SOURCE("overlay_depth_only_curves_vert.glsl")
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
ADDITIONAL_INFO(draw_hair_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_depth_curves, overlay_depth_curves_base)
/** \} */
/* -------------------------------------------------------------------- */
@@ -1007,28 +800,12 @@ PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_depth_only_vert.glsl")
FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_modelmat_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud)
DO_STATIC_COMPILATION()
PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_pointcloud_only_vert.glsl")
FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl")
ADDITIONAL_INFO(draw_pointcloud)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_uniform_color_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_uniform_color)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_uniform_color_pointcloud)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_uniform_color)
/** \} */

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
/* -------------------------------------------------------------------- */
/** \name Extra shapes
@@ -19,9 +19,6 @@ DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, INT, vclass)
/* Instance attributes. */
VERTEX_IN(2, VEC4, color)
VERTEX_IN(3, MAT4, inst_obmat)
VERTEX_OUT(overlay_extra_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
@@ -29,25 +26,18 @@ VERTEX_SOURCE("overlay_extra_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, ExtraInstanceData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_select)
DO_STATIC_COMPILATION()
DEFINE("SELECT_EDGES")
ADDITIONAL_INFO(overlay_extra)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_extra)
GPU_SHADER_CREATE_INFO(overlay_extra_clipped)
GPU_SHADER_CREATE_INFO(overlay_extra_spot_cone)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra)
ADDITIONAL_INFO(drw_clipped)
DEFINE("IS_SPOT_CONE")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_select_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_select)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_extra_spot_cone)
/** \} */
@@ -59,8 +49,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_extra_grid_iface)
FLAT(VEC4, finalColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_grid)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_extra_grid_base)
SAMPLER(0, DEPTH_2D, depthBuffer)
PUSH_CONSTANT(MAT4, gridModelMatrix)
PUSH_CONSTANT(BOOL, isTransform)
@@ -69,14 +58,11 @@ FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_extra_lightprobe_grid_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_grid_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_grid)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_extra_grid, overlay_extra_grid_base)
/** \} */
@@ -88,7 +74,6 @@ GPU_SHADER_CREATE_INFO(overlay_extra_groundline)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
/* Instance attributes. */
VERTEX_IN(1, VEC3, inst_pos)
VERTEX_OUT(overlay_extra_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
@@ -96,13 +81,10 @@ VERTEX_SOURCE("overlay_extra_groundline_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, vec4, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_groundline_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_groundline)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS(overlay_extra_groundline)
/** \} */
@@ -116,8 +98,25 @@ FLAT(VEC2, stipple_start)
FLAT(VEC4, finalColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_base)
VERTEX_OUT(overlay_extra_wire_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_extra_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_wire_frag.glsl")
TYPEDEF_SOURCE("overlay_shader_shared.h")
STORAGE_BUF(0, READ, VertexData, data_buf[])
PUSH_CONSTANT(INT, colorid)
DEFINE_VALUE("pos", "data_buf[gl_VertexID].pos_.xyz")
DEFINE_VALUE("color", "data_buf[gl_VertexID].color_")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_extra_wire, overlay_extra_wire_base)
GPU_SHADER_CREATE_INFO(overlay_extra_wire_object_base)
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, color)
/* If colorid is equal to 0 (i.e: Not specified) use color attribute and stippling. */
@@ -127,39 +126,13 @@ FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_extra_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_wire_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
DEFINE("OBJECT_WIRE")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_select)
DO_STATIC_COMPILATION()
DEFINE("SELECT_EDGES")
ADDITIONAL_INFO(overlay_extra_wire)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_object)
DO_STATIC_COMPILATION()
DEFINE("OBJECT_WIRE")
ADDITIONAL_INFO(overlay_extra_wire)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_select_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_wire_select)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_object_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_wire_object)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_extra_wire_object, overlay_extra_wire_object_base)
/** \} */
@@ -173,48 +146,38 @@ FLAT(VEC4, fillColor)
FLAT(VEC4, outlineColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_point)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_extra_point_base)
/* TODO(fclem): Move the vertex shader to Overlay engine and remove this bypass. */
DEFINE_VALUE("blender_srgb_to_framebuffer_space(a)", "a")
VERTEX_IN(0, VEC3, pos)
PUSH_CONSTANT(VEC4, ucolor)
VERTEX_OUT(overlay_extra_point_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_extra_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_varying_outline_aa_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
TYPEDEF_SOURCE("overlay_shader_shared.h")
STORAGE_BUF(0, READ, VertexData, data_buf[])
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_extra_point, overlay_extra_point_base)
GPU_SHADER_INTERFACE_INFO(overlay_extra_loose_point_iface)
SMOOTH(VEC4, finalColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_loose_point)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, vertex_color)
GPU_SHADER_CREATE_INFO(overlay_extra_loose_point_base)
VERTEX_OUT(overlay_extra_loose_point_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_extra_loose_point_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_loose_point_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
TYPEDEF_SOURCE("overlay_shader_shared.h")
STORAGE_BUF(0, READ, VertexData, data_buf[])
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_extra_loose_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_extra_loose_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_extra_loose_point, overlay_extra_loose_point_base)
/** \} */
@@ -225,33 +188,9 @@ GPU_SHADER_CREATE_END()
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_motion_path_line_iface, interp)
SMOOTH(VEC4, color)
GPU_SHADER_NAMED_INTERFACE_END(interp)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_motion_path_line_flat_iface, interp_flat)
FLAT(VEC2, ss_pos)
GPU_SHADER_NAMED_INTERFACE_END(interp_flat)
GPU_SHADER_CREATE_INFO(overlay_motion_path_line)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
PUSH_CONSTANT(IVEC4, mpathLineSettings)
PUSH_CONSTANT(BOOL, selected)
PUSH_CONSTANT(VEC3, customColorPre)
PUSH_CONSTANT(VEC3, customColorPost)
PUSH_CONSTANT(INT, lineThickness) /* In pixels. */
PUSH_CONSTANT(MAT4, camera_space_matrix)
VERTEX_OUT(overlay_motion_path_line_iface)
VERTEX_OUT(overlay_motion_path_line_flat_iface)
GEOMETRY_OUT(overlay_motion_path_line_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_motion_path_line_vert.glsl")
GEOMETRY_SOURCE("overlay_motion_path_line_geom.glsl")
FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_motion_path_line_next)
DO_STATIC_COMPILATION()
STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY)
PUSH_CONSTANT(IVEC2, gpu_attr_0)
PUSH_CONSTANT(IVEC4, mpathLineSettings)
@@ -262,18 +201,14 @@ PUSH_CONSTANT(INT, lineThickness) /* In pixels. */
PUSH_CONSTANT(MAT4, camera_space_matrix)
VERTEX_OUT(overlay_motion_path_line_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_motion_path_line_next_vert.glsl")
VERTEX_SOURCE("overlay_motion_path_line_vert.glsl")
FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(gpu_index_buffer_load)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_motion_path_line_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_motion_path_line)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_motion_path_line)
GPU_SHADER_INTERFACE_INFO(overlay_motion_path_point_iface)
FLAT(VEC4, finalColor)
@@ -297,11 +232,7 @@ ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_motion_path_point_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_motion_path_point)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_motion_path_point)
/** \} */
@@ -313,8 +244,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_image_iface)
SMOOTH(VEC2, uvs)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_image)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_image_base)
PUSH_CONSTANT(BOOL, depthSet)
PUSH_CONSTANT(BOOL, isCameraBackground)
PUSH_CONSTANT(BOOL, imgPremultiplied)
@@ -326,15 +256,21 @@ SAMPLER(0, FLOAT_2D, imgTexture)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_image_vert.glsl")
FRAGMENT_SOURCE("overlay_image_frag.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_image_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_image)
ADDITIONAL_INFO(drw_clipped)
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_image, overlay_image_base)
GPU_SHADER_CREATE_INFO(overlay_image_depth_bias_base)
ADDITIONAL_INFO(overlay_image_base)
DEFINE("DEPTH_BIAS")
PUSH_CONSTANT(MAT4, depth_bias_winmat)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_image_depth_bias, overlay_image_depth_bias_base)
/** \} */
/* -------------------------------------------------------------------- */
@@ -357,11 +293,7 @@ ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_gpencil_canvas)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_gpencil_canvas)
/** \} */
@@ -373,49 +305,25 @@ GPU_SHADER_INTERFACE_INFO(overlay_particle_iface)
FLAT(VEC4, finalColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_particle)
GPU_SHADER_CREATE_INFO(overlay_particle_dot_base)
SAMPLER(0, FLOAT_1D, weightTex)
PUSH_CONSTANT(VEC4, ucolor) /* Draw-size packed in alpha. */
VERTEX_IN(0, VEC3, part_pos)
VERTEX_IN(1, VEC4, part_rot)
VERTEX_IN(2, FLOAT, part_val)
VERTEX_OUT(overlay_particle_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_particle_vert.glsl")
FRAGMENT_SOURCE("overlay_particle_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_particle_dot)
DO_STATIC_COMPILATION()
DEFINE("USE_DOTS")
DEFINE_VALUE("vclass", "0")
DEFINE_VALUE("pos", "vec3(0.0)")
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
FRAGMENT_SOURCE("overlay_particle_frag.glsl")
ADDITIONAL_INFO(overlay_particle)
ADDITIONAL_INFO(draw_mesh)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_particle_dot, overlay_particle_dot_base)
GPU_SHADER_CREATE_INFO(overlay_particle_dot_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_particle_dot)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_particle_shape)
DO_STATIC_COMPILATION()
/* Instantiated Attrs. */
VERTEX_IN(3, VEC3, pos)
VERTEX_IN(4, INT, vclass)
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(overlay_particle)
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_resource_id_uniform)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_particle_shape_next)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_particle_shape_base)
TYPEDEF_SOURCE("overlay_shader_shared.h")
SAMPLER(0, FLOAT_1D, weightTex)
PUSH_CONSTANT(VEC4, ucolor) /* Draw-size packed in alpha. */
@@ -428,13 +336,13 @@ FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_particle_shape_vert.glsl")
FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_particle_hair_next)
DO_STATIC_COMPILATION()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_particle_shape, overlay_particle_shape_base)
GPU_SHADER_CREATE_INFO(overlay_particle_hair_base)
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC3, nor)
@@ -447,16 +355,11 @@ FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_particle_hair_vert.glsl")
FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_particle_shape_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_particle_shape)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_particle_hair, overlay_particle_hair_base)
/** \} */

View File

@@ -2,20 +2,16 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_CREATE_INFO(overlay_facing)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_facing_base)
VERTEX_IN(0, VEC3, pos)
VERTEX_SOURCE("overlay_facing_vert.glsl")
FRAGMENT_SOURCE("overlay_facing_frag.glsl")
FRAGMENT_OUT(0, VEC4, fragColor)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_facing_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_facing)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_facing, overlay_facing_base)

View File

@@ -9,22 +9,6 @@ GPU_SHADER_INTERFACE_INFO(overlay_grid_iface)
SMOOTH(VEC3, local_pos)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_grid)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
VERTEX_IN(0, VEC3, pos)
VERTEX_OUT(overlay_grid_iface)
FRAGMENT_OUT(0, VEC4, out_color)
SAMPLER(0, DEPTH_2D, depth_tx)
UNIFORM_BUF(3, OVERLAY_GridData, grid_buf)
PUSH_CONSTANT(VEC3, plane_axes)
PUSH_CONSTANT(INT, grid_flag)
VERTEX_SOURCE("overlay_grid_vert.glsl")
FRAGMENT_SOURCE("overlay_grid_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_grid_next)
DO_STATIC_COMPILATION()
TYPEDEF_SOURCE("overlay_shader_shared.h")
@@ -50,7 +34,12 @@ PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl")
FRAGMENT_SOURCE("overlay_grid_background_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
DEFINE_VALUE("tile_pos", "vec3(0.0)")
PUSH_CONSTANT(VEC3, tile_scale)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_grid_image)
@@ -60,5 +49,11 @@ PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl")
FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
STORAGE_BUF(0, READ, vec3, tile_pos_buf[])
DEFINE_VALUE("tile_pos", "tile_pos_buf[gl_InstanceID]")
DEFINE_VALUE("tile_scale", "vec3(1.0)");
GPU_SHADER_CREATE_END()

View File

@@ -25,17 +25,15 @@ GPU_SHADER_CREATE_INFO(overlay_outline_prepass_mesh)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_SOURCE("overlay_outline_prepass_vert.glsl")
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_resource_handle)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(overlay_outline_prepass)
ADDITIONAL_INFO(draw_object_infos)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_mesh_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass_mesh)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_outline_prepass_mesh)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_wire_iface, vert)
FLAT(VEC3, pos)
@@ -44,36 +42,20 @@ GPU_SHADER_NAMED_INTERFACE_END(vert)
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_curves)
DO_STATIC_COMPILATION()
VERTEX_SOURCE("overlay_outline_prepass_curves_vert.glsl")
ADDITIONAL_INFO(draw_hair)
ADDITIONAL_INFO(draw_resource_handle)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_hair_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(overlay_outline_prepass)
ADDITIONAL_INFO(draw_object_infos)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_curves_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass_curves)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_outline_prepass_curves)
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass)
ADDITIONAL_INFO(draw_object_infos)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_resource_handle)
VERTEX_IN(0, VEC3, pos)
DEFINE("USE_GEOM")
VERTEX_OUT(overlay_outline_prepass_wire_iface)
GEOMETRY_LAYOUT(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2)
GEOMETRY_OUT(overlay_outline_prepass_iface)
VERTEX_SOURCE("overlay_outline_prepass_vert.glsl")
GEOMETRY_SOURCE("overlay_outline_prepass_geom.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_next)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_mesh_new)
ADDITIONAL_INFO(draw_object_infos_new)
@@ -84,11 +66,7 @@ PUSH_CONSTANT(IVEC2, gpu_attr_0)
VERTEX_SOURCE("overlay_outline_prepass_wire_vert.glsl")
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass_wire)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_outline_prepass_wire)
GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_gpencil_flat_iface, gp_interp_flat)
FLAT(VEC2, aspect)
@@ -113,31 +91,29 @@ PUSH_CONSTANT(VEC4, gpDepthPlane) /* TODO(fclem): Move to a GPencil object UB
FRAGMENT_OUT(0, UINT, out_object_id)
FRAGMENT_SOURCE("overlay_outline_prepass_gpencil_frag.glsl")
DEPTH_WRITE(DepthWrite::ANY)
ADDITIONAL_INFO(draw_gpencil)
ADDITIONAL_INFO(draw_resource_handle)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_gpencil_new)
ADDITIONAL_INFO(draw_object_infos_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_gpencil_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass_gpencil)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_outline_prepass_gpencil)
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud)
DO_STATIC_COMPILATION()
VERTEX_SOURCE("overlay_outline_prepass_pointcloud_vert.glsl")
ADDITIONAL_INFO(draw_pointcloud)
ADDITIONAL_INFO(draw_resource_handle)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_pointcloud_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(overlay_outline_prepass)
ADDITIONAL_INFO(draw_object_infos)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_outline_prepass_pointcloud)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_outline_prepass_pointcloud)
/** \} */

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
/* -------------------------------------------------------------------- */
/** \name OVERLAY_shader_paint_face.
@@ -18,14 +18,13 @@ PUSH_CONSTANT(VEC4, ucolor)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_paint_face_vert.glsl")
FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_face_clipped)
ADDITIONAL_INFO(overlay_paint_face)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_face)
/** \} */
@@ -47,15 +46,13 @@ VERTEX_OUT(overlay_overlay_paint_point_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_paint_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_point_clipped)
ADDITIONAL_INFO(overlay_paint_point)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_point)
/** \} */
@@ -82,45 +79,13 @@ PUSH_CONSTANT(BOOL, maskImagePremultiplied)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_paint_texture_vert.glsl")
FRAGMENT_SOURCE("overlay_paint_texture_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_texture_clipped)
ADDITIONAL_INFO(overlay_paint_texture)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
/** \} */
/* -------------------------------------------------------------------- */
/** \name OVERLAY_shader_paint_vertcol.
*
* It should be used to draw a Vertex Paint overlay. But it is currently unreachable.
* \{ */
GPU_SHADER_INTERFACE_INFO(overlay_paint_vertcol_iface)
SMOOTH(VEC3, finalColor)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_vertcol)
DO_STATIC_COMPILATION()
VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC3, ac) /* Active color. */
VERTEX_OUT(overlay_paint_vertcol_iface)
PUSH_CONSTANT(FLOAT, opacity) /* `1.0` by default. */
PUSH_CONSTANT(BOOL, useAlphaBlend) /* `false` by default. */
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_paint_vertcol_vert.glsl")
FRAGMENT_SOURCE("overlay_paint_vertcol_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_vertcol_clipped)
ADDITIONAL_INFO(overlay_paint_vertcol)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_texture)
/** \} */
@@ -149,28 +114,22 @@ FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
VERTEX_SOURCE("overlay_paint_weight_vert.glsl")
FRAGMENT_SOURCE("overlay_paint_weight_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_weight)
GPU_SHADER_CREATE_INFO(overlay_paint_weight_fake_shading)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_paint_weight)
DEFINE("FAKE_SHADING")
PUSH_CONSTANT(VEC3, light_dir)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_weight_clipped)
ADDITIONAL_INFO(overlay_paint_weight)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_weight_fake_shading_clipped)
ADDITIONAL_INFO(overlay_paint_weight_fake_shading)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_weight_fake_shading)
/** \} */
@@ -194,14 +153,12 @@ PUSH_CONSTANT(BOOL, useSelect)
FRAGMENT_OUT(0, VEC4, fragColor)
VERTEX_SOURCE("overlay_paint_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_paint_wire_clipped)
ADDITIONAL_INFO(overlay_paint_vertcol)
ADDITIONAL_INFO(drw_clipped)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_paint_wire)
/** \} */

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_selection_iface)
SMOOTH(FLOAT, mask_weight)
@@ -17,15 +17,14 @@ VERTEX_OUT(overlay_sculpt_curves_selection_iface)
VERTEX_SOURCE("overlay_sculpt_curves_selection_vert.glsl")
FRAGMENT_SOURCE("overlay_sculpt_curves_selection_frag.glsl")
FRAGMENT_OUT(0, VEC4, out_color)
ADDITIONAL_INFO(draw_hair)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_hair_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_sculpt_curves_selection)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_sculpt_curves_selection)
GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_cage_iface)
NO_PERSPECTIVE(VEC2, edgePos)
@@ -43,13 +42,10 @@ FRAGMENT_OUT(1, VEC4, lineOutput)
PUSH_CONSTANT(FLOAT, opacity)
VERTEX_SOURCE("overlay_sculpt_curves_cage_vert.glsl")
FRAGMENT_SOURCE("overlay_extra_frag.glsl")
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_cage_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_sculpt_curves_cage)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_sculpt_curves_cage)

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_INTERFACE_INFO(overlay_sculpt_mask_iface)
FLAT(VEC3, faceset_color)
@@ -21,13 +21,10 @@ VERTEX_OUT(overlay_sculpt_mask_iface)
VERTEX_SOURCE("overlay_sculpt_mask_vert.glsl")
FRAGMENT_SOURCE("overlay_sculpt_mask_frag.glsl")
FRAGMENT_OUT(0, VEC4, fragColor)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_object_infos)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_sculpt_mask_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_sculpt_mask)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_sculpt_mask)

View File

@@ -2,7 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "gpu_shader_create_info.hh"
#include "overlay_common_info.hh"
GPU_SHADER_INTERFACE_INFO(overlay_viewer_attribute_iface)
SMOOTH(VEC4, finalColor)
@@ -22,14 +22,12 @@ VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, attribute_value)
VERTEX_OUT(overlay_viewer_attribute_iface)
ADDITIONAL_INFO(overlay_viewer_attribute_common)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_mesh_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_viewer_attribute_mesh)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_viewer_attribute_mesh)
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud)
DO_STATIC_COMPILATION()
@@ -40,14 +38,13 @@ FRAGMENT_OUT(1, VEC4, lineOutput)
SAMPLER(3, FLOAT_BUFFER, attribute_tx)
VERTEX_OUT(overlay_viewer_attribute_iface)
ADDITIONAL_INFO(overlay_viewer_attribute_common)
ADDITIONAL_INFO(draw_pointcloud)
ADDITIONAL_INFO(draw_pointcloud_new)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_viewer_attribute_pointcloud)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_viewer_attribute_pointcloud)
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve)
DO_STATIC_COMPILATION()
@@ -59,15 +56,12 @@ VERTEX_IN(0, VEC3, pos)
VERTEX_IN(1, VEC4, attribute_value)
VERTEX_OUT(overlay_viewer_attribute_iface)
ADDITIONAL_INFO(overlay_viewer_attribute_common)
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_resource_id)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_modelmat_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_viewer_attribute_curve)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_viewer_attribute_curve)
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves)
DO_STATIC_COMPILATION()
@@ -79,11 +73,10 @@ SAMPLER(1, FLOAT_BUFFER, color_tx)
PUSH_CONSTANT(BOOL, is_point_domain)
VERTEX_OUT(overlay_viewer_attribute_iface)
ADDITIONAL_INFO(overlay_viewer_attribute_common)
ADDITIONAL_INFO(draw_hair)
ADDITIONAL_INFO(draw_hair_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_globals)
ADDITIONAL_INFO(draw_modelmat_new)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_viewer_attribute_curves)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_CLIP_VARIATION(overlay_viewer_attribute_curves)

View File

@@ -36,27 +36,36 @@ GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_streamline)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_velocity)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_velocity_streamline)
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_mac)
DO_STATIC_COMPILATION()
DEFINE("USE_MAC")
PUSH_CONSTANT(BOOL, drawMACX)
PUSH_CONSTANT(BOOL, drawMACY)
PUSH_CONSTANT(BOOL, drawMACZ)
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_velocity)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_velocity_mac)
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle)
DO_STATIC_COMPILATION()
DEFINE("USE_NEEDLE")
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_velocity)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_velocity_needle)
/** \} */
/* -------------------------------------------------------------------- */
@@ -87,18 +96,24 @@ GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flat)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_gridlines)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_gridlines_flat)
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flags)
DO_STATIC_COMPILATION()
DEFINE("SHOW_FLAGS")
SAMPLER(0, UINT_3D, flagTexture)
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_gridlines)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_gridlines_flags)
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_range)
DO_STATIC_COMPILATION()
DEFINE("SHOW_RANGE")
@@ -108,8 +123,11 @@ PUSH_CONSTANT(VEC4, rangeColor)
PUSH_CONSTANT(INT, cellFilter)
SAMPLER(0, UINT_3D, flagTexture)
SAMPLER(1, FLOAT_3D, fieldTexture)
ADDITIONAL_INFO(draw_volume)
ADDITIONAL_INFO(draw_volume_new)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(overlay_volume_gridlines)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_SELECT_VARIATION(overlay_volume_gridlines_range)
/** \} */

View File

@@ -10,8 +10,7 @@ FLAT(VEC2, edgeStart)
NO_PERSPECTIVE(VEC2, edgePos)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_wireframe_base)
PUSH_CONSTANT(FLOAT, wireStepParam)
PUSH_CONSTANT(FLOAT, wireOpacity)
PUSH_CONSTANT(BOOL, useColoring)
@@ -30,13 +29,17 @@ FRAGMENT_SOURCE("overlay_wireframe_frag.glsl")
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
DEPTH_WRITE(DepthWrite::ANY)
ADDITIONAL_INFO(draw_mesh)
ADDITIONAL_INFO(draw_object_infos)
DEFINE("CUSTOM_DEPTH_BIAS_CONST")
SPECIALIZATION_CONSTANT(BOOL, use_custom_depth_bias, true)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_curve)
DO_STATIC_COMPILATION()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_wireframe, overlay_wireframe_base)
GPU_SHADER_CREATE_INFO(overlay_wireframe_curve_base)
DEFINE("CURVES")
PUSH_CONSTANT(FLOAT, wireOpacity)
PUSH_CONSTANT(BOOL, useColoring)
@@ -49,19 +52,19 @@ FRAGMENT_SOURCE("overlay_wireframe_frag.glsl")
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_wireframe_curve, overlay_wireframe_curve_base)
GPU_SHADER_INTERFACE_INFO(overlay_wireframe_points_iface)
FLAT(VEC4, finalColor)
FLAT(VEC4, finalColorInner)
GPU_SHADER_INTERFACE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_points)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_INFO(overlay_wireframe_points_base)
DEFINE("POINTS")
PUSH_CONSTANT(BOOL, useColoring)
PUSH_CONSTANT(BOOL, isTransform)
@@ -73,41 +76,12 @@ FRAGMENT_SOURCE("overlay_wireframe_frag.glsl")
FRAGMENT_OUT(0, VEC4, fragColor)
FRAGMENT_OUT(1, VEC4, lineOutput)
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)
ADDITIONAL_INFO(draw_object_infos_new)
ADDITIONAL_INFO(draw_globals)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_wireframe)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_custom_depth)
DO_STATIC_COMPILATION()
DEFINE("CUSTOM_DEPTH_BIAS")
ADDITIONAL_INFO(overlay_wireframe)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_custom_depth_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_wireframe_custom_depth)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_select)
DO_STATIC_COMPILATION()
DEFINE("SELECT_EDGES")
ADDITIONAL_INFO(overlay_wireframe)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(overlay_wireframe_select_clipped)
DO_STATIC_COMPILATION()
ADDITIONAL_INFO(overlay_wireframe_select)
ADDITIONAL_INFO(drw_clipped)
GPU_SHADER_CREATE_END()
OVERLAY_INFO_VARIATIONS_MODELMAT(overlay_wireframe_points, overlay_wireframe_points_base)
GPU_SHADER_CREATE_INFO(overlay_wireframe_uv)
DO_STATIC_COMPILATION()
@@ -119,11 +93,11 @@ DEFINE_VALUE("dashLength", "1" /* Not used by this line style */)
DEFINE_VALUE("use_edge_select", "false")
PUSH_CONSTANT(BOOL, doSmoothWire)
PUSH_CONSTANT(FLOAT, alpha)
VERTEX_OUT(overlay_edit_uv_next_iface)
VERTEX_OUT(overlay_edit_uv_iface)
FRAGMENT_OUT(0, VEC4, fragColor)
/* Note: Reuse edit mode shader as it is mostly the same. */
VERTEX_SOURCE("overlay_edit_uv_edges_next_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl")
VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat_new)
ADDITIONAL_INFO(draw_resource_handle_new)

View File

@@ -15,6 +15,7 @@ vec3 sphere_project(float ax, float az)
void main()
{
mat4 inst_obmat = data_buf[gl_InstanceID].object_to_world;
mat4 model_mat = inst_obmat;
model_mat[0][3] = model_mat[1][3] = model_mat[2][3] = 0.0;
model_mat[3][3] = 1.0;
@@ -27,7 +28,7 @@ void main()
vec3 world_pos = (model_mat * vec4(final_pos, 1.0)).xyz;
gl_Position = point_world_to_ndc(world_pos);
finalColor = color;
finalColor = data_buf[gl_InstanceID].color_;
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport;

View File

@@ -94,19 +94,19 @@ void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
float dst_head = distance(headSphere.xyz, drw_view.viewinv[3].xyz);
float dst_tail = distance(tailSphere.xyz, drw_view.viewinv[3].xyz);
// float dst_head = -dot(headSphere.xyz, drw_view.viewmat[2].xyz);
// float dst_tail = -dot(tailSphere.xyz, drw_view.viewmat[2].xyz);
float dst_head = distance(data_buf[gl_InstanceID].head_sphere.xyz, drw_view.viewinv[3].xyz);
float dst_tail = distance(data_buf[gl_InstanceID].tail_sphere.xyz, drw_view.viewinv[3].xyz);
// float dst_head = -dot(data_buf[gl_InstanceID].head_sphere.xyz, drw_view.viewmat[2].xyz);
// float dst_tail = -dot(data_buf[gl_InstanceID].tail_sphere.xyz, drw_view.viewmat[2].xyz);
vec4 sph_near, sph_far;
if ((dst_head > dst_tail) && (drw_view.winmat[3][3] == 0.0)) {
sph_near = tailSphere;
sph_far = headSphere;
sph_near = data_buf[gl_InstanceID].tail_sphere;
sph_far = data_buf[gl_InstanceID].head_sphere;
}
else {
sph_near = headSphere;
sph_far = tailSphere;
sph_near = data_buf[gl_InstanceID].head_sphere;
sph_far = data_buf[gl_InstanceID].tail_sphere;
}
vec3 bone_vec = (sph_far.xyz - sph_near.xyz) + 1e-8;
@@ -147,5 +147,5 @@ void main()
edgeStart = edgePos = proj(gl_Position);
finalColor = vec4(outlineColorSize.rgb, 1.0);
finalColor = vec4(data_buf[gl_InstanceID].bone_color_and_wire_width.rgb, 1.0);
}

View File

@@ -10,36 +10,39 @@ void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
vec3 bone_vec = tailSphere.xyz - headSphere.xyz;
vec3 bone_vec = data_buf[gl_InstanceID].tail_sphere.xyz -
data_buf[gl_InstanceID].head_sphere.xyz;
float bone_len = max(1e-8, sqrt(dot(bone_vec, bone_vec)));
float bone_lenrcp = 1.0 / bone_len;
#ifdef SMOOTH_ENVELOPE
float sinb = (tailSphere.w - headSphere.w) * bone_lenrcp;
float sinb = (data_buf[gl_InstanceID].tail_sphere.w - data_buf[gl_InstanceID].head_sphere.w) *
bone_lenrcp;
#else
const float sinb = 0.0;
#endif
vec3 y_axis = bone_vec * bone_lenrcp;
vec3 z_axis = normalize(cross(xAxis, -y_axis));
vec3 x_axis = cross(y_axis, z_axis); /* cannot trust xAxis to be orthogonal. */
vec3 z_axis = normalize(cross(data_buf[gl_InstanceID].x_axis.xyz, -y_axis));
vec3 x_axis = cross(
y_axis, z_axis); /* cannot trust data_buf[gl_InstanceID].x_axis.xyz to be orthogonal. */
vec3 sp, nor;
nor = sp = pos.xyz;
/* In bone space */
bool is_head = (pos.z < -sinb);
sp *= (is_head) ? headSphere.w : tailSphere.w;
sp *= (is_head) ? data_buf[gl_InstanceID].head_sphere.w : data_buf[gl_InstanceID].tail_sphere.w;
sp.z += (is_head) ? 0.0 : bone_len;
/* Convert to world space */
mat3 bone_mat = mat3(x_axis, y_axis, z_axis);
sp = bone_mat * sp.xzy + headSphere.xyz;
sp = bone_mat * sp.xzy + data_buf[gl_InstanceID].head_sphere.xyz;
nor = bone_mat * nor.xzy;
normalView = to_float3x3(drw_view.viewmat) * nor;
finalStateColor = stateColor;
finalBoneColor = boneColor;
finalStateColor = data_buf[gl_InstanceID].state_color.xyz;
finalBoneColor = data_buf[gl_InstanceID].state_color.xyz;
view_clipping_distances(sp);

View File

@@ -1,79 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
void main()
{
finalColor = vec4(geom_in[0].vColSize.rgb, 1.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
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);
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If one of the face is perpendicular to the view,
* consider it and outline edge. */
if (abs(fac0) > 1e-5 && abs(fac3) > 1e-5) {
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
}
}
n0 = (geom_flat_in[0].inverted == 1) ? -n0 : n0;
/* Don't outline if concave edge. */
if (dot(n0, v13) > 0.0001) {
return;
}
vec2 perp = normalize(geom_in[2].ssPos - geom_in[1].ssPos);
vec2 edge_dir = vec2(-perp.y, perp.x);
vec2 hidden_point;
/* Take the farthest point to compute edge direction
* (avoid problems with point behind near plane).
* 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 (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) ? geom_in[3].ssPos : geom_in[0].ssPos;
}
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 = geom_in[1].pPos;
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += (edge_dir - perp) * sizeViewportInv * 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;
view_clipping_distances_set(gl_in[1]);
gpu_EmitVertex();
gl_Position = geom_in[2].pPos;
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += (edge_dir + perp) * sizeViewportInv * 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;
view_clipping_distances_set(gl_in[2]);
gpu_EmitVertex();
EndPrimitive();
}

View File

@@ -1,198 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_matrix_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "select_lib.glsl"
struct VertIn {
vec3 ls_P;
mat4 inst_matrix;
};
VertIn input_assembly(uint in_vertex_id, mat4x4 inst_matrix)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.inst_matrix = inst_matrix;
return vert_in;
}
struct VertOut {
vec3 vs_P;
vec3 ws_P;
vec4 hs_P;
vec2 ss_P;
vec4 color_size;
int inverted;
};
VertOut vertex_main(VertIn v_in)
{
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(v_in.inst_matrix, state_color, bone_color);
VertOut v_out;
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.inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0);
v_out.color_size = bone_color;
return v_out;
}
void emit_vertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
vec4 color,
vec4 hs_P,
vec3 ws_P,
vec2 offset,
bool is_persp)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index != strip_index) {
return;
}
finalColor = color;
gl_Position = hs_P;
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += offset * sizeViewportInv * 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;
view_clipping_distances(ws_P);
}
void geometry_main(VertOut geom_in[4],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(geom_in[1].vs_P) : vec3(0.0, 0.0, -1.0);
vec3 v10 = geom_in[0].vs_P - geom_in[1].vs_P;
vec3 v12 = geom_in[2].vs_P - geom_in[1].vs_P;
vec3 v13 = geom_in[3].vs_P - geom_in[1].vs_P;
vec3 n0 = cross(v12, v10);
vec3 n3 = cross(v13, v12);
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If one of the face is perpendicular to the view,
* consider it and outline edge. */
if (abs(fac0) > 1e-5 && abs(fac3) > 1e-5) {
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
}
}
n0 = (geom_in[0].inverted == 1) ? -n0 : n0;
/* Don't outline if concave edge. */
if (dot(n0, v13) > 0.0001) {
return;
}
vec2 perp = normalize(geom_in[2].ss_P - geom_in[1].ss_P);
vec2 edge_dir = vec2(-perp.y, perp.x);
vec2 hidden_point;
/* Take the farthest point to compute edge direction
* (avoid problems with point behind near plane).
* 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 (geom_in[0].vs_P.z < geom_in[3].vs_P.z) {
hidden_point = (abs(fac0) > 1e-5) ? geom_in[0].ss_P : geom_in[3].ss_P;
}
else {
hidden_point = (abs(fac3) > 1e-5) ? geom_in[3].ss_P : geom_in[0].ss_P;
}
vec2 hidden_dir = normalize(hidden_point - geom_in[1].ss_P);
float fac = dot(-hidden_dir, edge_dir);
edge_dir *= (fac < 0.0) ? -1.0 : 1.0;
emit_vertex(0,
out_vertex_id,
out_primitive_id,
vec4(geom_in[0].color_size.rgb, 1.0),
geom_in[1].hs_P,
geom_in[1].ws_P,
edge_dir - perp,
is_persp);
emit_vertex(1,
out_vertex_id,
out_primitive_id,
vec4(geom_in[0].color_size.rgb, 1.0),
geom_in[2].hs_P,
geom_in[2].ws_P,
edge_dir + perp,
is_persp);
}
void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
/* Line Adjacency primitive. */
const uint input_primitive_vertex_count = 4u;
/* Line list primitive. */
const uint ouput_primitive_vertex_count = 2u;
const uint ouput_primitive_count = 1u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
mat4x4 inst_matrix = data_buf[gl_InstanceID];
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u, inst_matrix);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u, inst_matrix);
vert_in[2] = input_assembly(in_primitive_first_vertex + 2u, inst_matrix);
vert_in[3] = input_assembly(in_primitive_first_vertex + 3u, inst_matrix);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
vert_out[2] = vertex_main(vert_in[2]);
vert_out[3] = vertex_main(vert_in[3]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -3,24 +3,34 @@
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
/* project to screen space */
vec2 proj(vec4 pos)
{
return (0.5 * (pos.xy / pos.w) + 0.5) * sizeViewport.xy;
}
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_matrix_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "select_lib.glsl"
struct VertIn {
vec3 l_P;
vec3 ls_P;
mat4 inst_matrix;
};
VertIn input_assembly(uint in_vertex_id, mat4x4 inst_matrix)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.inst_matrix = inst_matrix;
return vert_in;
}
struct VertOut {
vec3 vPos;
vec4 pPos;
vec2 ssPos;
vec4 vColSize;
vec3 vs_P;
vec3 ws_P;
vec4 hs_P;
vec2 ss_P;
vec4 color_size;
int inverted;
};
@@ -29,47 +39,160 @@ VertOut vertex_main(VertIn v_in)
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(v_in.inst_matrix, state_color, bone_color);
vec4 world_pos = model_mat * vec4(v_in.l_P, 1.0);
vec4 view_pos = drw_view.viewmat * world_pos;
/* 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. */
mat3 normal_mat = transpose(inverse(to_float3x3(model_mat)));
VertOut v_out;
v_out.vPos = view_pos.xyz;
v_out.pPos = drw_view.winmat * view_pos;
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.inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0);
v_out.ssPos = proj(v_out.pPos);
v_out.vColSize = bone_color;
view_clipping_distances(world_pos.xyz);
v_out.color_size = bone_color;
return v_out;
}
#ifndef NO_GEOM
/* Legacy Path */
void main()
void emit_vertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
vec4 color,
vec4 hs_P,
vec3 ws_P,
vec2 offset,
bool is_persp)
{
VertIn v_in;
v_in.l_P = pos;
v_in.inst_matrix = inst_obmat;
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
VertOut v_out = vertex_main(v_in);
if (out_strip_index != strip_index) {
return;
}
geom_in.vPos = v_out.vPos;
geom_in.pPos = v_out.pPos;
geom_in.ssPos = v_out.ssPos;
geom_in.vColSize = v_out.vColSize;
geom_flat_in.inverted = v_out.inverted;
finalColor = color;
gl_Position = hs_P;
/* Offset away from the center to avoid overlap with solid shape. */
gl_Position.xy += offset * sizeViewportInv * 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;
view_clipping_distances(ws_P);
}
#else
void geometry_main(VertOut geom_in[4],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(geom_in[1].vs_P) : vec3(0.0, 0.0, -1.0);
vec3 v10 = geom_in[0].vs_P - geom_in[1].vs_P;
vec3 v12 = geom_in[2].vs_P - geom_in[1].vs_P;
vec3 v13 = geom_in[3].vs_P - geom_in[1].vs_P;
vec3 n0 = cross(v12, v10);
vec3 n3 = cross(v13, v12);
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If one of the face is perpendicular to the view,
* consider it and outline edge. */
if (abs(fac0) > 1e-5 && abs(fac3) > 1e-5) {
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
}
}
n0 = (geom_in[0].inverted == 1) ? -n0 : n0;
/* Don't outline if concave edge. */
if (dot(n0, v13) > 0.0001) {
return;
}
vec2 perp = normalize(geom_in[2].ss_P - geom_in[1].ss_P);
vec2 edge_dir = vec2(-perp.y, perp.x);
vec2 hidden_point;
/* Take the farthest point to compute edge direction
* (avoid problems with point behind near plane).
* 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 (geom_in[0].vs_P.z < geom_in[3].vs_P.z) {
hidden_point = (abs(fac0) > 1e-5) ? geom_in[0].ss_P : geom_in[3].ss_P;
}
else {
hidden_point = (abs(fac3) > 1e-5) ? geom_in[3].ss_P : geom_in[0].ss_P;
}
vec2 hidden_dir = normalize(hidden_point - geom_in[1].ss_P);
float fac = dot(-hidden_dir, edge_dir);
edge_dir *= (fac < 0.0) ? -1.0 : 1.0;
emit_vertex(0,
out_vertex_id,
out_primitive_id,
vec4(geom_in[0].color_size.rgb, 1.0),
geom_in[1].hs_P,
geom_in[1].ws_P,
edge_dir - perp,
is_persp);
emit_vertex(1,
out_vertex_id,
out_primitive_id,
vec4(geom_in[0].color_size.rgb, 1.0),
geom_in[2].hs_P,
geom_in[2].ws_P,
edge_dir + perp,
is_persp);
}
void main()
{
/* TODO */
}
select_id_set(in_select_buf[gl_InstanceID]);
#endif
/* Line Adjacency primitive. */
const uint input_primitive_vertex_count = 4u;
/* Line list primitive. */
const uint ouput_primitive_vertex_count = 2u;
const uint ouput_primitive_count = 1u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
mat4x4 inst_matrix = data_buf[gl_InstanceID];
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u, inst_matrix);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u, inst_matrix);
vert_in[2] = input_assembly(in_primitive_first_vertex + 2u, inst_matrix);
vert_in[3] = input_assembly(in_primitive_first_vertex + 3u, inst_matrix);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
vert_out[2] = vertex_main(vert_in[2]);
vert_out[3] = vertex_main(vert_in[3]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -11,6 +11,7 @@ void main()
select_id_set(in_select_buf[gl_InstanceID]);
vec4 bone_color, state_color;
mat4 inst_obmat = data_buf[gl_InstanceID];
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
/* This is slow and run per vertex, but it's still faster than

View File

@@ -31,12 +31,6 @@ float edge_step(float dist)
void main()
{
#ifndef NO_GEOM
float wire_width = geometry_out.wire_width;
float4 finalColor = geometry_out.finalColor;
float edgeCoord = geometry_noperspective_out.edgeCoord;
#endif
float half_size = (do_smooth_wire ? wire_width - 0.5 : wire_width) / 2.0;
float dist = abs(edgeCoord) - half_size;

View File

@@ -1,75 +0,0 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void do_vertex(vec4 color, vec4 pos, float coord, float wire_width, vec2 offset)
{
geometry_out.finalColor = color;
geometry_out.wire_width = wire_width;
geometry_noperspective_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: #62792.
* Do inline instead. */
#if 0
view_clipping_distances_set(gl_in[i]);
#endif
gpu_EmitVertex();
}
void main()
{
/* Clip line against near plane to avoid deformed lines. */
vec4 pos0 = gl_in[0].gl_Position;
vec4 pos1 = gl_in[1].gl_Position;
const vec2 pz_ndc = vec2(pos0.z / pos0.w, pos1.z / pos1.w);
const bvec2 clipped = lessThan(pz_ndc, vec2(-1.0));
if (all(clipped)) {
/* Totally clipped. */
return;
}
const vec4 pos01 = pos0 - pos1;
const float ofs = abs((pz_ndc.y + 1.0) / (pz_ndc.x - pz_ndc.y));
if (clipped.y) {
pos1 += pos01 * ofs;
}
else if (clipped.x) {
pos0 -= pos01 * (1.0 - ofs);
}
vec2 screen_space_pos[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. */
const float wire_width = geometry_in[0].wire_width * (sizeEdge * 2);
float half_size = max(wire_width / 2.0, 0.5);
if (do_smooth_wire) {
/* Add 1px for AA */
half_size += 0.5;
}
const vec2 line = (screen_space_pos[0] - screen_space_pos[1]) * sizeViewport.xy;
const vec2 line_norm = normalize(vec2(line[1], -line[0]));
vec2 edge_ofs = (half_size * line_norm) * sizeViewportInv;
/* Due to an AMD glitch, this line was moved out of the `do_vertex`
* function (see #62792). */
view_clipping_distances_set(gl_in[0]);
const vec4 final_color = geometry_in[0].finalColor;
do_vertex(final_color, pos0, half_size, wire_width, edge_ofs);
do_vertex(final_color, pos0, -half_size, wire_width, -edge_ofs);
view_clipping_distances_set(gl_in[1]);
do_vertex(final_color, pos1, half_size, wire_width, edge_ofs);
do_vertex(final_color, pos1, -half_size, wire_width, -edge_ofs);
EndPrimitive();
}

View File

@@ -1,193 +0,0 @@
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "select_lib.glsl"
struct VertIn {
vec3 lP;
mat4 inst_matrix;
};
VertIn input_assembly(uint in_vertex_id, mat4x4 inst_matrix)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.lP = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.inst_matrix = inst_matrix;
return vert_in;
}
struct VertOut {
vec4 gpu_position;
vec4 finalColor;
vec3 world_pos;
float wire_width;
};
VertOut vertex_main(VertIn v_in)
{
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(v_in.inst_matrix, state_color, bone_color);
VertOut v_out;
v_out.world_pos = (model_mat * vec4(v_in.lP, 1.0)).xyz;
v_out.gpu_position = point_world_to_ndc(v_out.world_pos);
v_out.finalColor.rgb = mix(state_color.rgb, bone_color.rgb, 0.5);
v_out.finalColor.a = 1.0;
/* Because the packing clamps the value, the wire width is passed in compressed. */
v_out.wire_width = bone_color.a * WIRE_WIDTH_COMPRESSION;
return v_out;
}
void do_vertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
vec4 color,
vec4 hs_P,
vec3 ws_P,
float coord,
vec2 offset)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index != strip_index) {
return;
}
finalColor = color;
edgeCoord = coord;
gl_Position = hs_P;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0 * hs_P.w;
view_clipping_distances(ws_P);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
/* Clip line against near plane to avoid deformed lines. */
vec4 pos0 = geom_in[0].gpu_position;
vec4 pos1 = geom_in[1].gpu_position;
vec2 pz_ndc = vec2(pos0.z / pos0.w, pos1.z / pos1.w);
bvec2 clipped = lessThan(pz_ndc, vec2(-1.0));
if (all(clipped)) {
/* Totally clipped. */
return;
}
vec4 pos01 = pos0 - pos1;
float ofs = abs((pz_ndc.y + 1.0) / (pz_ndc.x - pz_ndc.y));
if (clipped.y) {
pos1 += pos01 * ofs;
}
else if (clipped.x) {
pos0 -= pos01 * (1.0 - ofs);
}
vec2 screen_space_pos[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);
float half_size = max(wire_width / 2.0, 0.5);
if (do_smooth_wire) {
/* Add 1px for AA */
half_size += 0.5;
}
vec2 line = (screen_space_pos[0] - screen_space_pos[1]) * sizeViewport.xy;
vec2 line_norm = normalize(vec2(line[1], -line[0]));
vec2 edge_ofs = (half_size * line_norm) * sizeViewportInv;
vec4 final_color = geom_in[0].finalColor;
do_vertex(0,
out_vertex_id,
out_primitive_id,
final_color,
pos0,
geom_in[0].world_pos,
half_size,
edge_ofs);
do_vertex(1,
out_vertex_id,
out_primitive_id,
final_color,
pos0,
geom_in[0].world_pos,
-half_size,
-edge_ofs);
do_vertex(2,
out_vertex_id,
out_primitive_id,
final_color,
pos1,
geom_in[1].world_pos,
half_size,
edge_ofs);
do_vertex(3,
out_vertex_id,
out_primitive_id,
final_color,
pos1,
geom_in[1].world_pos,
-half_size,
-edge_ofs);
}
void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
/* Line primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
mat4x4 inst_matrix = inst_obmat;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u, inst_matrix);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u, inst_matrix);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -4,19 +4,191 @@
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "select_lib.glsl"
struct VertIn {
vec3 lP;
mat4 inst_matrix;
};
VertIn input_assembly(uint in_vertex_id, mat4x4 inst_matrix)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.lP = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.inst_matrix = inst_matrix;
return vert_in;
}
struct VertOut {
vec4 gpu_position;
vec4 finalColor;
vec3 world_pos;
float wire_width;
};
VertOut vertex_main(VertIn v_in)
{
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(v_in.inst_matrix, state_color, bone_color);
VertOut v_out;
v_out.world_pos = (model_mat * vec4(v_in.lP, 1.0)).xyz;
v_out.gpu_position = point_world_to_ndc(v_out.world_pos);
v_out.finalColor.rgb = mix(state_color.rgb, bone_color.rgb, 0.5);
v_out.finalColor.a = 1.0;
/* Because the packing clamps the value, the wire width is passed in compressed. */
v_out.wire_width = bone_color.a * WIRE_WIDTH_COMPRESSION;
return v_out;
}
void do_vertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
vec4 color,
vec4 hs_P,
vec3 ws_P,
float coord,
vec2 offset)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index != strip_index) {
return;
}
finalColor = color;
edgeCoord = coord;
gl_Position = hs_P;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0 * hs_P.w;
view_clipping_distances(ws_P);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
/* Clip line against near plane to avoid deformed lines. */
vec4 pos0 = geom_in[0].gpu_position;
vec4 pos1 = geom_in[1].gpu_position;
vec2 pz_ndc = vec2(pos0.z / pos0.w, pos1.z / pos1.w);
bvec2 clipped = lessThan(pz_ndc, vec2(-1.0));
if (all(clipped)) {
/* Totally clipped. */
return;
}
vec4 pos01 = pos0 - pos1;
float ofs = abs((pz_ndc.y + 1.0) / (pz_ndc.x - pz_ndc.y));
if (clipped.y) {
pos1 += pos01 * ofs;
}
else if (clipped.x) {
pos0 -= pos01 * (1.0 - ofs);
}
vec2 screen_space_pos[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);
float half_size = max(wire_width / 2.0, 0.5);
if (do_smooth_wire) {
/* Add 1px for AA */
half_size += 0.5;
}
vec2 line = (screen_space_pos[0] - screen_space_pos[1]) * sizeViewport.xy;
vec2 line_norm = normalize(vec2(line[1], -line[0]));
vec2 edge_ofs = (half_size * line_norm) * sizeViewportInv;
vec4 final_color = geom_in[0].finalColor;
do_vertex(0,
out_vertex_id,
out_primitive_id,
final_color,
pos0,
geom_in[0].world_pos,
half_size,
edge_ofs);
do_vertex(1,
out_vertex_id,
out_primitive_id,
final_color,
pos0,
geom_in[0].world_pos,
-half_size,
-edge_ofs);
do_vertex(2,
out_vertex_id,
out_primitive_id,
final_color,
pos1,
geom_in[1].world_pos,
half_size,
edge_ofs);
do_vertex(3,
out_vertex_id,
out_primitive_id,
final_color,
pos1,
geom_in[1].world_pos,
-half_size,
-edge_ofs);
}
void main()
{
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
select_id_set(in_select_buf[gl_InstanceID]);
vec3 world_pos = (model_mat * vec4(pos, 1.0)).xyz;
gl_Position = point_world_to_ndc(world_pos);
/* Line primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
geometry_in.finalColor.rgb = mix(state_color.rgb, bone_color.rgb, 0.5);
geometry_in.finalColor.a = 1.0;
/* Because the packing clamps the value, the wire width is passed in compressed. */
geometry_in.wire_width = bone_color.a * WIRE_WIDTH_COMPRESSION;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
view_clipping_distances(world_pos);
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
mat4 inst_obmat = data_buf[gl_InstanceID];
mat4x4 inst_matrix = inst_obmat;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u, inst_matrix);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u, inst_matrix);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -16,6 +16,7 @@ void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
vec4 bone_color, state_color;
mat4 inst_obmat = data_buf[gl_InstanceID];
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
mat4 model_view_matrix = drw_view.viewmat * model_mat;

View File

@@ -14,6 +14,7 @@ void main()
select_id_set(in_select_buf[gl_InstanceID]);
vec4 bone_color, state_color;
mat4 inst_obmat = data_buf[gl_InstanceID];
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
mat4 model_view_matrix = drw_view.viewmat * model_mat;

View File

@@ -17,14 +17,18 @@ void main()
{
select_id_set(in_select_buf[gl_InstanceID]);
StickBoneFlag bone_flag = StickBoneFlag(flag);
finalInnerColor = flag_test(bone_flag, COL_HEAD) ? headColor : tailColor;
finalInnerColor = flag_test(bone_flag, COL_BONE) ? boneColor : finalInnerColor;
finalWireColor = (do_wire) ? wireColor : finalInnerColor;
StickBoneFlag bone_flag = StickBoneFlag(vclass);
finalInnerColor = flag_test(bone_flag, COL_HEAD) ? data_buf[gl_InstanceID].head_color :
data_buf[gl_InstanceID].tail_color;
finalInnerColor = flag_test(bone_flag, COL_BONE) ? data_buf[gl_InstanceID].bone_color :
finalInnerColor;
finalWireColor = (data_buf[gl_InstanceID].wire_color.a > 0.0) ?
data_buf[gl_InstanceID].wire_color :
finalInnerColor;
colorFac = flag_test(bone_flag, COL_WIRE) ? 0.0 : (flag_test(bone_flag, COL_BONE) ? 1.0 : 2.0);
vec4 boneStart_4d = vec4(boneStart, 1.0);
vec4 boneEnd_4d = vec4(boneEnd, 1.0);
vec4 boneStart_4d = vec4(data_buf[gl_InstanceID].bone_start.xyz, 1.0);
vec4 boneEnd_4d = vec4(data_buf[gl_InstanceID].bone_end.xyz, 1.0);
vec4 v0 = drw_view.viewmat * boneStart_4d;
vec4 v1 = drw_view.viewmat * boneEnd_4d;
@@ -56,7 +60,7 @@ void main()
/* 2D screen aligned pos at the point */
vec2 vpos = pos.x * x_screen_vec + pos.y * y_screen_vec;
vpos *= (drw_view.winmat[3][3] == 0.0) ? h : 1.0;
vpos *= (do_wire) ? 1.0 : 0.5;
vpos *= (data_buf[gl_InstanceID].wire_color.a > 0.0) ? 1.0 : 0.5;
if (finalInnerColor.a > 0.0) {
float stick_size = sizePixel * 5.0;

View File

@@ -10,10 +10,10 @@ void main()
{
select_id_set(in_select_buf[gl_VertexID / 2]);
finalColor.rgb = color.rgb;
finalColor.rgb = data_buf[gl_VertexID].color_.rgb;
finalColor.a = 1.0;
vec3 world_pos = pos;
vec3 world_pos = data_buf[gl_VertexID].pos_.xyz;
gl_Position = point_world_to_ndc(world_pos);
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;

View File

@@ -1,119 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void output_line(vec2 offset, vec4 color)
{
finalColor = color;
gl_Position = gl_in[0].gl_Position;
gl_Position.xy += offset * gl_in[0].gl_Position.w;
view_clipping_distances_set(gl_in[0]);
gpu_EmitVertex();
gl_Position = gl_in[1].gl_Position;
gl_Position.xy += offset * gl_in[1].gl_Position.w;
view_clipping_distances_set(gl_in[1]);
gpu_EmitVertex();
}
void main()
{
vec4 v1 = gl_in[0].gl_Position;
vec4 v2 = gl_in[1].gl_Position;
uint is_active_nurb = (vert[1].flag & ACTIVE_NURB);
uint color_id = (vert[1].flag >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5u)) {
return;
}
bool edge_selected = (((vert[1].flag | vert[0].flag) & VERT_SELECTED) != 0u);
bool handle_selected = (showCurveHandles &&
(((vert[1].flag | vert[0].flag) & VERT_SELECTED_BEZT_HANDLE) != 0u));
bool is_gpencil = ((vert[1].flag & VERT_GPENCIL_BEZT_HANDLE) != 0u);
/* If handle type is only selected and the edge is not selected, don't show. */
if ((uint(curveHandleDisplay) != CURVE_HANDLE_ALL) && (!handle_selected)) {
/* Nurbs must show the handles always. */
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4u)) {
return;
}
if (is_gpencil) {
return;
}
}
vec4 inner_color;
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
}
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
}
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
}
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
}
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
}
else {
bool is_selected = (((vert[1].flag & vert[0].flag) & VERT_SELECTED) != 0u);
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0u);
if (is_u_segment) {
inner_color = (is_selected) ? colorNurbSelUline : colorNurbUline;
}
else {
inner_color = (is_selected) ? colorNurbSelVline : colorNurbVline;
}
}
vec4 outer_color = (is_active_nurb != 0u) ?
mix(colorActiveSpline,
inner_color,
0.25) /* Minimize active color bleeding on inner_color. */
:
vec4(inner_color.rgb, 0.0);
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x * sizeViewport.x) < abs(v1_2.y * sizeViewport.y)) {
offset.y = 0.0;
}
else {
offset.x = 0.0;
}
/* draw the transparent border (AA). */
if (is_active_nurb != 0u) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_line(offset * 2.0, vec4(colorActiveSpline.rgb, 0.0));
}
/* draw the outline. */
output_line(offset, outer_color);
/* draw the core of the line. */
output_line(vec2(0.0), inner_color);
/* draw the outline. */
output_line(-offset, outer_color);
/* draw the transparent border (AA). */
if (is_active_nurb != 0u) {
output_line(offset * -2.0, vec4(colorActiveSpline.rgb, 0.0));
}
EndPrimitive();
}

View File

@@ -1,220 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
struct VertIn {
/* Local Position. */
vec3 ls_P;
/* Edit Flags and Data. */
uint e_data;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.e_data = data[gpu_attr_load_index(v_i, gpu_attr_1)];
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 gpu_position;
uint flag;
};
VertOut vertex_main(VertIn vert_in)
{
VertOut vert;
vert.flag = vert_in.e_data;
vert.ws_P = point_object_to_world(vert_in.ls_P);
vert.gpu_position = point_world_to_ndc(vert.ws_P);
return vert;
}
struct GeomOut {
vec4 gpu_position;
vec3 ws_P;
vec2 offset;
vec4 color;
};
void export_vertex(GeomOut geom_out)
{
finalColor = geom_out.color;
gl_Position = geom_out.gpu_position;
gl_Position.xy += geom_out.offset * geom_out.gpu_position.w;
view_clipping_distances(geom_out.ws_P);
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void output_vertex_pair(const uint line_id,
uint out_vertex_id,
uint out_primitive_id,
VertOut geom_in[2],
vec2 offset,
vec4 color)
{
GeomOut geom_out;
geom_out.color = color;
geom_out.color.a *= alpha;
geom_out.offset = offset;
geom_out.gpu_position = geom_in[0].gpu_position;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(line_id * 2 + 0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].gpu_position;
geom_out.ws_P = geom_in[1].ws_P;
strip_EmitVertex(line_id * 2 + 1, out_vertex_id, out_primitive_id, geom_out);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec4 v1 = geom_in[0].gpu_position;
vec4 v2 = geom_in[1].gpu_position;
uint is_active_nurb = (geom_in[1].flag & ACTIVE_NURB);
uint color_id = (geom_in[1].flag >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5u)) {
return;
}
bool edge_selected = (((geom_in[1].flag | geom_in[0].flag) & VERT_SELECTED) != 0u);
bool handle_selected = (showCurveHandles && (((geom_in[1].flag | geom_in[0].flag) &
VERT_SELECTED_BEZT_HANDLE) != 0u));
bool is_gpencil = ((geom_in[1].flag & VERT_GPENCIL_BEZT_HANDLE) != 0u);
/* If handle type is only selected and the edge is not selected, don't show. */
if ((uint(curveHandleDisplay) != CURVE_HANDLE_ALL) && (!handle_selected)) {
/* Nurbs must show the handles always. */
bool is_u_segment = (((geom_in[1].flag ^ geom_in[0].flag) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4u)) {
return;
}
if (is_gpencil) {
return;
}
}
vec4 inner_color;
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
}
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
}
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
}
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
}
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
}
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;
}
else {
inner_color = (is_selected) ? colorNurbSelVline : colorNurbVline;
}
}
/* Minimize active color bleeding on inner_color. */
vec4 active_color = mix(colorActiveSpline, inner_color, 0.25);
vec4 outer_color = (is_active_nurb != 0u) ? active_color : vec4(inner_color.rgb, 0.0);
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x * sizeViewport.x) < abs(v1_2.y * sizeViewport.y)) {
offset.y = 0.0;
}
else {
offset.x = 0.0;
}
vec4 border_color = vec4(colorActiveSpline.rgb, 0.0);
/* Draw the transparent border (AA). */
if (is_active_nurb != 0u) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_vertex_pair(0, out_vertex_id, out_primitive_id, geom_in, offset * 2.0, border_color);
}
/* Draw the outline. */
output_vertex_pair(1, out_vertex_id, out_primitive_id, geom_in, offset, outer_color);
/* Draw the core of the line. */
output_vertex_pair(2, out_vertex_id, out_primitive_id, geom_in, vec2(0.0), inner_color);
/* Draw the outline. */
output_vertex_pair(3, out_vertex_id, out_primitive_id, geom_in, -offset, outer_color);
/* Draw the transparent border (AA). */
if (is_active_nurb != 0u) {
output_vertex_pair(4, out_vertex_id, out_primitive_id, geom_in, -offset * 2.0, border_color);
}
}
void main()
{
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive (emulating triangle strip). */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 8u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -1,17 +1,220 @@
/* SPDX-FileCopyrightText: 2017-2022 Blender Authors
/* SPDX-FileCopyrightText: 2018-2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
struct VertIn {
/* Local Position. */
vec3 ls_P;
/* Edit Flags and Data. */
uint e_data;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.e_data = data[gpu_attr_load_index(v_i, gpu_attr_1)];
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 gpu_position;
uint flag;
};
VertOut vertex_main(VertIn vert_in)
{
VertOut vert;
vert.flag = vert_in.e_data;
vert.ws_P = point_object_to_world(vert_in.ls_P);
vert.gpu_position = point_world_to_ndc(vert.ws_P);
return vert;
}
struct GeomOut {
vec4 gpu_position;
vec3 ws_P;
vec2 offset;
vec4 color;
};
void export_vertex(GeomOut geom_out)
{
finalColor = geom_out.color;
gl_Position = geom_out.gpu_position;
gl_Position.xy += geom_out.offset * geom_out.gpu_position.w;
view_clipping_distances(geom_out.ws_P);
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void output_vertex_pair(const uint line_id,
uint out_vertex_id,
uint out_primitive_id,
VertOut geom_in[2],
vec2 offset,
vec4 color)
{
GeomOut geom_out;
geom_out.color = color;
geom_out.color.a *= alpha;
geom_out.offset = offset;
geom_out.gpu_position = geom_in[0].gpu_position;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(line_id * 2 + 0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].gpu_position;
geom_out.ws_P = geom_in[1].ws_P;
strip_EmitVertex(line_id * 2 + 1, out_vertex_id, out_primitive_id, geom_out);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec4 v1 = geom_in[0].gpu_position;
vec4 v2 = geom_in[1].gpu_position;
uint is_active_nurb = (geom_in[1].flag & ACTIVE_NURB);
uint color_id = (geom_in[1].flag >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5u)) {
return;
}
bool edge_selected = (((geom_in[1].flag | geom_in[0].flag) & VERT_SELECTED) != 0u);
bool handle_selected = (showCurveHandles && (((geom_in[1].flag | geom_in[0].flag) &
VERT_SELECTED_BEZT_HANDLE) != 0u));
bool is_gpencil = ((geom_in[1].flag & VERT_GPENCIL_BEZT_HANDLE) != 0u);
/* If handle type is only selected and the edge is not selected, don't show. */
if ((uint(curveHandleDisplay) != CURVE_HANDLE_ALL) && (!handle_selected)) {
/* Nurbs must show the handles always. */
bool is_u_segment = (((geom_in[1].flag ^ geom_in[0].flag) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4u)) {
return;
}
if (is_gpencil) {
return;
}
}
vec4 inner_color;
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
}
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
}
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
}
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
}
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
}
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;
}
else {
inner_color = (is_selected) ? colorNurbSelVline : colorNurbVline;
}
}
/* Minimize active color bleeding on inner_color. */
vec4 active_color = mix(colorActiveSpline, inner_color, 0.25);
vec4 outer_color = (is_active_nurb != 0u) ? active_color : vec4(inner_color.rgb, 0.0);
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x * sizeViewport.x) < abs(v1_2.y * sizeViewport.y)) {
offset.y = 0.0;
}
else {
offset.x = 0.0;
}
vec4 border_color = vec4(colorActiveSpline.rgb, 0.0);
/* Draw the transparent border (AA). */
if (is_active_nurb != 0u) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_vertex_pair(0, out_vertex_id, out_primitive_id, geom_in, offset * 2.0, border_color);
}
/* Draw the outline. */
output_vertex_pair(1, out_vertex_id, out_primitive_id, geom_in, offset, outer_color);
/* Draw the core of the line. */
output_vertex_pair(2, out_vertex_id, out_primitive_id, geom_in, vec2(0.0), inner_color);
/* Draw the outline. */
output_vertex_pair(3, out_vertex_id, out_primitive_id, geom_in, -offset, outer_color);
/* Draw the transparent border (AA). */
if (is_active_nurb != 0u) {
output_vertex_pair(4, out_vertex_id, out_primitive_id, geom_in, -offset * 2.0, border_color);
}
}
void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive (emulating triangle strip). */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 8u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
vert.flag = data;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
view_clipping_distances(world_pos);
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -1,132 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_math_lib.glsl"
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#define M_TAN_PI_BY_8 tan(M_PI / 8)
#define M_TAN_3_PI_BY_8 tan(3 * M_PI / 8)
#define M_SQRT2_BY_2 (M_SQRT2 / 2)
float4 get_bezier_handle_color(uint color_id, float sel)
{
switch (color_id) {
case 0u: /* BEZIER_HANDLE_FREE */
return mix(globalsBlock.color_handle_free, globalsBlock.color_handle_sel_free, sel);
case 1u: /* BEZIER_HANDLE_AUTO */
return mix(globalsBlock.color_handle_auto, globalsBlock.color_handle_sel_auto, sel);
case 2u: /* BEZIER_HANDLE_VECTOR */
return mix(globalsBlock.color_handle_vect, globalsBlock.color_handle_sel_vect, sel);
case 3u: /* BEZIER_HANDLE_ALIGN */
return mix(globalsBlock.color_handle_align, globalsBlock.color_handle_sel_align, sel);
}
return mix(globalsBlock.color_handle_autoclamp, globalsBlock.color_handle_sel_autoclamp, sel);
}
void output_line(vec2 offset, vec4 color_start, vec4 color_end)
{
finalColor = color_start;
gl_Position = gl_in[0].gl_Position;
gl_Position.xy += offset * gl_in[0].gl_Position.w;
view_clipping_distances_set(gl_in[0]);
gpu_EmitVertex();
finalColor = color_end;
gl_Position = gl_in[1].gl_Position;
gl_Position.xy += offset * gl_in[1].gl_Position.w;
view_clipping_distances_set(gl_in[1]);
gpu_EmitVertex();
}
void main()
{
vec4 v1 = gl_in[0].gl_Position;
vec4 v2 = gl_in[1].gl_Position;
bool is_active = (vert[0].flag & EDIT_CURVES_ACTIVE_HANDLE) != 0u;
uint color_id = uint(vert[0].flag >> EDIT_CURVES_HANDLE_TYPES_SHIFT) & 7;
bool is_bezier_handle = (vert[0].flag & EDIT_CURVES_BEZIER_HANDLE) != 0;
/* Don't output any edges if we don't show handles */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_NONE) && is_bezier_handle) {
return;
}
/* If handle type is only selected and the edge is not selected, don't show.
* Nurbs and other curves must show the handles always. */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_SELECTED) && is_bezier_handle && !is_active) {
return;
}
vec4 inner_color[2];
if ((vert[0].flag & (EDIT_CURVES_BEZIER_HANDLE | EDIT_CURVES_BEZIER_KNOT)) != 0u) {
inner_color[0] = get_bezier_handle_color(color_id, vert[0].selection);
inner_color[1] = get_bezier_handle_color(color_id, vert[1].selection);
}
else if ((vert[0].flag & EDIT_CURVES_NURBS_CONTROL_POINT) != 0u) {
inner_color[0] = mix(
globalsBlock.color_nurb_uline, globalsBlock.color_nurb_sel_uline, vert[0].selection);
inner_color[1] = mix(
globalsBlock.color_nurb_uline, globalsBlock.color_nurb_sel_uline, vert[1].selection);
}
else {
inner_color[0] = mix(
globalsBlock.color_wire, globalsBlock.color_vertex_select, vert[0].selection);
inner_color[1] = mix(
globalsBlock.color_wire, globalsBlock.color_vertex_select, vert[1].selection);
}
vec4 outer_color[2];
if (is_active) {
outer_color[0] = mix(colorActiveSpline,
inner_color[0],
0.25); /* Minimize active color bleeding on inner_color. */
outer_color[1] = mix(colorActiveSpline,
inner_color[1],
0.25); /* Minimize active color bleeding on inner_color. */
}
else {
outer_color[0] = vec4(inner_color[0].rgb, 0.0);
outer_color[1] = vec4(inner_color[1].rgb, 0.0);
}
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w) * sizeViewport;
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x) <= M_TAN_PI_BY_8 * abs(v1_2.y)) {
offset.y = 0.0;
}
else if (abs(v1_2.x) <= M_TAN_3_PI_BY_8 * abs(v1_2.y)) {
offset = offset * vec2(-M_SQRT2_BY_2 * sign(v1_2.x), M_SQRT2_BY_2 * sign(v1_2.y));
}
else {
offset.x = 0.0;
}
/* draw the transparent border (AA). */
if (is_active) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_line(offset * 2.0, vec4(colorActiveSpline.rgb, 0.0), vec4(colorActiveSpline.rgb, 0.0));
}
/* draw the outline. */
output_line(offset, outer_color[0], outer_color[1]);
/* draw the core of the line. */
output_line(vec2(0.0), inner_color[0], inner_color[1]);
/* draw the outline. */
output_line(-offset, outer_color[0], outer_color[1]);
/* draw the transparent border (AA). */
if (is_active) {
output_line(offset * -2.0, vec4(colorActiveSpline.rgb, 0.0), vec4(colorActiveSpline.rgb, 0.0));
}
EndPrimitive();
}

View File

@@ -1,229 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_base_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#define M_TAN_PI_BY_8 tan(M_PI / 8)
#define M_TAN_3_PI_BY_8 tan(3 * M_PI / 8)
#define M_SQRT2_BY_2 (M_SQRT2 / 2)
struct VertIn {
/* Local Position. */
vec3 ls_P;
/* Edit Flags and Data. */
uint e_data;
float sel;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.e_data = data[gpu_attr_load_index(v_i, gpu_attr_1)];
vert_in.sel = selection[gpu_attr_load_index(v_i, gpu_attr_2)];
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 gpu_position;
uint flag;
float sel;
};
VertOut vertex_main(VertIn vert_in)
{
VertOut vert;
vert.flag = vert_in.e_data;
vert.ws_P = point_object_to_world(vert_in.ls_P);
vert.gpu_position = point_world_to_ndc(vert.ws_P);
vert.sel = vert_in.sel;
return vert;
}
struct GeomOut {
vec4 gpu_position;
vec3 ws_P;
vec2 offset;
vec4 color;
};
void export_vertex(GeomOut geom_out)
{
finalColor = geom_out.color;
gl_Position = geom_out.gpu_position;
gl_Position.xy += geom_out.offset * geom_out.gpu_position.w;
view_clipping_distances(geom_out.ws_P);
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void output_vertex_pair(const uint line_id,
uint out_vertex_id,
uint out_primitive_id,
VertOut geom_in[2],
vec2 offset,
vec4 color)
{
GeomOut geom_out;
geom_out.color = color;
geom_out.offset = offset;
geom_out.gpu_position = geom_in[0].gpu_position;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(line_id * 2 + 0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].gpu_position;
geom_out.ws_P = geom_in[1].ws_P;
strip_EmitVertex(line_id * 2 + 1, out_vertex_id, out_primitive_id, geom_out);
}
float4 get_bezier_handle_color(uint color_id, float sel)
{
switch (color_id) {
case 0u: /* BEZIER_HANDLE_FREE */
return mix(globalsBlock.color_handle_free, globalsBlock.color_handle_sel_free, sel);
case 1u: /* BEZIER_HANDLE_AUTO */
return mix(globalsBlock.color_handle_auto, globalsBlock.color_handle_sel_auto, sel);
case 2u: /* BEZIER_HANDLE_VECTOR */
return mix(globalsBlock.color_handle_vect, globalsBlock.color_handle_sel_vect, sel);
case 3u: /* BEZIER_HANDLE_ALIGN */
return mix(globalsBlock.color_handle_align, globalsBlock.color_handle_sel_align, sel);
}
return mix(globalsBlock.color_handle_autoclamp, globalsBlock.color_handle_sel_autoclamp, sel);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec4 v1 = geom_in[0].gpu_position;
vec4 v2 = geom_in[1].gpu_position;
bool is_active = (geom_in[0].flag & EDIT_CURVES_ACTIVE_HANDLE) != 0u;
uint color_id = (geom_in[0].flag >> EDIT_CURVES_HANDLE_TYPES_SHIFT) & 7u;
bool is_bezier_handle = (geom_in[0].flag & EDIT_CURVES_BEZIER_HANDLE) != 0;
/* Don't output any edges if we don't show handles */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_NONE) && is_bezier_handle) {
return;
}
/* If handle type is only selected and the edge is not selected, don't show.
* Nurbs and other curves must show the handles always. */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_SELECTED) && is_bezier_handle && !is_active) {
return;
}
bool is_odd_vertex = (out_vertex_id & 1u) != 0u;
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
uint line_end_point = (is_odd_primitive && !is_odd_vertex) ||
(!is_odd_primitive && is_odd_vertex) ?
1 :
0;
vec4 inner_color;
if ((geom_in[line_end_point].flag & (EDIT_CURVES_BEZIER_HANDLE | EDIT_CURVES_BEZIER_KNOT)) != 0u)
{
inner_color = get_bezier_handle_color(color_id, geom_in[line_end_point].sel);
}
else if ((geom_in[line_end_point].flag & EDIT_CURVES_NURBS_CONTROL_POINT) != 0u) {
inner_color = mix(globalsBlock.color_nurb_uline,
globalsBlock.color_nurb_sel_uline,
geom_in[line_end_point].sel);
}
else {
inner_color = mix(
globalsBlock.color_wire, globalsBlock.color_vertex_select, geom_in[line_end_point].sel);
}
/* Minimize active color bleeding on inner_color. */
vec4 active_color = mix(colorActiveSpline, inner_color, 0.25);
vec4 outer_color = is_active ? active_color : vec4(inner_color.rgb, 0.0);
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x) <= M_TAN_PI_BY_8 * abs(v1_2.y)) {
offset.y = 0.0;
}
else if (abs(v1_2.x) <= M_TAN_3_PI_BY_8 * abs(v1_2.y)) {
offset = offset * vec2(-M_SQRT2_BY_2 * sign(v1_2.x), M_SQRT2_BY_2 * sign(v1_2.y));
}
else {
offset.x = 0.0;
}
vec4 border_color = vec4(colorActiveSpline.rgb, 0.0);
/* Draw the transparent border (AA). */
if (is_active) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_vertex_pair(0, out_vertex_id, out_primitive_id, geom_in, offset * 2.0, border_color);
}
/* Draw the outline. */
output_vertex_pair(1, out_vertex_id, out_primitive_id, geom_in, offset, outer_color);
/* Draw the core of the line. */
output_vertex_pair(2, out_vertex_id, out_primitive_id, geom_in, vec2(0.0), inner_color);
/* Draw the outline. */
output_vertex_pair(3, out_vertex_id, out_primitive_id, geom_in, -offset, outer_color);
/* Draw the transparent border (AA). */
if (is_active) {
output_vertex_pair(4, out_vertex_id, out_primitive_id, geom_in, -offset * 2.0, border_color);
}
}
void main()
{
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive (emulating triangle strip). */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 8u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -1,18 +1,229 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
/* SPDX-FileCopyrightText: 2018-2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_base_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#define M_TAN_PI_BY_8 tan(M_PI / 8)
#define M_TAN_3_PI_BY_8 tan(3 * M_PI / 8)
#define M_SQRT2_BY_2 (M_SQRT2 / 2)
struct VertIn {
/* Local Position. */
vec3 ls_P;
/* Edit Flags and Data. */
uint e_data;
float sel;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.ls_P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.e_data = data[gpu_attr_load_index(v_i, gpu_attr_1)];
vert_in.sel = selection[gpu_attr_load_index(v_i, gpu_attr_2)];
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 gpu_position;
uint flag;
float sel;
};
VertOut vertex_main(VertIn vert_in)
{
VertOut vert;
vert.flag = vert_in.e_data;
vert.ws_P = point_object_to_world(vert_in.ls_P);
vert.gpu_position = point_world_to_ndc(vert.ws_P);
vert.sel = vert_in.sel;
return vert;
}
struct GeomOut {
vec4 gpu_position;
vec3 ws_P;
vec2 offset;
vec4 color;
};
void export_vertex(GeomOut geom_out)
{
finalColor = geom_out.color;
gl_Position = geom_out.gpu_position;
gl_Position.xy += geom_out.offset * geom_out.gpu_position.w;
view_clipping_distances(geom_out.ws_P);
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void output_vertex_pair(const uint line_id,
uint out_vertex_id,
uint out_primitive_id,
VertOut geom_in[2],
vec2 offset,
vec4 color)
{
GeomOut geom_out;
geom_out.color = color;
geom_out.offset = offset;
geom_out.gpu_position = geom_in[0].gpu_position;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(line_id * 2 + 0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].gpu_position;
geom_out.ws_P = geom_in[1].ws_P;
strip_EmitVertex(line_id * 2 + 1, out_vertex_id, out_primitive_id, geom_out);
}
float4 get_bezier_handle_color(uint color_id, float sel)
{
switch (color_id) {
case 0u: /* BEZIER_HANDLE_FREE */
return mix(globalsBlock.color_handle_free, globalsBlock.color_handle_sel_free, sel);
case 1u: /* BEZIER_HANDLE_AUTO */
return mix(globalsBlock.color_handle_auto, globalsBlock.color_handle_sel_auto, sel);
case 2u: /* BEZIER_HANDLE_VECTOR */
return mix(globalsBlock.color_handle_vect, globalsBlock.color_handle_sel_vect, sel);
case 3u: /* BEZIER_HANDLE_ALIGN */
return mix(globalsBlock.color_handle_align, globalsBlock.color_handle_sel_align, sel);
}
return mix(globalsBlock.color_handle_autoclamp, globalsBlock.color_handle_sel_autoclamp, sel);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec4 v1 = geom_in[0].gpu_position;
vec4 v2 = geom_in[1].gpu_position;
bool is_active = (geom_in[0].flag & EDIT_CURVES_ACTIVE_HANDLE) != 0u;
uint color_id = (geom_in[0].flag >> EDIT_CURVES_HANDLE_TYPES_SHIFT) & 7u;
bool is_bezier_handle = (geom_in[0].flag & EDIT_CURVES_BEZIER_HANDLE) != 0;
/* Don't output any edges if we don't show handles */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_NONE) && is_bezier_handle) {
return;
}
/* If handle type is only selected and the edge is not selected, don't show.
* Nurbs and other curves must show the handles always. */
if ((uint(curveHandleDisplay) == CURVE_HANDLE_SELECTED) && is_bezier_handle && !is_active) {
return;
}
bool is_odd_vertex = (out_vertex_id & 1u) != 0u;
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
uint line_end_point = (is_odd_primitive && !is_odd_vertex) ||
(!is_odd_primitive && is_odd_vertex) ?
1 :
0;
vec4 inner_color;
if ((geom_in[line_end_point].flag & (EDIT_CURVES_BEZIER_HANDLE | EDIT_CURVES_BEZIER_KNOT)) != 0u)
{
inner_color = get_bezier_handle_color(color_id, geom_in[line_end_point].sel);
}
else if ((geom_in[line_end_point].flag & EDIT_CURVES_NURBS_CONTROL_POINT) != 0u) {
inner_color = mix(globalsBlock.color_nurb_uline,
globalsBlock.color_nurb_sel_uline,
geom_in[line_end_point].sel);
}
else {
inner_color = mix(
globalsBlock.color_wire, globalsBlock.color_vertex_select, geom_in[line_end_point].sel);
}
/* Minimize active color bleeding on inner_color. */
vec4 active_color = mix(colorActiveSpline, inner_color, 0.25);
vec4 outer_color = is_active ? active_color : vec4(inner_color.rgb, 0.0);
vec2 v1_2 = (v2.xy / v2.w - v1.xy / v1.w);
vec2 offset = sizeEdge * 4.0 * sizeViewportInv; /* 4.0 is eyeballed */
if (abs(v1_2.x) <= M_TAN_PI_BY_8 * abs(v1_2.y)) {
offset.y = 0.0;
}
else if (abs(v1_2.x) <= M_TAN_3_PI_BY_8 * abs(v1_2.y)) {
offset = offset * vec2(-M_SQRT2_BY_2 * sign(v1_2.x), M_SQRT2_BY_2 * sign(v1_2.y));
}
else {
offset.x = 0.0;
}
vec4 border_color = vec4(colorActiveSpline.rgb, 0.0);
/* Draw the transparent border (AA). */
if (is_active) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_vertex_pair(0, out_vertex_id, out_primitive_id, geom_in, offset * 2.0, border_color);
}
/* Draw the outline. */
output_vertex_pair(1, out_vertex_id, out_primitive_id, geom_in, offset, outer_color);
/* Draw the core of the line. */
output_vertex_pair(2, out_vertex_id, out_primitive_id, geom_in, vec2(0.0), inner_color);
/* Draw the outline. */
output_vertex_pair(3, out_vertex_id, out_primitive_id, geom_in, -offset, outer_color);
/* Draw the transparent border (AA). */
if (is_active) {
output_vertex_pair(4, out_vertex_id, out_primitive_id, geom_in, -offset * 2.0, border_color);
}
}
void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive (emulating triangle strip). */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 8u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
vert.flag = data;
vert.selection = selection;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
view_clipping_distances(world_pos);
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -1,17 +0,0 @@
/* SPDX-FileCopyrightText: 2020-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
gl_Position = point_world_to_ndc(pPosition);
finalColor = pColor;
gl_PointSize = pSize;
view_clipping_distances(pPosition);
}

View File

@@ -1,80 +0,0 @@
/* SPDX-FileCopyrightText: 2019-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void do_vertex(vec4 color, vec4 pos, float coord, vec2 offset)
{
geometry_out.finalColor = color;
geometry_noperspective_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: #62792.
* Do inline instead. */
#if 0
view_clipping_distances_set(gl_in[i]);
#endif
gpu_EmitVertex();
}
void main()
{
vec2 ss_pos[2];
/* Clip line against near plane to avoid deformed lines. */
vec4 pos0 = gl_in[0].gl_Position;
vec4 pos1 = gl_in[1].gl_Position;
vec2 pz_ndc = vec2(pos0.z / pos0.w, pos1.z / pos1.w);
bvec2 clipped = lessThan(pz_ndc, vec2(-1.0));
if (all(clipped)) {
/* Totally clipped. */
return;
}
vec4 pos01 = pos0 - pos1;
float ofs = abs((pz_ndc.y + 1.0) / (pz_ndc.x - pz_ndc.y));
if (clipped.y) {
pos1 += pos01 * ofs;
}
else if (clipped.x) {
pos0 -= pos01 * (1.0 - ofs);
}
ss_pos[0] = pos0.xy / pos0.w;
ss_pos[1] = pos1.xy / pos1.w;
vec2 line = ss_pos[0] - ss_pos[1];
line = abs(line) * sizeViewport.xy;
geometry_flat_out.finalColorOuter = geometry_in[0].finalColorOuter_;
float half_size = sizeEdge;
/* Enlarge edge for flag display. */
half_size += (geometry_flat_out.finalColorOuter.a > 0.0) ? max(sizeEdge, 1.0) : 0.0;
if (do_smooth_wire) {
/* Add 1px for AA */
half_size += 0.5;
}
vec3 edge_ofs = vec3(half_size * sizeViewportInv, 0.0);
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;
/* Due to an AMD glitch, this line was moved out of the `do_vertex`
* function (see #62792). */
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);
view_clipping_distances_set(gl_in[1]);
vec4 final_color = (geometry_in[0].selectOverride_ == 0u) ? 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);
EndPrimitive();
}

View File

@@ -21,38 +21,39 @@ void main()
vec4 inner_color = vec4(vec3(0.0), 1.0);
vec4 outer_color = vec4(0.0);
vec2 dd = fwidth(geom_noperspective_out.stipplePos);
float line_distance = distance(geom_noperspective_out.stipplePos, geom_flat_out.stippleStart) /
max(dd.x, dd.y);
vec2 dd = fwidth(stipplePos);
float line_distance = distance(stipplePos, stippleStart) / max(dd.x, dd.y);
if (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) {
#ifdef USE_EDGE_SELECT
/* 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 = (geom_out.selectionFac != 0.0) ? colorEdgeSelect : (colorWireEdit * 0.5);
#else
inner_color = mix(colorWireEdit, colorEdgeSelect, geom_out.selectionFac);
#endif
if (use_edge_select) {
/* 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 = (selectionFac != 0.0) ? colorEdgeSelect : (colorWireEdit * 0.5);
}
else {
inner_color = mix(colorWireEdit, colorEdgeSelect, selectionFac);
}
outer_color = vec4(vec3(0.0), 1.0);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_DASH) {
if (fract(line_distance / dashLength) < 0.5) {
inner_color = mix(vec4(vec3(0.35), 1.0), colorEdgeSelect, geom_out.selectionFac);
inner_color = mix(vec4(vec3(0.35), 1.0), colorEdgeSelect, selectionFac);
}
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_BLACK) {
vec4 base_color = vec4(vec3(0.0), 1.0);
inner_color = mix(base_color, colorEdgeSelect, geom_out.selectionFac);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_WHITE) {
vec4 base_color = vec4(1.0);
inner_color = mix(base_color, colorEdgeSelect, geom_out.selectionFac);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_SHADOW) {
inner_color = colorUVShadow;
}
float dist = abs(geom_noperspective_out.edgeCoord) - max(sizeEdge - 0.5, 0.0);
float dist = abs(edgeCoord) - max(sizeEdge - 0.5, 0.0);
float dist_outer = dist - max(sizeEdge, 1.0);
float mix_w;
float mix_w_outer;

View File

@@ -1,77 +0,0 @@
/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "overlay_common_lib.glsl"
void do_vertex(
vec4 pos, float selection_fac, vec2 stipple_start, vec2 stipple_pos, float coord, vec2 offset)
{
geom_out.selectionFac = selection_fac;
geom_noperspective_out.edgeCoord = coord;
geom_flat_out.stippleStart = stipple_start;
geom_noperspective_out.stipplePos = stipple_pos;
gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0;
gpu_EmitVertex();
}
void main()
{
vec2 ss_pos[2];
vec4 pos0 = gl_in[0].gl_Position;
vec4 pos1 = gl_in[1].gl_Position;
ss_pos[0] = pos0.xy / pos0.w;
ss_pos[1] = pos1.xy / pos1.w;
float half_size = sizeEdge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (doSmoothWire ? 1.0 : 3.0), 1.0) :
0.0;
/* Add 1 PX for AA. */
if (doSmoothWire) {
half_size += 0.5;
}
vec2 line = ss_pos[0] - ss_pos[1];
vec2 line_dir = normalize(line);
vec2 line_perp = vec2(-line_dir.y, line_dir.x);
vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
float selectFac0 = geom_in[0].selectionFac;
float selectFac1 = geom_in[1].selectionFac;
#ifdef USE_EDGE_SELECT
/* No blending with edge selection. */
selectFac1 = selectFac0;
#endif
do_vertex(pos0,
selectFac0,
geom_flat_in[0].stippleStart,
geom_noperspective_in[0].stipplePos,
half_size,
edge_ofs.xy);
do_vertex(pos0,
selectFac0,
geom_flat_in[0].stippleStart,
geom_noperspective_in[0].stipplePos,
-half_size,
-edge_ofs.xy);
do_vertex(pos1,
selectFac1,
geom_flat_in[1].stippleStart,
geom_noperspective_in[1].stipplePos,
half_size,
edge_ofs.xy);
do_vertex(pos1,
selectFac1,
geom_flat_in[1].stippleStart,
geom_noperspective_in[1].stipplePos,
-half_size,
-edge_ofs.xy);
EndPrimitive();
}

View File

@@ -1,75 +0,0 @@
/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/**
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with a circle of the same area and try to find the intersection
* area. The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complex. Instead,
* we approximate it by using the smooth-step function and a 1.05 factor to the disc radius.
*/
#define M_1_SQRTPI 0.5641895835477563 /* `1/sqrt(pi)`. */
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
#include "overlay_common_lib.glsl"
void main()
{
vec4 inner_color = vec4(vec3(0.0), 1.0);
vec4 outer_color = vec4(0.0);
vec2 dd = fwidth(stipplePos);
float line_distance = distance(stipplePos, stippleStart) / max(dd.x, dd.y);
if (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) {
if (use_edge_select) {
/* 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 = (selectionFac != 0.0) ? colorEdgeSelect : (colorWireEdit * 0.5);
}
else {
inner_color = mix(colorWireEdit, colorEdgeSelect, selectionFac);
}
outer_color = vec4(vec3(0.0), 1.0);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_DASH) {
if (fract(line_distance / dashLength) < 0.5) {
inner_color = mix(vec4(vec3(0.35), 1.0), colorEdgeSelect, selectionFac);
}
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_BLACK) {
vec4 base_color = vec4(vec3(0.0), 1.0);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_WHITE) {
vec4 base_color = vec4(1.0);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_SHADOW) {
inner_color = colorUVShadow;
}
float dist = abs(edgeCoord) - max(sizeEdge - 0.5, 0.0);
float dist_outer = dist - max(sizeEdge, 1.0);
float mix_w;
float mix_w_outer;
if (doSmoothWire) {
mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer);
}
else {
mix_w = step(0.5, dist);
mix_w_outer = step(0.5, dist_outer);
}
vec4 final_color = mix(outer_color, inner_color, 1.0 - mix_w * outer_color.a);
final_color.a *= 1.0 - (outer_color.a > 0.0 ? mix_w_outer : mix_w);
final_color.a *= alpha;
fragColor = final_color;
}

View File

@@ -1,186 +0,0 @@
/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "draw_model_lib.glsl"
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "overlay_common_lib.glsl"
struct VertIn {
vec2 uv;
uint flag;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.uv = gpu_attr_load_float2(au, gpu_attr_0, v_i);
#ifdef WIREFRAME
vert_in.flag = 0u;
#else
vert_in.flag = gpu_attr_load_uchar4(data, gpu_attr_1, v_i).x;
#endif
return vert_in;
}
struct VertOut {
vec4 hs_P;
vec2 stipple_start;
vec2 stipple_pos;
bool selected;
};
VertOut vertex_main(VertIn v_in)
{
VertOut vert_out;
vec3 world_pos = vec3(v_in.uv, 0.0);
vert_out.hs_P = drw_point_world_to_homogenous(world_pos);
/* Snap vertices to the pixel grid to reduce artifacts. */
vec2 half_viewport_res = sizeViewport * 0.5;
vec2 half_pixel_offset = sizeViewportInv * 0.5;
vert_out.hs_P.xy = floor(vert_out.hs_P.xy * half_viewport_res) / half_viewport_res +
half_pixel_offset;
const uint selection_flag = use_edge_select ? uint(EDGE_UV_SELECT) : uint(VERT_UV_SELECT);
vert_out.selected = flag_test(v_in.flag, selection_flag);
/* Move selected edges to the top so that they occlude unselected edges.
* - Vertices are between 0.0 and 0.2 depth.
* - Edges between 0.2 and 0.4 depth.
* - Image pixels are at 0.75 depth.
* - 1.0 is used for the background. */
vert_out.hs_P.z = vert_out.selected ? 0.25 : 0.35;
/* Avoid precision loss. */
vert_out.stipple_pos = 500.0 + 500.0 * (vert_out.hs_P.xy / vert_out.hs_P.w);
vert_out.stipple_start = vert_out.stipple_pos;
return vert_out;
}
struct GeomOut {
vec4 gpu_position;
vec2 stipple_start;
vec2 stipple_pos;
float edge_coord;
bool selected;
};
void export_vertex(GeomOut geom_out)
{
selectionFac = float(geom_out.selected);
stippleStart = geom_out.stipple_start;
stipplePos = geom_out.stipple_pos;
edgeCoord = geom_out.edge_coord;
gl_Position = geom_out.gpu_position;
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec2 ss_pos0 = drw_perspective_divide(geom_in[0].hs_P).xy;
vec2 ss_pos1 = drw_perspective_divide(geom_in[1].hs_P).xy;
float half_size = sizeEdge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (doSmoothWire ? 1.0 : 3.0), 1.0) :
0.0;
/* Add 1 PX for AA. */
if (doSmoothWire) {
half_size += 0.5;
}
vec2 line_dir = normalize(ss_pos0 - ss_pos1);
vec2 line_perp = vec2(-line_dir.y, line_dir.x);
vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
edge_ofs *= 2.0;
bool select_0 = geom_in[0].selected;
/* No blending with edge selection. */
bool select_1 = use_edge_select ? geom_in[0].selected : geom_in[1].selected;
GeomOut geom_out;
geom_out.stipple_start = geom_in[0].stipple_start;
geom_out.stipple_pos = geom_in[0].stipple_pos;
geom_out.gpu_position = geom_in[0].hs_P + vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = half_size;
geom_out.selected = select_0;
strip_EmitVertex(0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[0].hs_P - vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = -half_size;
strip_EmitVertex(1, out_vertex_id, out_primitive_id, geom_out);
geom_out.stipple_start = geom_in[1].stipple_start;
geom_out.stipple_pos = geom_in[1].stipple_pos;
geom_out.gpu_position = geom_in[1].hs_P + vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = half_size;
geom_out.selected = select_1;
strip_EmitVertex(2, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].hs_P - vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = -half_size;
strip_EmitVertex(3, out_vertex_id, out_primitive_id, geom_out);
}
void main()
{
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -2,31 +2,185 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_lib.glsl"
#include "draw_model_lib.glsl"
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
#include "overlay_common_lib.glsl"
void main()
struct VertIn {
vec2 uv;
uint flag;
};
VertIn input_assembly(uint in_vertex_id)
{
vec3 world_pos = vec3(au, 0.0);
gl_Position = point_world_to_ndc(world_pos);
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.uv = gpu_attr_load_float2(au, gpu_attr_0, v_i);
#ifdef WIREFRAME
vert_in.flag = 0u;
#else
vert_in.flag = gpu_attr_load_uchar4(data, gpu_attr_1, v_i).x;
#endif
return vert_in;
}
struct VertOut {
vec4 hs_P;
vec2 stipple_start;
vec2 stipple_pos;
bool selected;
};
VertOut vertex_main(VertIn v_in)
{
VertOut vert_out;
vec3 world_pos = vec3(v_in.uv, 0.0);
vert_out.hs_P = drw_point_world_to_homogenous(world_pos);
/* Snap vertices to the pixel grid to reduce artifacts. */
vec2 half_viewport_res = sizeViewport * 0.5;
vec2 half_pixel_offset = sizeViewportInv * 0.5;
gl_Position.xy = floor(gl_Position.xy * half_viewport_res) / half_viewport_res +
half_pixel_offset;
vert_out.hs_P.xy = floor(vert_out.hs_P.xy * half_viewport_res) / half_viewport_res +
half_pixel_offset;
#ifdef USE_EDGE_SELECT
bool is_select = (flag & int(EDGE_UV_SELECT)) != 0;
#else
bool is_select = (flag & int(VERT_UV_SELECT)) != 0;
#endif
geom_in.selectionFac = is_select ? 1.0 : 0.0;
/* Move selected edges to the top
* Vertices are between 0.0 and 0.2, Edges between 0.2 and 0.4
* actual pixels are at 0.75, 1.0 is used for the background. */
float depth = is_select ? 0.25 : 0.35;
gl_Position.z = depth;
const uint selection_flag = use_edge_select ? uint(EDGE_UV_SELECT) : uint(VERT_UV_SELECT);
vert_out.selected = flag_test(v_in.flag, selection_flag);
/* Move selected edges to the top so that they occlude unselected edges.
* - Vertices are between 0.0 and 0.2 depth.
* - Edges between 0.2 and 0.4 depth.
* - Image pixels are at 0.75 depth.
* - 1.0 is used for the background. */
vert_out.hs_P.z = vert_out.selected ? 0.25 : 0.35;
/* Avoid precision loss. */
geom_flat_in.stippleStart = geom_noperspective_in.stipplePos = 500.0 + 500.0 * (gl_Position.xy /
gl_Position.w);
vert_out.stipple_pos = 500.0 + 500.0 * (vert_out.hs_P.xy / vert_out.hs_P.w);
vert_out.stipple_start = vert_out.stipple_pos;
return vert_out;
}
struct GeomOut {
vec4 gpu_position;
vec2 stipple_start;
vec2 stipple_pos;
float edge_coord;
bool selected;
};
void export_vertex(GeomOut geom_out)
{
selectionFac = float(geom_out.selected);
stippleStart = geom_out.stipple_start;
stipplePos = geom_out.stipple_pos;
edgeCoord = geom_out.edge_coord;
gl_Position = geom_out.gpu_position;
}
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index == strip_index) {
export_vertex(geom_out);
}
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec2 ss_pos0 = drw_perspective_divide(geom_in[0].hs_P).xy;
vec2 ss_pos1 = drw_perspective_divide(geom_in[1].hs_P).xy;
float half_size = sizeEdge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (doSmoothWire ? 1.0 : 3.0), 1.0) :
0.0;
/* Add 1 PX for AA. */
if (doSmoothWire) {
half_size += 0.5;
}
vec2 line_dir = normalize(ss_pos0 - ss_pos1);
vec2 line_perp = vec2(-line_dir.y, line_dir.x);
vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
edge_ofs *= 2.0;
bool select_0 = geom_in[0].selected;
/* No blending with edge selection. */
bool select_1 = use_edge_select ? geom_in[0].selected : geom_in[1].selected;
GeomOut geom_out;
geom_out.stipple_start = geom_in[0].stipple_start;
geom_out.stipple_pos = geom_in[0].stipple_pos;
geom_out.gpu_position = geom_in[0].hs_P + vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = half_size;
geom_out.selected = select_0;
strip_EmitVertex(0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[0].hs_P - vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = -half_size;
strip_EmitVertex(1, out_vertex_id, out_primitive_id, geom_out);
geom_out.stipple_start = geom_in[1].stipple_start;
geom_out.stipple_pos = geom_in[1].stipple_pos;
geom_out.gpu_position = geom_in[1].hs_P + vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = half_size;
geom_out.selected = select_1;
strip_EmitVertex(2, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].hs_P - vec4(edge_ofs, 0.0, 0.0);
geom_out.edge_coord = -half_size;
strip_EmitVertex(3, out_vertex_id, out_primitive_id, geom_out);
}
void main()
{
/* Line list primitive. */
const uint input_primitive_vertex_count = 2u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
VertIn vert_in[input_primitive_vertex_count];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[input_primitive_vertex_count];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -9,10 +9,6 @@ void main()
/* `pos` contains the coordinates of a quad (-1..1). but we need the coordinates of an image
* plane (0..1) */
vec3 image_pos = pos * 0.5 + 0.5;
#ifdef OVERLAY_NEXT
gl_Position = point_world_to_ndc(vec3(image_pos.xy * brush_scale + brush_offset, 0.0));
#else
gl_Position = point_object_to_ndc(image_pos);
#endif
uvs = image_pos.xy;
}

View File

@@ -13,9 +13,5 @@ void main()
/* `pos` contains the coordinates of a quad (-1..1). but we need the coordinates of an image
* plane (0..1) */
vec3 image_pos = pos * 0.5 + 0.5;
#ifdef OVERLAY_NEXT
gl_Position = point_world_to_ndc(tile_scale * image_pos + tile_pos);
#else
gl_Position = point_object_to_ndc(image_pos);
#endif
}

View File

@@ -13,6 +13,7 @@ void main()
/* Relative to DPI scaling. Have constant screen size. */
vec3 screen_pos = ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y;
vec3 inst_pos = data_buf[gl_InstanceID].xyz;
vec3 p = inst_pos;
p.z *= (pos.z == 0.0) ? 0.0 : 1.0;
float screen_size = mul_project_m4_v3_zfac(p) * sizePixel;

View File

@@ -7,15 +7,9 @@
void main()
{
#ifdef OVERLAY_NEXT
finalColor = vertex_color;
#else
/* Extract data packed inside the unused mat4 members. */
mat4 obmat = ModelMatrix;
finalColor = vec4(obmat[0][3], obmat[1][3], obmat[2][3], obmat[3][3]);
#endif
finalColor = data_buf[gl_VertexID].color_;
vec3 world_pos = (ModelMatrix * vec4(pos, 1.0)).xyz;
vec3 world_pos = (ModelMatrix * vec4(data_buf[gl_VertexID].pos_.xyz, 1.0)).xyz;
gl_Position = point_world_to_ndc(world_pos);
gl_PointSize = sizeVertex * 2.0;

View File

@@ -10,7 +10,7 @@ void main()
{
select_id_set(in_select_buf[gl_VertexID]);
vec3 world_pos = point_object_to_world(pos);
vec3 world_pos = point_object_to_world(data_buf[gl_VertexID].pos_.xyz);
gl_Position = point_world_to_ndc(world_pos);
gl_PointSize = sizeObjectCenter;
@@ -22,7 +22,7 @@ void main()
radii[3] = radius - outline_width - 1.0;
radii /= sizeObjectCenter;
fillColor = ucolor;
fillColor = data_buf[gl_VertexID].color_;
outlineColor = colorOutline;
#ifdef SELECT_ENABLE

View File

@@ -49,10 +49,12 @@ void main()
/* Loading the matrix first before doing the manipulation fixes an issue
* with the Metal compiler on older Intel macs (see #130867). */
mat4 inst_obmat = data_buf[gl_InstanceID].object_to_world;
mat4x4 input_mat = inst_obmat;
/* Extract data packed inside the unused mat4 members. */
vec4 inst_data = vec4(input_mat[0][3], input_mat[1][3], input_mat[2][3], input_mat[3][3]);
float4 color = data_buf[gl_InstanceID].color_;
float inst_color_data = color.a;
mat4 obmat = input_mat;
obmat[0][3] = obmat[1][3] = obmat[2][3] = 0.0;
@@ -224,7 +226,7 @@ void main()
/* Convert to screen position [0..sizeVp]. */
edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
#ifdef SELECT_EDGES
#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... */

View File

@@ -22,7 +22,7 @@ void main()
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
#ifdef SELECT_EDGES
#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... */
@@ -48,7 +48,7 @@ void main()
}
#endif
#ifdef SELECT_EDGES
#if defined(SELECT_ENABLE)
finalColor.a = 0.0; /* No Stipple */
#endif

View File

@@ -206,13 +206,11 @@ void main()
vec2 uv = gl_FragCoord.xy / vec2(textureSize(depth_tx, 0));
float scene_depth = texture(depth_tx, uv, 0).r;
#ifdef OVERLAY_NEXT
float scene_depth_infront = texture(depth_infront_tx, uv, 0).r;
if (scene_depth_infront != 1.0) {
/* Treat in front objects as if they were on the near plane to occlude the grid. */
scene_depth = 0.0;
}
#endif
if (flag_test(grid_flag, GRID_BACK)) {
fade *= (scene_depth == 1.0) ? 1.0 : 0.0;

View File

@@ -1,39 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
vec2 compute_dir(vec2 v0, vec2 v1)
{
vec2 dir = normalize(v1 - v0 + 1e-8);
dir = vec2(-dir.y, dir.x);
return dir;
}
void main()
{
vec2 t;
vec2 edge_dir = compute_dir(interp_flat[0].ss_pos, interp_flat[1].ss_pos) * sizeViewportInv;
bool is_persp = (drw_view.winmat[3][3] == 0.0);
float line_size = float(lineThickness) * sizePixel;
view_clipping_distances_set(gl_in[0]);
interp_out.color = interp_in[0].color;
t = edge_dir * (line_size * (is_persp ? gl_in[0].gl_Position.w : 1.0));
gl_Position = gl_in[0].gl_Position + vec4(t, 0.0, 0.0);
gpu_EmitVertex();
gl_Position = gl_in[0].gl_Position - vec4(t, 0.0, 0.0);
gpu_EmitVertex();
view_clipping_distances_set(gl_in[1]);
interp_out.color = interp_in[1].color;
t = edge_dir * (line_size * (is_persp ? gl_in[1].gl_Position.w : 1.0));
gl_Position = gl_in[1].gl_Position + vec4(t, 0.0, 0.0);
gpu_EmitVertex();
gl_Position = gl_in[1].gl_Position - vec4(t, 0.0, 0.0);
gpu_EmitVertex();
EndPrimitive();
}

View File

@@ -1,165 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_matrix_lib.glsl"
#include "gpu_shader_math_vector_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
struct VertIn {
vec3 P;
uint vert_id;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.vert_id = v_i;
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 hs_P;
vec2 ss_P;
vec4 color;
};
#define frameCurrent mpathLineSettings.x
#define frameStart mpathLineSettings.y
#define frameEnd mpathLineSettings.z
#define cacheStart mpathLineSettings.w
VertOut vertex_main(VertIn vert_in)
{
VertOut vert_out;
/* 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.xy;
int frame = int(vert_in.vert_id) + cacheStart;
vec3 blend_base = (abs(frame - frameCurrent) == 0) ?
colorCurrentFrame.rgb :
colorBackground.rgb; /* "bleed" CFRAME color to ease color blending */
bool use_custom_color = customColorPre.x >= 0.0;
if (frame < frameCurrent) {
vert_out.color.rgb = use_custom_color ? customColorPre : colorBeforeFrame.rgb;
}
else if (frame > frameCurrent) {
vert_out.color.rgb = use_custom_color ? customColorPost : colorAfterFrame.rgb;
}
else /* if (frame == frameCurrent) */ {
vert_out.color.rgb = use_custom_color ? colorCurrentFrame.rgb : blend_base;
}
vert_out.color.a = 1.0;
return vert_out;
}
struct GeomOut {
vec4 gpu_position;
vec4 color;
vec3 ws_P;
};
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index != strip_index) {
return;
}
interp.color = geom_out.color;
gl_Position = geom_out.gpu_position;
view_clipping_distances(geom_out.ws_P);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec2 ss_P0 = geom_in[0].ss_P;
vec2 ss_P1 = geom_in[1].ss_P;
vec2 edge_dir = orthogonal(normalize(ss_P1 - ss_P0 + 1e-8)) * sizeViewportInv;
bool is_persp = (drw_view.winmat[3][3] == 0.0);
float line_size = float(lineThickness) * sizePixel;
GeomOut geom_out;
vec2 t0 = edge_dir * (line_size * (is_persp ? geom_in[0].hs_P.w : 1.0));
geom_out.gpu_position = geom_in[0].hs_P + vec4(t0, 0.0, 0.0);
geom_out.color = geom_in[0].color;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[0].hs_P - vec4(t0, 0.0, 0.0);
strip_EmitVertex(1, out_vertex_id, out_primitive_id, geom_out);
vec2 t1 = edge_dir * (line_size * (is_persp ? geom_in[1].hs_P.w : 1.0));
geom_out.gpu_position = geom_in[1].hs_P + vec4(t1, 0.0, 0.0);
geom_out.ws_P = geom_in[1].ws_P;
geom_out.color = geom_in[1].color;
strip_EmitVertex(2, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].hs_P - vec4(t1, 0.0, 0.0);
strip_EmitVertex(3, out_vertex_id, out_primitive_id, geom_out);
}
void main()
{
/* Point list primitive. */
const uint input_primitive_vertex_count = 1u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
/* Read current and next point. */
VertIn vert_in[2];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[2];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -3,26 +3,50 @@
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "draw_view_lib.glsl"
#include "gpu_shader_attribute_load_lib.glsl"
#include "gpu_shader_index_load_lib.glsl"
#include "gpu_shader_math_matrix_lib.glsl"
#include "gpu_shader_math_vector_lib.glsl"
#include "gpu_shader_utildefines_lib.glsl"
struct VertIn {
vec3 P;
uint vert_id;
};
VertIn input_assembly(uint in_vertex_id)
{
uint v_i = gpu_index_load(in_vertex_id);
VertIn vert_in;
vert_in.P = gpu_attr_load_float3(pos, gpu_attr_0, v_i);
vert_in.vert_id = v_i;
return vert_in;
}
struct VertOut {
vec3 ws_P;
vec4 hs_P;
vec2 ss_P;
vec4 color;
};
#define frameCurrent mpathLineSettings.x
#define frameStart mpathLineSettings.y
#define frameEnd mpathLineSettings.z
#define cacheStart mpathLineSettings.w
/* project to screen space */
vec2 proj(vec4 pos)
VertOut vertex_main(VertIn vert_in)
{
return (0.5 * (pos.xy / pos.w) + 0.5) * sizeViewport.xy;
}
VertOut vert_out;
/* 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.xy;
void main()
{
gl_Position = drw_view.winmat * (drw_view.viewmat * (camera_space_matrix * vec4(pos, 1.0)));
interp_flat.ss_pos = proj(gl_Position);
int frame = gl_VertexID + cacheStart;
int frame = int(vert_in.vert_id) + cacheStart;
vec3 blend_base = (abs(frame - frameCurrent) == 0) ?
colorCurrentFrame.rgb :
@@ -30,32 +54,112 @@ void main()
bool use_custom_color = customColorPre.x >= 0.0;
if (frame < frameCurrent) {
if (use_custom_color) {
interp.color.rgb = customColorPre;
}
else {
interp.color.rgb = colorBeforeFrame.rgb;
}
vert_out.color.rgb = use_custom_color ? customColorPre : colorBeforeFrame.rgb;
}
else if (frame > frameCurrent) {
if (use_custom_color) {
interp.color.rgb = customColorPost;
}
else {
interp.color.rgb = colorAfterFrame.rgb;
}
vert_out.color.rgb = use_custom_color ? customColorPost : colorAfterFrame.rgb;
}
else {
/* Current Frame. */
if (use_custom_color) {
interp.color.rgb = colorCurrentFrame.rgb;
}
else {
interp.color.rgb = blend_base;
}
else /* if (frame == frameCurrent) */ {
vert_out.color.rgb = use_custom_color ? colorCurrentFrame.rgb : blend_base;
}
vert_out.color.a = 1.0;
interp.color.a = 1.0;
view_clipping_distances(pos);
return vert_out;
}
struct GeomOut {
vec4 gpu_position;
vec4 color;
vec3 ws_P;
};
void strip_EmitVertex(const uint strip_index,
uint out_vertex_id,
uint out_primitive_id,
GeomOut geom_out)
{
bool is_odd_primitive = (out_primitive_id & 1u) != 0u;
/* Maps triangle list primitives to triangle strip indices. */
uint out_strip_index = (is_odd_primitive ? (2u - out_vertex_id) : out_vertex_id) +
out_primitive_id;
if (out_strip_index != strip_index) {
return;
}
interp.color = geom_out.color;
gl_Position = geom_out.gpu_position;
view_clipping_distances(geom_out.ws_P);
}
void geometry_main(VertOut geom_in[2],
uint out_vertex_id,
uint out_primitive_id,
uint out_invocation_id)
{
vec2 ss_P0 = geom_in[0].ss_P;
vec2 ss_P1 = geom_in[1].ss_P;
vec2 edge_dir = orthogonal(normalize(ss_P1 - ss_P0 + 1e-8)) * sizeViewportInv;
bool is_persp = (drw_view.winmat[3][3] == 0.0);
float line_size = float(lineThickness) * sizePixel;
GeomOut geom_out;
vec2 t0 = edge_dir * (line_size * (is_persp ? geom_in[0].hs_P.w : 1.0));
geom_out.gpu_position = geom_in[0].hs_P + vec4(t0, 0.0, 0.0);
geom_out.color = geom_in[0].color;
geom_out.ws_P = geom_in[0].ws_P;
strip_EmitVertex(0, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[0].hs_P - vec4(t0, 0.0, 0.0);
strip_EmitVertex(1, out_vertex_id, out_primitive_id, geom_out);
vec2 t1 = edge_dir * (line_size * (is_persp ? geom_in[1].hs_P.w : 1.0));
geom_out.gpu_position = geom_in[1].hs_P + vec4(t1, 0.0, 0.0);
geom_out.ws_P = geom_in[1].ws_P;
geom_out.color = geom_in[1].color;
strip_EmitVertex(2, out_vertex_id, out_primitive_id, geom_out);
geom_out.gpu_position = geom_in[1].hs_P - vec4(t1, 0.0, 0.0);
strip_EmitVertex(3, out_vertex_id, out_primitive_id, geom_out);
}
void main()
{
/* Point list primitive. */
const uint input_primitive_vertex_count = 1u;
/* Triangle list primitive. */
const uint ouput_primitive_vertex_count = 3u;
const uint ouput_primitive_count = 2u;
const uint ouput_invocation_count = 1u;
const uint output_vertex_count_per_invocation = ouput_primitive_count *
ouput_primitive_vertex_count;
const uint output_vertex_count_per_input_primitive = output_vertex_count_per_invocation *
ouput_invocation_count;
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
ouput_primitive_count;
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
ouput_invocation_count;
/* Read current and next point. */
VertIn vert_in[2];
vert_in[0] = input_assembly(in_primitive_first_vertex + 0u);
vert_in[1] = input_assembly(in_primitive_first_vertex + 1u);
VertOut vert_out[2];
vert_out[0] = vertex_main(vert_in[0]);
vert_out[1] = vertex_main(vert_in[1]);
/* Discard by default. */
gl_Position = vec4(NAN_FLT);
geometry_main(vert_out, out_vertex_id, out_primitive_id, out_invocation_id);
}

View File

@@ -1,50 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void vert_from_gl_in(int v)
{
gl_Position = gl_in[v].gl_Position;
interp_out.ob_id = interp_in[v].ob_id;
view_clipping_distances_set(gl_in[v]);
}
void main()
{
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(vert[1].pos) : vec3(0.0, 0.0, -1.0);
vec3 v10 = vert[0].pos - vert[1].pos;
vec3 v12 = vert[2].pos - vert[1].pos;
vec3 v13 = vert[3].pos - vert[1].pos;
vec3 n0 = cross(v12, v10);
vec3 n3 = cross(v13, v12);
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
}
/* Don't outline if concave edge. */
/* That would hide a lot of non useful edge but it flickers badly.
* TODO: revisit later... */
// if (dot(n0, v13) > 0.01)
// return;
vert_from_gl_in(1);
gpu_EmitVertex();
vert_from_gl_in(2);
gpu_EmitVertex();
EndPrimitive();
}

View File

@@ -1,24 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
vec3 linear_to_srgb_attr(vec3 c)
{
c = max(c, vec3(0.0));
vec3 c1 = c * 12.92;
vec3 c2 = 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055;
return mix(c1, c2, step(vec3(0.0031308), c));
}
void main()
{
vec3 color = linear_to_srgb_attr(finalColor);
if (useAlphaBlend) {
fragColor = vec4(color, opacity);
}
else {
/* mix with 1.0 -> is like opacity when using multiply blend mode */
fragColor = vec4(mix(vec3(1.0), color, opacity), 1.0);
}
}

View File

@@ -1,26 +0,0 @@
/* SPDX-FileCopyrightText: 2018-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
vec3 srgb_to_linear_attr(vec3 c)
{
c = max(c, vec3(0.0));
vec3 c1 = c * (1.0 / 12.92);
vec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));
return mix(c1, c2, step(vec3(0.04045), c));
}
void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
finalColor = srgb_to_linear_attr(ac);
view_clipping_distances(world_pos);
}

View File

@@ -6,17 +6,6 @@
#include "common_view_lib.glsl"
#include "select_lib.glsl"
/* TODO(fclem): Share with C code. */
#define VCLASS_SCREENALIGNED (1 << 9)
#define VCLASS_EMPTY_AXES (1 << 11)
vec3 rotate(vec3 vec, vec4 quat)
{
/* The quaternion representation here stores the w component in the first index. */
return vec + 2.0 * cross(quat.yzw, cross(quat.yzw, vec) + quat.x * vec);
}
void main()
{
select_id_set(drw_CustomID);
@@ -26,29 +15,12 @@ void main()
vec3 world_pos = part_pos;
#ifdef USE_DOTS
gl_Position = point_world_to_ndc(world_pos);
/* World sized points. */
gl_PointSize = sizePixel * draw_size * drw_view.winmat[1][1] * sizeViewport.y / gl_Position.w;
#else
if ((vclass & VCLASS_SCREENALIGNED) != 0) {
/* World sized, camera facing geometry. */
world_pos += (ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y) * draw_size;
}
else {
world_pos += rotate(pos, part_rot) * draw_size;
}
gl_Position = point_world_to_ndc(world_pos);
#endif
/* Coloring */
if ((vclass & VCLASS_EMPTY_AXES) != 0) {
/* See VBO construction for explanation. */
finalColor = vec4(clamp(pos * 10000.0, 0.0, 1.0), 1.0);
}
else if (part_val < 0.0) {
if (part_val < 0.0) {
finalColor = vec4(ucolor.rgb, 1.0);
}
else {

View File

@@ -1,13 +0,0 @@
/* SPDX-FileCopyrightText: 2017-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "common_pointcloud_lib.glsl"
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
void main()
{
vec3 world_pos = pointcloud_get_pos();
gl_Position = point_world_to_ndc(world_pos);
}

View File

@@ -32,7 +32,7 @@ void main()
fragColor = vec4(mix(final_front_col, rim_col, saturate(fac)), 1.0);
fragColor *= fragColor;
#elif !defined(SELECT_EDGES)
#elif defined(SELECT_ENABLE)
lineOutput = pack_line_data(gl_FragCoord.xy, edgeStart, edgePos);
fragColor = finalColor;

View File

@@ -157,7 +157,7 @@ void main()
# if defined(CURVES)
finalColor.rgb = rim_col;
# elif !defined(SELECT_EDGES)
# elif !defined(SELECT_ENABLE)
facing = clamp(abs(facing), 0.0, 1.0);
/* Do interpolation in a non-linear space to have a better visual result. */
rim_col = pow(rim_col, vec3(1.0 / 2.2));
@@ -177,7 +177,7 @@ void main()
}
# endif
# ifdef SELECT_EDGES
# 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.0 : 1.0);

View File

@@ -4,7 +4,6 @@
void main()
{
#ifdef OVERLAY_NEXT
/* TODO(fclem): Cleanup naming. Here the xray depth mean the scene depth (from workbench) and
* simple depth is the overlay depth. */
float depth_infront = textureLod(depthTexInfront, uvcoordsvar.xy, 0.0).r;
@@ -33,9 +32,4 @@ void main()
discard;
return;
#else
float depth = texture(depthTex, uvcoordsvar.xy).r;
float depth_xray = texture(xrayDepthTex, uvcoordsvar.xy).r;
fragColor = vec4((depth < 1.0 && depth > depth_xray) ? opacity : 1.0);
#endif
}

View File

@@ -65,9 +65,6 @@ GPUShader *GPU_shader_create_from_info_name(const char *info_name);
*/
const GPUShaderCreateInfo *GPU_shader_create_info_get(const char *info_name);
void GPU_shader_create_info_get_unfinalized_copy(const char *info_name,
GPUShaderCreateInfo &r_info);
/**
* Error checking for user created shaders.
* \return true is create info is valid.

View File

@@ -263,12 +263,6 @@ const GPUShaderCreateInfo *GPU_shader_create_info_get(const char *info_name)
return gpu_shader_create_info_get(info_name);
}
void GPU_shader_create_info_get_unfinalized_copy(const char *info_name,
GPUShaderCreateInfo &r_info)
{
gpu_shader_create_info_get_unfinalized_copy(info_name, r_info);
}
bool GPU_shader_create_info_check_error(const GPUShaderCreateInfo *_info, char r_error[128])
{
using namespace blender::gpu::shader;

View File

@@ -35,7 +35,6 @@ using CreateInfoDictionnary = Map<StringRef, ShaderCreateInfo *>;
using InterfaceDictionnary = Map<StringRef, StageInterfaceInfo *>;
static CreateInfoDictionnary *g_create_infos = nullptr;
static CreateInfoDictionnary *g_create_infos_unfinalized = nullptr;
static InterfaceDictionnary *g_interfaces = nullptr;
/* -------------------------------------------------------------------- */
@@ -153,6 +152,7 @@ void ShaderCreateInfo::finalize(const bool recursive)
if (info.early_fragment_test_) {
early_fragment_test_ = true;
depth_write_ = DepthWrite::UNCHANGED;
}
/* Modify depth write if has been changed from default.
* `UNCHANGED` implies gl_FragDepth is not used at all. */
@@ -444,7 +444,6 @@ using namespace blender::gpu::shader;
void gpu_shader_create_info_init()
{
g_create_infos = new CreateInfoDictionnary();
g_create_infos_unfinalized = new CreateInfoDictionnary();
g_interfaces = new InterfaceDictionnary();
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \
@@ -514,10 +513,6 @@ void gpu_shader_create_info_init()
#endif
}
for (auto [key, info] : g_create_infos->items()) {
g_create_infos_unfinalized->add_new(key, new ShaderCreateInfo(*info));
}
for (ShaderCreateInfo *info : g_create_infos->values()) {
info->finalize(true);
}
@@ -536,11 +531,6 @@ void gpu_shader_create_info_exit()
}
delete g_create_infos;
for (auto *value : g_create_infos_unfinalized->values()) {
delete value;
}
delete g_create_infos_unfinalized;
for (auto *value : g_interfaces->values()) {
delete value;
}
@@ -662,18 +652,3 @@ const GPUShaderCreateInfo *gpu_shader_create_info_get(const char *info_name)
ShaderCreateInfo *info = g_create_infos->lookup(info_name);
return reinterpret_cast<const GPUShaderCreateInfo *>(info);
}
void gpu_shader_create_info_get_unfinalized_copy(const char *info_name,
GPUShaderCreateInfo &r_info)
{
if (g_create_infos_unfinalized->contains(info_name) == false) {
std::string msg = std::string("Error: Cannot find shader create info named \"") + info_name +
"\"\n";
BLI_assert_msg(0, msg.c_str());
}
else {
ShaderCreateInfo &info = reinterpret_cast<ShaderCreateInfo &>(r_info);
info = *g_create_infos_unfinalized->lookup(info_name);
BLI_assert(!info.finalized_);
}
}

View File

@@ -22,6 +22,3 @@ bool gpu_shader_create_info_compile(const char *name_starts_with_filter);
/** Runtime create infos are not registered in the dictionary and cannot be searched. */
const GPUShaderCreateInfo *gpu_shader_create_info_get(const char *info_name);
void gpu_shader_create_info_get_unfinalized_copy(const char *info_name,
GPUShaderCreateInfo &r_info);