update resources and localization

This commit is contained in:
QIDI TECH
2024-11-09 14:38:04 +08:00
parent a616ed7278
commit c9ec3da208
73 changed files with 155634 additions and 102254 deletions

View File

@@ -23,25 +23,25 @@ attribute vec3 v_normal;
// x = tainted, y = specular;
varying vec2 intensity;
varying vec3 world_position;
varying vec3 position;
void main()
{
// First transform the normal into camera space and normalize the result.
vec3 normal = normalize(view_normal_matrix * v_normal);
vec3 eye_normal = normalize(view_normal_matrix * v_normal);
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
vec4 position = view_model_matrix * vec4(v_position, 1.0);
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
vec4 eye_position = view_model_matrix * vec4(v_position, 1.0);
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
// Perform the same lighting calculation for the 2nd light source (no specular applied).
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
world_position = v_position;
gl_Position = projection_matrix * position;
position = v_position;
gl_Position = projection_matrix * eye_position;
}