Code cleanup

This commit is contained in:
enricoturri1966 2020-08-27 09:13:30 +02:00
parent 88b6835258
commit af30a3ab7e
6 changed files with 4 additions and 146 deletions

View file

@ -5,8 +5,7 @@ uniform vec4 uniform_color;
uniform float percent_outline_radius;
uniform float percent_center_radius;
vec4 customizable_color(float radius, vec4 color)
vec4 calc_color(float radius, vec4 color)
{
return ((radius < percent_center_radius) || (radius > 1.0 - percent_outline_radius)) ?
vec4(0.5 * color.rgb, color.a) : color;
@ -19,5 +18,5 @@ void main()
if (radius > 1.0)
discard;
gl_FragColor = customizable_color(radius, uniform_color);
gl_FragColor = calc_color(radius, uniform_color);
}

View file

@ -8,11 +8,8 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.0, 0.0, 1.0);
uniform vec4 light_intensity;
uniform vec4 uniform_color;
varying vec3 eye_position;
varying vec3 eye_normal;
float intensity;
void main()
{
vec3 normal = normalize(eye_normal);
@ -21,7 +18,7 @@ void main()
// Since these two are normalized the cosine is the dot product. Take the abs value to light the lines no matter in which direction the normal points.
float NdotL = abs(dot(normal, LIGHT_TOP_DIR));
intensity = light_intensity.x + NdotL * light_intensity.y;
float intensity = light_intensity.x + NdotL * light_intensity.y;
// Perform the same lighting calculation for the 2nd light source.
NdotL = abs(dot(normal, LIGHT_FRONT_DIR));

View file

@ -1,6 +1,5 @@
#version 110
varying vec3 eye_position;
varying vec3 eye_normal;
vec3 world_normal()
@ -16,6 +15,5 @@ void main()
{
vec4 world_position = vec4(gl_Vertex.xyz, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * world_position;
eye_position = (gl_ModelViewMatrix * world_position).xyz;
eye_normal = gl_NormalMatrix * world_normal();
}