Skip to content

Commit

Permalink
try fix GLMakie
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jun 13, 2024
1 parent 4caa1d5 commit 824089d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
11 changes: 2 additions & 9 deletions GLMakie/assets/shader/line_segment.geom
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ struct Nothing{ //Nothing type, to encode if some variable doesn't contain any d
};

layout(lines) in;

// Need to set size of ClipDistance
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[8];
} gl_in[];

layout(triangle_strip, max_vertices = 4) out;

uniform vec2 resolution;
Expand All @@ -24,6 +16,7 @@ uniform int linecap;
in {{stripped_color_type}} g_color[];
in uvec2 g_id[];
in float g_thickness[];
in float g_clip_distance[][8];

out vec3 f_quad_sdf;
out vec2 f_truncation;
Expand Down Expand Up @@ -118,7 +111,7 @@ void main(void)
f_id = g_id[x];

for (int i = 0; i < 8; i++)
gl_ClipDistance[i] = gl_in[x].gl_ClipDistance[i];
gl_ClipDistance[i] = g_clip_distance[x][i];

for (int y = 0; y < 2; y++) {
// Get offset in y direction & compute vertex position
Expand Down
6 changes: 3 additions & 3 deletions GLMakie/assets/shader/line_segment.vert
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ vec4 to_vec4(vec2 v){return vec4(v, 0, 1);}

uniform int num_clip_planes;
uniform vec4 clip_planes[8];
out float gl_ClipDistance[8];
out float g_clip_distance[8];

void process_clip_planes(vec3 world_pos)
{
// distance = dot(world_pos - plane.point, plane.normal)
// precalculated: dot(plane.point, plane.normal) -> plane.w
for (int i = 0; i < num_clip_planes; i++)
gl_ClipDistance[i] = dot(world_pos, clip_planes[i].xyz) - clip_planes[i].w;
g_clip_distance[i] = dot(world_pos, clip_planes[i].xyz) - clip_planes[i].w;

// TODO: can be skipped?
for (int i = num_clip_planes; i < 8; i++)
gl_ClipDistance[i] = 1.0;
g_clip_distance[i] = 1.0;
}


Expand Down
11 changes: 2 additions & 9 deletions GLMakie/assets/shader/lines.geom
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ struct Nothing{ //Nothing type, to encode if some variable doesn't contain any d
{{define_fast_path}}

layout(lines_adjacency) in;

// Need to set size of ClipDistance
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[8];
} gl_in[];

layout(triangle_strip, max_vertices = 4) out;

in {{stripped_color_type}} g_color[];
in float g_lastlen[];
in uvec2 g_id[];
in int g_valid_vertex[];
in float g_thickness[];
in float g_clip_distance[][8];

out highp vec3 f_quad_sdf;
out vec2 f_truncation;
Expand Down Expand Up @@ -89,7 +82,7 @@ void emit_vertex(LineVertex vertex) {
f_linelength = vertex.linelength;
f_id = g_id[vertex.index];
for (int i = 0; i < 8; i++)
gl_ClipDistance[i] = gl_in[vertex.index].gl_ClipDistance[i];
gl_ClipDistance[i] = g_clip_distance[vertex.index][i];
EmitVertex();
}

Expand Down
6 changes: 3 additions & 3 deletions GLMakie/assets/shader/lines.vert
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ uniform float depth_shift;

uniform int num_clip_planes;
uniform vec4 clip_planes[8];
out float gl_ClipDistance[8];
out float g_clip_distance[8];

void process_clip_planes(vec3 world_pos)
{
// distance = dot(world_pos - plane.point, plane.normal)
// precalculated: dot(plane.point, plane.normal) -> plane.w
for (int i = 0; i < num_clip_planes; i++)
gl_ClipDistance[i] = dot(world_pos, clip_planes[i].xyz) - clip_planes[i].w;
g_clip_distance[i] = dot(world_pos, clip_planes[i].xyz) - clip_planes[i].w;

// TODO: can be skipped?
for (int i = num_clip_planes; i < 8; i++)
gl_ClipDistance[i] = 1.0;
g_clip_distance[i] = 1.0;
}

void main()
Expand Down

0 comments on commit 824089d

Please sign in to comment.