Cleanup/rename etc. dashed line shaders.
Goal is to make them more modular, to allow more variants (variable single-color, thickness, ...) to be added without having to copy-and-change-one-line of whole chain of shaders.
This commit is contained in:
@@ -354,7 +354,7 @@ static void draw_marker(
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1864,7 +1864,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1223,7 +1223,7 @@ static void ui_draw_colorband_handle(
|
||||
if (active || half_width < min_width) {
|
||||
immUnbindProgram();
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -172,7 +172,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
|
||||
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -361,7 +361,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
|
||||
gpuScale2f(zoomx, zoomy);
|
||||
gpuMultMatrix(sc->stabmat);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -651,7 +651,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
/* Since we are switching solid and dashed lines in rather complex logic here, just always go with dashed shader. */
|
||||
immUnbindProgram();
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -1192,7 +1192,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
||||
if (draw_plane_quad || is_selected_track) {
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -89,7 +89,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -846,7 +846,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
|
||||
// return;
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -967,7 +967,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -1053,7 +1053,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -689,7 +689,7 @@ void draw_image_sample_line(SpaceImage *sima)
|
||||
Gwn_VertFormat *format = immVertexFormat();
|
||||
unsigned int shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -179,7 +179,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
if (dashed) {
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -466,7 +466,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
|
||||
/* restore current vertex format & program (roundbox trashes it) */
|
||||
/* Note that we use dahsed shader here, and make it draw solid lines if not muted... */
|
||||
shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1035,7 +1035,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
|
||||
/* border */
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1503,7 +1503,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
||||
if (margin_column_x >= x) {
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1634,7 +1634,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -2209,7 +2209,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
|
||||
if ((do_dashed & DASH_HELP_LINES) && ((bone->flag & BONE_CONNECTED) == 0)) {
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -2516,7 +2516,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
|
||||
|
||||
GPU_select_load_id(-1); /* -1 here is OK! */
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -514,7 +514,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
}
|
||||
|
||||
/* And now, the dashed lines! */
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
{
|
||||
float viewport_size[4];
|
||||
@@ -677,7 +677,7 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -461,7 +461,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -600,7 +600,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
}
|
||||
}
|
||||
else {
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -1731,7 +1731,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -7557,7 +7557,7 @@ static void drawVertSlide(TransInfo *t)
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -735,7 +735,7 @@ void drawConstraint(TransInfo *t)
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -323,7 +323,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -89,7 +89,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -743,7 +743,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
{
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
@@ -135,7 +135,7 @@ data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_geom.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC)
|
||||
@@ -154,8 +154,8 @@ data_to_c_simple(shaders/gpu_shader_3D_image_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_normal_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_flat_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_normal_smooth_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_frag.glsl SRC)
|
||||
|
||||
@@ -146,8 +146,8 @@ typedef enum GPUBuiltinShader {
|
||||
GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
|
||||
GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
|
||||
/* lines */
|
||||
GPU_SHADER_2D_LINE_DASHED_COLOR,
|
||||
GPU_SHADER_3D_LINE_DASHED_COLOR,
|
||||
GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR,
|
||||
GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR,
|
||||
/* lamp drawing */
|
||||
GPU_SHADER_3D_GROUNDPOINT,
|
||||
GPU_SHADER_3D_GROUNDLINE,
|
||||
|
||||
@@ -113,11 +113,11 @@ extern char datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_geom_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_edges_front_back_persp_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_edges_front_back_persp_geom_glsl[];
|
||||
@@ -678,12 +678,12 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
datatoc_gpu_shader_uniform_color_frag_glsl,
|
||||
datatoc_gpu_shader_3D_groundline_geom_glsl },
|
||||
|
||||
[GPU_SHADER_2D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_2D_line_dashed_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
[GPU_SHADER_3D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_3D_line_dashed_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
[GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = { datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
[GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = { datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
|
||||
[GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] =
|
||||
{ datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl,
|
||||
@@ -744,7 +744,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
datatoc_gpu_shader_instance_edges_variying_color_geom_glsl},
|
||||
|
||||
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID] = { datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl,
|
||||
datatoc_gpu_shader_simple_lighting_frag_glsl },
|
||||
datatoc_gpu_shader_simple_lighting_frag_glsl },
|
||||
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl },
|
||||
};
|
||||
@@ -786,10 +786,10 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
stages = &legacy_fancy_edges;
|
||||
}
|
||||
|
||||
if (shader == GPU_SHADER_3D_LINE_DASHED_COLOR && !GLEW_VERSION_3_2) {
|
||||
if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) {
|
||||
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
|
||||
/* TODO: remove after switch to core profile (maybe) */
|
||||
static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl,
|
||||
static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl };
|
||||
stages = &legacy_dashed_lines;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,50 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
|
||||
noperspective in float distance_along_line;
|
||||
out vec4 fragColor;
|
||||
/*
|
||||
* Fragment Shader for dashed lines, with uniform multi-color(s), or any single-color, and any thickness.
|
||||
*
|
||||
* Dashed is performed in screen space.
|
||||
*/
|
||||
|
||||
uniform float dash_width;
|
||||
|
||||
/* Simple mode, discarding non-dash parts (so no need for blending at all). */
|
||||
uniform float dash_factor; /* if > 1.0, solid line. */
|
||||
uniform vec4 color;
|
||||
|
||||
/* More advanced mode, allowing for complex, multi-colored patterns. Enabled when num_colors > 0. */
|
||||
/* Note: max number of steps/colors in pattern is 32! */
|
||||
uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
|
||||
uniform vec4 colors[32];
|
||||
|
||||
noperspective in float distance_along_line;
|
||||
noperspective in vec4 color_geom;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Solid line cases, simple. */
|
||||
if (num_colors == 1) {
|
||||
fragColor = colors[0];
|
||||
}
|
||||
else if (dash_factor >= 1.0f) {
|
||||
fragColor = color;
|
||||
}
|
||||
else {
|
||||
/* Multi-color option. */
|
||||
if (num_colors > 0) {
|
||||
/* Solid line case, simple. */
|
||||
if (num_colors == 1) {
|
||||
fragColor = colors[0];
|
||||
}
|
||||
/* Actually dashed line... */
|
||||
float normalized_distance = fract(distance_along_line / dash_width);
|
||||
if (num_colors > 0) {
|
||||
else {
|
||||
float normalized_distance = fract(distance_along_line / dash_width);
|
||||
fragColor = colors[int(normalized_distance * num_colors)];
|
||||
}
|
||||
}
|
||||
/* Single color option. */
|
||||
else {
|
||||
/* Solid line case, simple. */
|
||||
if (dash_factor >= 1.0f) {
|
||||
fragColor = color_geom;
|
||||
}
|
||||
/* Actually dashed line... */
|
||||
else {
|
||||
float normalized_distance = fract(distance_along_line / dash_width);
|
||||
if (normalized_distance <= dash_factor) {
|
||||
fragColor = color;
|
||||
fragColor = color_geom;
|
||||
}
|
||||
else {
|
||||
discard;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
/*
|
||||
* Geometry Shader for dashed lines, with uniform multi-color(s), or any single-color, and unary thickness.
|
||||
*
|
||||
* Dashed is performed in screen space.
|
||||
*/
|
||||
|
||||
|
||||
/* Make to be used with dynamic batching so no Model Matrix needed */
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
@@ -11,8 +16,11 @@ uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
|
||||
|
||||
layout(lines) in;
|
||||
|
||||
in vec4 color_vert[];
|
||||
|
||||
layout(line_strip, max_vertices = 2) out;
|
||||
noperspective out float distance_along_line;
|
||||
noperspective out vec4 color_geom;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -20,12 +28,14 @@ void main()
|
||||
vec4 v2 = gl_in[1].gl_Position;
|
||||
|
||||
gl_Position = v1;
|
||||
color_geom = color_vert[0];
|
||||
distance_along_line = 0.0f;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = v2;
|
||||
color_geom = color_vert[1];
|
||||
if ((num_colors == 1) || (dash_factor >= 1.0f)) {
|
||||
/* Solid line, optimise out distance computation! */
|
||||
/* Solid line, optimize out distance computation! */
|
||||
distance_along_line = 0.0f;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/*
|
||||
* Vertex Shader for dashed lines with 2D coordinates, with uniform multi-colors or uniform single-color,
|
||||
* and unary thickness.
|
||||
*
|
||||
* Dashed is performed in screen space.
|
||||
*/
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
uniform vec4 color;
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
out vec4 color_vert;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
|
||||
color_vert = color;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space, with non-unary width.
|
||||
|
||||
/* Make to be used with dynamic batching so no Model Matrix needed */
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
/* Width of the generated 'line'. */
|
||||
uniform float width; /* in pixels, screen space. */
|
||||
|
||||
/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */
|
||||
uniform float dash_factor; /* if > 1.0, solid line. */
|
||||
uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
|
||||
|
||||
layout(lines) in;
|
||||
|
||||
layout(triangle_strip, max_vertices = 4) out;
|
||||
noperspective out float distance_along_line;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 v1 = gl_in[0].gl_Position;
|
||||
vec4 v2 = gl_in[1].gl_Position;
|
||||
|
||||
/* Width, from 2D screen space in pixels, to ModelViewProjection space of each input vertices. */
|
||||
float w1 = (width / viewport_size) * v1.w * 2.0;
|
||||
float w2 = (width / viewport_size) * v2.w * 2.0;
|
||||
|
||||
/* Normalized vector parallel to screen and orthogonal to line. */
|
||||
vec4 wdir = normalize(vec4(v1.y - v2.y, v2.x - v1.x, 0.0, 0.0))
|
||||
|
||||
distance_along_line = 0.0f;
|
||||
gl_Position = v1 + (wdir * w1);
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = v1 - (wdir * w1);
|
||||
EmitVertex();
|
||||
|
||||
if ((num_colors == 1) || (dash_factor >= 1.0f)) {
|
||||
/* Solid line, optimize out distance computation! */
|
||||
distance_along_line = 0.0f;
|
||||
}
|
||||
else {
|
||||
vec2 p1 = (v1.xy / v1.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
p1 = p1 * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
vec2 p2 = (v2.xy / v2.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
p2 = p2 * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
distance_along_line = distance(p1, p2);
|
||||
}
|
||||
gl_Position = v2 + (wdir * w2);
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = v2 - (wdir * w2);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
|
||||
/* Note: nearly the same code as for 2D version... Maybe we could deduplicate? */
|
||||
/*
|
||||
* Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
|
||||
* and unary thickness.
|
||||
*
|
||||
* Legacy version, without geometry shader support, always produce solid lines!
|
||||
*/
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
uniform vec4 color;
|
||||
|
||||
in vec3 pos;
|
||||
noperspective out float distance_along_line;
|
||||
noperspective out vec4 color_geom;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -13,4 +21,6 @@ void main()
|
||||
|
||||
/* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */
|
||||
distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f;
|
||||
|
||||
color_geom = color;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/*
|
||||
* Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
|
||||
* and unary thickness.
|
||||
*
|
||||
* Dashed is performed in screen space.
|
||||
*/
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
uniform vec4 color;
|
||||
|
||||
in vec3 pos;
|
||||
|
||||
out vec4 color_vert;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
color_vert = color;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec3 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ static void wm_gesture_draw_line(wmGesture *gt)
|
||||
|
||||
uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -214,7 +214,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
|
||||
|
||||
shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -248,7 +248,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -355,7 +355,7 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
@@ -386,7 +386,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
|
||||
|
||||
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
|
||||
Reference in New Issue
Block a user