mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
WIP OpenGL 4.1 core profile. CURA-3273
This commit is contained in:
parent
aa923321f8
commit
e31a695061
4 changed files with 219 additions and 0 deletions
|
@ -27,6 +27,37 @@ fragment =
|
||||||
gl_FragColor = u_gridColor1;
|
gl_FragColor = u_gridColor1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelViewProjectionMatrix;
|
||||||
|
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in lowp vec2 a_uvs;
|
||||||
|
|
||||||
|
out lowp vec2 v_uvs;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = u_modelViewProjectionMatrix * a_vertex;
|
||||||
|
v_uvs = a_uvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform lowp vec4 u_gridColor0;
|
||||||
|
uniform lowp vec4 u_gridColor1;
|
||||||
|
|
||||||
|
in lowp vec2 v_uvs;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (mod(floor(v_uvs.x / 10.0) - floor(v_uvs.y / 10.0), 2.0) < 1.0)
|
||||||
|
frag_color = u_gridColor0;
|
||||||
|
else
|
||||||
|
frag_color = u_gridColor1;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_gridColor0 = [0.96, 0.96, 0.96, 1.0]
|
u_gridColor0 = [0.96, 0.96, 0.96, 1.0]
|
||||||
u_gridColor1 = [0.8, 0.8, 0.8, 1.0]
|
u_gridColor1 = [0.8, 0.8, 0.8, 1.0]
|
||||||
|
|
|
@ -62,6 +62,73 @@ fragment =
|
||||||
gl_FragColor.a = 1.0;
|
gl_FragColor.a = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelMatrix;
|
||||||
|
uniform highp mat4 u_viewProjectionMatrix;
|
||||||
|
uniform highp mat4 u_normalMatrix;
|
||||||
|
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in highp vec4 a_normal;
|
||||||
|
in highp vec2 a_uvs;
|
||||||
|
|
||||||
|
out highp vec3 f_vertex;
|
||||||
|
out highp vec3 f_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 world_space_vert = u_modelMatrix * a_vertex;
|
||||||
|
gl_Position = u_viewProjectionMatrix * world_space_vert;
|
||||||
|
|
||||||
|
f_vertex = world_space_vert.xyz;
|
||||||
|
f_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform mediump vec4 u_ambientColor;
|
||||||
|
uniform mediump vec4 u_diffuseColor;
|
||||||
|
uniform mediump vec4 u_specularColor;
|
||||||
|
uniform highp vec3 u_lightPosition;
|
||||||
|
uniform mediump float u_shininess;
|
||||||
|
uniform highp vec3 u_viewPosition;
|
||||||
|
|
||||||
|
uniform lowp float u_overhangAngle;
|
||||||
|
uniform lowp vec4 u_overhangColor;
|
||||||
|
|
||||||
|
in highp vec3 f_vertex;
|
||||||
|
in highp vec3 f_normal;
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
mediump vec4 finalColor = vec4(0.0);
|
||||||
|
|
||||||
|
// Ambient Component
|
||||||
|
finalColor += u_ambientColor;
|
||||||
|
|
||||||
|
highp vec3 normal = normalize(f_normal);
|
||||||
|
highp vec3 lightDir = normalize(u_lightPosition - f_vertex);
|
||||||
|
|
||||||
|
// Diffuse Component
|
||||||
|
highp float NdotL = clamp(abs(dot(normal, lightDir)), 0.0, 1.0);
|
||||||
|
finalColor += (NdotL * u_diffuseColor);
|
||||||
|
|
||||||
|
// Specular Component
|
||||||
|
// TODO: We should not do specularity for fragments facing away from the light.
|
||||||
|
highp vec3 reflectedLight = reflect(-lightDir, normal);
|
||||||
|
highp vec3 viewVector = normalize(u_viewPosition - f_vertex);
|
||||||
|
highp float NdotR = clamp(dot(viewVector, reflectedLight), 0.0, 1.0);
|
||||||
|
finalColor += pow(NdotR, u_shininess) * u_specularColor;
|
||||||
|
|
||||||
|
finalColor = (-normal.y > u_overhangAngle) ? u_overhangColor : finalColor;
|
||||||
|
|
||||||
|
frag_color = finalColor;
|
||||||
|
frag_color.a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_ambientColor = [0.3, 0.3, 0.3, 1.0]
|
u_ambientColor = [0.3, 0.3, 0.3, 1.0]
|
||||||
u_diffuseColor = [1.0, 0.79, 0.14, 1.0]
|
u_diffuseColor = [1.0, 0.79, 0.14, 1.0]
|
||||||
|
|
|
@ -63,6 +63,74 @@ fragment =
|
||||||
gl_FragColor.a = 1.0;
|
gl_FragColor.a = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelMatrix;
|
||||||
|
uniform highp mat4 u_viewProjectionMatrix;
|
||||||
|
uniform highp mat4 u_normalMatrix;
|
||||||
|
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in highp vec4 a_normal;
|
||||||
|
in highp vec2 a_uvs;
|
||||||
|
|
||||||
|
out highp vec3 v_position;
|
||||||
|
out highp vec3 v_vertex;
|
||||||
|
out highp vec3 v_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 world_space_vert = u_modelMatrix * a_vertex;
|
||||||
|
gl_Position = u_viewProjectionMatrix * world_space_vert;
|
||||||
|
|
||||||
|
v_position = gl_Position.xyz;
|
||||||
|
v_vertex = world_space_vert.xyz;
|
||||||
|
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform mediump vec4 u_ambientColor;
|
||||||
|
uniform mediump vec4 u_diffuseColor1;
|
||||||
|
uniform mediump vec4 u_diffuseColor2;
|
||||||
|
uniform mediump vec4 u_specularColor;
|
||||||
|
uniform highp vec3 u_lightPosition;
|
||||||
|
uniform mediump float u_shininess;
|
||||||
|
uniform highp vec3 u_viewPosition;
|
||||||
|
|
||||||
|
uniform mediump float u_width;
|
||||||
|
|
||||||
|
in highp vec3 v_position;
|
||||||
|
in highp vec3 v_vertex;
|
||||||
|
in highp vec3 v_normal;
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
mediump vec4 finalColor = vec4(0.0);
|
||||||
|
mediump vec4 diffuseColor = (mod((-v_position.x + v_position.y), u_width) < (u_width / 2.)) ? u_diffuseColor1 : u_diffuseColor2;
|
||||||
|
|
||||||
|
/* Ambient Component */
|
||||||
|
finalColor += u_ambientColor;
|
||||||
|
|
||||||
|
highp vec3 normal = normalize(v_normal);
|
||||||
|
highp vec3 lightDir = normalize(u_lightPosition - v_vertex);
|
||||||
|
|
||||||
|
/* Diffuse Component */
|
||||||
|
highp float NdotL = clamp(abs(dot(normal, lightDir)), 0.0, 1.0);
|
||||||
|
finalColor += (NdotL * diffuseColor);
|
||||||
|
|
||||||
|
/* Specular Component */
|
||||||
|
/* TODO: We should not do specularity for fragments facing away from the light.*/
|
||||||
|
highp vec3 reflectedLight = reflect(-lightDir, normal);
|
||||||
|
highp vec3 viewVector = normalize(u_viewPosition - v_vertex);
|
||||||
|
highp float NdotR = clamp(dot(viewVector, reflectedLight), 0.0, 1.0);
|
||||||
|
finalColor += pow(NdotR, u_shininess) * u_specularColor;
|
||||||
|
|
||||||
|
frag_color = finalColor;
|
||||||
|
frag_color.a = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_ambientColor = [0.3, 0.3, 0.3, 1.0]
|
u_ambientColor = [0.3, 0.3, 0.3, 1.0]
|
||||||
u_diffuseColor1 = [1.0, 0.5, 0.5, 1.0]
|
u_diffuseColor1 = [1.0, 0.5, 0.5, 1.0]
|
||||||
|
|
|
@ -48,6 +48,59 @@ fragment =
|
||||||
gl_FragColor.a = u_opacity;
|
gl_FragColor.a = u_opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vertex41core =
|
||||||
|
#version 410
|
||||||
|
uniform highp mat4 u_modelMatrix;
|
||||||
|
uniform highp mat4 u_viewProjectionMatrix;
|
||||||
|
uniform highp mat4 u_normalMatrix;
|
||||||
|
|
||||||
|
in highp vec4 a_vertex;
|
||||||
|
in highp vec4 a_normal;
|
||||||
|
in highp vec2 a_uvs;
|
||||||
|
|
||||||
|
out highp vec3 v_vertex;
|
||||||
|
out highp vec3 v_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 world_space_vert = u_modelMatrix * a_vertex;
|
||||||
|
gl_Position = u_viewProjectionMatrix * world_space_vert;
|
||||||
|
|
||||||
|
v_vertex = world_space_vert.xyz;
|
||||||
|
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment41core =
|
||||||
|
#version 410
|
||||||
|
uniform mediump vec4 u_ambientColor;
|
||||||
|
uniform mediump vec4 u_diffuseColor;
|
||||||
|
uniform highp vec3 u_lightPosition;
|
||||||
|
|
||||||
|
uniform mediump float u_opacity;
|
||||||
|
|
||||||
|
in highp vec3 v_vertex;
|
||||||
|
in highp vec3 v_normal;
|
||||||
|
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
mediump vec4 finalColor = vec4(0.0);
|
||||||
|
|
||||||
|
/* Ambient Component */
|
||||||
|
finalColor += u_ambientColor;
|
||||||
|
|
||||||
|
highp vec3 normal = normalize(v_normal);
|
||||||
|
highp vec3 lightDir = normalize(u_lightPosition - v_vertex);
|
||||||
|
|
||||||
|
/* Diffuse Component */
|
||||||
|
highp float NdotL = clamp(abs(dot(normal, lightDir)), 0.0, 1.0);
|
||||||
|
finalColor += (NdotL * u_diffuseColor);
|
||||||
|
|
||||||
|
frag_color = finalColor;
|
||||||
|
frag_color.a = u_opacity;
|
||||||
|
}
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
u_ambientColor = [0.1, 0.1, 0.1, 1.0]
|
u_ambientColor = [0.1, 0.1, 0.1, 1.0]
|
||||||
u_diffuseColor = [0.4, 0.4, 0.4, 1.0]
|
u_diffuseColor = [0.4, 0.4, 0.4, 1.0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue