Tech ENABLE_GL_CORE_PROFILE - Use OpenGL core profile context - 1st installment

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2022-03-24 14:45:59 +01:00
parent 1b09628b0d
commit 389dc36053
39 changed files with 542 additions and 46 deletions

View file

@ -5,7 +5,9 @@ uniform vec4 bottom_color;
in vec2 tex_coord;
out vec4 out_color;
void main()
{
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
out_color = mix(bottom_color, top_color, tex_coord.y);
}

View file

@ -2,7 +2,9 @@
uniform vec4 uniform_color;
out vec4 out_color;
void main()
{
gl_FragColor = uniform_color;
out_color = uniform_color;
}

View file

@ -4,7 +4,9 @@ uniform sampler2D uniform_texture;
in vec2 tex_coord;
out vec4 out_color;
void main()
{
gl_FragColor = texture(uniform_texture, tex_coord);
out_color = texture(uniform_texture, tex_coord);
}

View file

@ -42,6 +42,8 @@ in vec4 world_pos;
in float world_normal_z;
in vec3 eye_normal;
out vec4 out_color;
void main()
{
if (any(lessThan(clipping_planes_dots, ZERO)))
@ -72,8 +74,8 @@ void main()
#ifdef ENABLE_ENVIRONMENT_MAP
if (use_environment_tex)
gl_FragColor = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
out_color = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
else
#endif
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
out_color = vec4(vec3(intensity.y) + color * intensity.x, alpha);
}

View file

@ -6,7 +6,9 @@ uniform float emission_factor;
// x = tainted, y = specular;
in vec2 intensity;
out vec4 out_color;
void main()
{
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
out_color = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
}

View file

@ -6,7 +6,9 @@ uniform float emission_factor;
// x = tainted, y = specular;
in vec2 intensity;
out vec4 out_color;
void main()
{
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
out_color = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
}

View file

@ -5,7 +5,9 @@ uniform sampler2D Texture;
in vec2 Frag_UV;
in vec4 Frag_Color;
out vec4 out_color;
void main()
{
gl_FragColor = Frag_Color * texture(Texture, Frag_UV.st);
out_color = Frag_Color * texture(Texture, Frag_UV.st);
}

View file

@ -0,0 +1,27 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
const vec2 aa_radius = vec2(1.5);
uniform vec4 uniform_color;
in float line_width;
in float line_length;
in vec2 uv;
out vec4 out_color;
void main()
{
// We render a quad that is fattened by r, giving total width of the line to be w+r. We want smoothing to happen
// around w, so that the edge is properly smoothed out. As such, in the smoothstep function we have:
// Far edge : 1.0 = (w+r) / (w+r)
// Close edge : 1.0 - (2r / (w+r)) = (w+r)/(w+r) - 2r/(w+r)) = (w-r) / (w+r)
// This way the smoothing is centered around 'w'.
out_color = uniform_color;
float au = 1.0 - smoothstep( 1.0 - ((2.0 * aa_radius[0]) / line_width), 1.0, abs(uv.x / line_width) );
float av = 1.0 - smoothstep( 1.0 - ((2.0 * aa_radius[1]) / line_length), 1.0, abs(uv.y / line_length) );
out_color.a *= min(av, au);
}

View file

@ -0,0 +1,57 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
const vec2 aa_radius = vec2(1.5);
uniform vec2 viewport_size;
uniform float width;
out float line_width;
out float line_length;
out vec2 uv;
void main()
{
float u_width = viewport_size[0];
float u_height = viewport_size[1];
float u_aspect_ratio = u_height / u_width;
vec2 ndc_a = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
vec2 ndc_b = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
vec2 line_vector = ndc_b - ndc_a;
vec2 viewport_line_vector = line_vector * viewport_size;
vec2 dir = normalize(viewport_line_vector);
vec2 normal_dir = vec2(-dir.y, dir.x);
line_width = max(1.0, width) + aa_radius[0];
line_length = length(viewport_line_vector) + 2.0 * aa_radius[1];
vec2 normal = vec2(line_width / u_width, line_width / u_height) * normal_dir;
vec2 extension = vec2(aa_radius[1] / u_width, aa_radius[1] / u_height) * dir;
float half_line_width = line_width * 0.5;
float half_line_length = line_length * 0.5;
uv = vec2(-half_line_width, half_line_length);
gl_Position = vec4((ndc_a + normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
EmitVertex();
uv = vec2(-half_line_width, -half_line_length);
gl_Position = vec4((ndc_a - normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
EmitVertex();
uv = vec2(half_line_width, half_line_length);
gl_Position = vec4((ndc_b + normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
EmitVertex();
uv = vec2(half_line_width, -half_line_length);
gl_Position = vec4((ndc_b - normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
EmitVertex();
EndPrimitive();
}

View file

@ -0,0 +1,13 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
uniform mat4 view_model_matrix;
uniform mat4 projection_matrix;
in vec3 v_position;
void main()
{
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
}

View file

@ -2,7 +2,9 @@
uniform vec4 uniform_color;
out vec4 out_color;
void main()
{
gl_FragColor = uniform_color;
out_color = uniform_color;
}

View file

@ -27,6 +27,8 @@ uniform mat3 normal_matrix;
in vec3 clipping_planes_dots;
in vec4 model_pos;
out vec4 out_color;
void main()
{
if (any(lessThan(clipping_planes_dots, ZERO)))
@ -59,5 +61,5 @@ void main()
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
out_color = vec4(vec3(intensity.y) + color * intensity.x, alpha);
}

View file

@ -8,7 +8,8 @@ uniform bool transparent_background;
uniform bool svg_source;
in vec2 tex_coord;
out vec4 frag_color;
out vec4 out_color;
vec4 svg_color()
{
@ -33,5 +34,5 @@ void main()
{
vec4 color = svg_source ? svg_color() : non_svg_color();
color.a = transparent_background ? color.a * 0.5 : color.a;
frag_color = color;
out_color = color;
}

View file

@ -11,9 +11,11 @@ uniform vec3 world_center;
in vec2 intensity;
in vec3 world_position;
out vec4 out_color;
void main()
{
vec3 delta = world_position - world_center;
vec4 color = delta.x * delta.y * delta.z > 0.0 ? BLACK : WHITE;
gl_FragColor = vec4(vec3(intensity.y) + color.rgb * (intensity.x + emission_factor), 1.0);
out_color = vec4(vec3(intensity.y) + color.rgb * (intensity.x + emission_factor), 1.0);
}

View file

@ -15,6 +15,8 @@ in vec2 intensity;
in float object_z;
out vec4 out_color;
void main()
{
float object_z_row = z_to_texture_row * object_z;
@ -37,5 +39,5 @@ void main()
color = mix(texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.),
texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod);
// Mix the final color.
gl_FragColor = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
out_color = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
}