mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Working quite nicely
This commit is contained in:
parent
47e204038f
commit
c6d56b60f6
5 changed files with 108 additions and 134 deletions
|
@ -16,8 +16,6 @@ vertex =
|
|||
varying highp vec3 v_vertex;
|
||||
varying highp vec3 v_normal;
|
||||
|
||||
varying highp vec4 v_orig_vertex;
|
||||
|
||||
varying lowp vec4 f_color;
|
||||
varying highp vec3 f_vertex;
|
||||
varying highp vec3 f_normal;
|
||||
|
@ -29,14 +27,12 @@ vertex =
|
|||
gl_Position = world_space_vert;
|
||||
// gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||
// shade the color depending on the extruder index stored in the alpha component of the color
|
||||
v_color = (a_color.a == u_active_extruder) ? a_color : a_color * u_shade_factor;
|
||||
v_color = (a_color.a == u_active_extruder) ? a_color : vec4(0.4, 0.4, 0.4, 1.0); //a_color * u_shade_factor;
|
||||
v_color.a = 1.0;
|
||||
|
||||
v_vertex = world_space_vert.xyz;
|
||||
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||
|
||||
v_orig_vertex = a_vertex;
|
||||
|
||||
// for testing without geometry shader
|
||||
f_color = v_color;
|
||||
f_vertex = v_vertex;
|
||||
|
@ -51,7 +47,7 @@ geometry =
|
|||
//uniform highp mat4 u_modelViewProjectionMatrix;
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 8) out;
|
||||
layout(triangle_strip, max_vertices = 28) out;
|
||||
/*layout(std140) uniform Matrices {
|
||||
mat4 u_modelViewProjectionMatrix;
|
||||
};*/
|
||||
|
@ -59,7 +55,6 @@ geometry =
|
|||
in vec4 v_color[];
|
||||
in vec3 v_vertex[];
|
||||
in vec3 v_normal[];
|
||||
in vec3 v_orig_vertex[];
|
||||
|
||||
out vec4 f_color;
|
||||
out vec3 f_normal;
|
||||
|
@ -71,20 +66,28 @@ geometry =
|
|||
//vec3 g_normal;
|
||||
//vec3 g_offset;
|
||||
|
||||
//vec4 g_vertex_delta;
|
||||
vec4 g_vertex_delta;
|
||||
vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers
|
||||
vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position
|
||||
vec3 g_vertex_normal_vert;
|
||||
vec4 g_vertex_offset_vert;
|
||||
vec3 g_vertex_normal_horz_head;
|
||||
vec4 g_vertex_offset_horz_head;
|
||||
|
||||
const float size = 0.5;
|
||||
const float size_x = 0.2;
|
||||
const float size_y = 0.1;
|
||||
|
||||
//g_vertex_delta = gl_in[1].gl_Position - gl_in[0].gl_Position;
|
||||
g_vertex_normal_horz = normalize(v_normal[0]); //vec3(g_vertex_delta.z, g_vertex_delta.y, -g_vertex_delta.x);
|
||||
g_vertex_offset_horz = vec4(g_vertex_normal_horz * size, 0.0); //size * g_vertex_normal_horz;
|
||||
//g_vertex_normal_horz = normalize(v_normal[0]); //vec3(g_vertex_delta.z, g_vertex_delta.y, -g_vertex_delta.x);
|
||||
g_vertex_delta = gl_in[1].gl_Position - gl_in[0].gl_Position;
|
||||
g_vertex_normal_horz_head = normalize(vec3(-g_vertex_delta.x, -g_vertex_delta.y, -g_vertex_delta.z));
|
||||
g_vertex_offset_horz_head = vec4(g_vertex_normal_horz_head * size_x, 0.0);
|
||||
|
||||
g_vertex_normal_horz = normalize(vec3(g_vertex_delta.z, g_vertex_delta.y, -g_vertex_delta.x));
|
||||
|
||||
g_vertex_offset_horz = vec4(g_vertex_normal_horz * size_x, 0.0); //size * g_vertex_normal_horz;
|
||||
g_vertex_normal_vert = vec3(0.0, 1.0, 0.0);
|
||||
//g_vertex_offset_vert = vec3(g_vertex_normal_vert.x * 0.5f, g_vertex_normal_vert.y * 0.5f, g_vertex_normal_vert.z * 0.5f); //size * g_vertex_normal_vert;
|
||||
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size, 0.0);
|
||||
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_normal = g_vertex_normal_horz;
|
||||
|
@ -134,108 +137,101 @@ geometry =
|
|||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
|
||||
poep =
|
||||
#version 410
|
||||
|
||||
uniform highp mat4 u_modelMatrix;
|
||||
uniform highp mat4 u_viewProjectionMatrix;
|
||||
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 3) out;
|
||||
|
||||
in vec4 v_color[];
|
||||
in vec3 v_vertex[];
|
||||
in vec3 v_normal[];
|
||||
in vec4 v_orig_vertex[];
|
||||
|
||||
out vec4 f_color;
|
||||
out vec3 f_normal;
|
||||
out vec3 f_vertex;
|
||||
|
||||
void main()
|
||||
{
|
||||
int i;
|
||||
vec4 delta;
|
||||
vec3 g_normal;
|
||||
vec3 g_offset;
|
||||
|
||||
vec4 g_vertex_delta;
|
||||
vec4 g_vertex_normal_horz; // horizontal and vertical in respect to layers
|
||||
vec3 g_vertex_normal_vert;
|
||||
vec3 g_vertex_offset_horz;
|
||||
vec3 g_vertex_offset_vert;
|
||||
|
||||
float size = 3;
|
||||
|
||||
g_vertex_delta = v_orig_vertex[1] - v_orig_vertex[0];
|
||||
g_vertex_normal_horz = vec4(g_vertex_delta.z, 0.0, -g_vertex_delta.x, g_vertex_delta.w);
|
||||
if (length(g_vertex_normal_horz) < 0.1) {
|
||||
g_vertex_normal_horz = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
g_vertex_offset_horz = vec3(0.0, 0.0, 0.0);
|
||||
g_vertex_offset_vert = vec3(0.0, 0.0, 0.0);
|
||||
} else {
|
||||
g_vertex_normal_horz = normalize(g_vertex_normal_horz);
|
||||
g_vertex_offset_horz = (u_viewProjectionMatrix * u_modelMatrix * size * g_vertex_normal_horz).xyz;
|
||||
g_vertex_normal_vert = vec3(0.0, 0.0, 1.0);
|
||||
g_vertex_offset_vert = (u_viewProjectionMatrix * u_modelMatrix * size * g_vertex_normal_vert).xyz;
|
||||
}
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = gl_in[0].gl_Position + g_vertex_offset_horz;
|
||||
f_color = v_color[0];
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = gl_in[1].gl_Position + g_vertex_offset_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
f_normal = g_vertex_offset_vert;
|
||||
gl_Position = gl_in[0].gl_Position + g_vertex_offset_vert;
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
f_normal = g_vertex_offset_vert;
|
||||
gl_Position = gl_in[1].gl_Position + g_vertex_offset_vert;
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = gl_in[0].gl_Position - g_vertex_offset_horz;
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = gl_in[1].gl_Position - g_vertex_offset_horz;
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
f_normal = -g_vertex_offset_vert;
|
||||
gl_Position = gl_in[0].gl_Position - g_vertex_offset_vert;
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
f_normal = -g_vertex_offset_vert;
|
||||
gl_Position = gl_in[1].gl_Position - g_vertex_offset_vert;
|
||||
EmitVertex();
|
||||
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
// left side
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_horz_head;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_horz_head;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
// right side
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_horz_head;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = -g_vertex_normal_horz_head;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head);
|
||||
EmitVertex();
|
||||
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -271,6 +267,8 @@ fragment =
|
|||
|
||||
//gl_FrontFacing = ..
|
||||
|
||||
//if ((f_normal).z < 0) {discard; }
|
||||
|
||||
mediump vec4 finalColor = vec4(0.0);
|
||||
|
||||
finalColor += u_ambientColor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue