redef var vertex_shader_source = """
// Vertex coordinates
attribute vec4 coord;
// Vertex translation
attribute vec4 translation;
// Vertex scaling
attribute float scale;
attribute float alpha;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Vertex normal
attribute vec3 normal;
// Camera model view projection matrix
uniform mat4 mvp;
// Actor rotation
attribute vec4 rotation_row0;
attribute vec4 rotation_row1;
attribute vec4 rotation_row2;
attribute vec4 rotation_row3;
mat4 rotation()
{
return mat4(rotation_row0, rotation_row1, rotation_row2, rotation_row3);
}
// Lights config
uniform lowp int light_kind;
uniform vec3 light_center;
uniform mat4 light_mvp;
// Coordinates of the camera
uniform vec3 camera;
// Output for the fragment shader
varying vec2 v_tex_coord;
varying vec3 v_normal;
varying vec4 v_to_light;
varying vec4 v_to_camera;
varying vec4 v_depth_pos;
varying float v_alpha;
void main()
{
mat4 rotation = rotation();
vec4 pos = (vec4(coord.xyz * scale, 1.0) * rotation + translation);
gl_Position = pos * mvp;
v_depth_pos = (pos * light_mvp) * 0.5 + 0.5;
// Pass varyings to the fragment shader
v_tex_coord = vec2(tex_coord.x, 1.0 - tex_coord.y);
v_normal = normalize(vec4(normal, 0.0) * rotation).xyz;
v_to_camera = normalize(vec4(camera, 1.0) - pos);
if (light_kind == 0) {
// No light
} else if (light_kind == 1) {
// Parallel
v_to_light = normalize(vec4(light_center, 1.0));
} else {
// Point light (and others?)
v_to_light = normalize(vec4(light_center, 1.0) - pos);
}
v_alpha = alpha;
}
""" @ glsl_vertex_shader
lib/gamnit/depth/more_materials.nit:318,2--390,26