# Source code of the vertex shader
fun vertex_shader_source: Text is abstract
lib/gamnit/programs.nit:498,2--499,43
redef var vertex_shader_source = """
// Vertex coordinates
attribute vec4 coord;
// Vertex color tint
attribute vec4 color;
// Vertex translation
attribute vec4 translation;
// Vertex scaling
attribute float scale;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Model view projection matrix
uniform mat4 mvp;
// Current world time, in seconds
uniform float time;
// Rotation matrix
attribute vec4 rotation_row0;
attribute vec4 rotation_row1;
attribute vec4 rotation_row2;
attribute vec4 rotation_row3;
// Animation speed, frames per seconds
attribute float a_fps;
// Number of frames in the animation
attribute float a_n_frames;
// World coordinate of the animation (for aspect ratio)
attribute vec2 a_coord;
// Animation texture coordinates of the first frame
attribute vec2 a_tex_coord;
// Animation texture coordinates difference between frames
attribute vec2 a_tex_diff;
// Animation start time, in reference to `time`
attribute float a_start;
// Number of loops to play of the animation
attribute float a_loops;
mat4 rotation()
{
return mat4(rotation_row0, rotation_row1, rotation_row2, rotation_row3);
}
// Output to the fragment shader
varying vec4 v_color;
varying vec2 v_coord;
// Is there an active animation?
varying float v_animated;
void main()
{
vec3 c; // coords
float end = a_start + a_loops/a_fps*a_n_frames;
if (a_fps != 0.0 && (a_loops == -1.0 || time < end)) {
// in animation
float frame = mod(floor((time-a_start)*a_fps), a_n_frames);
v_coord = a_tex_coord + a_tex_diff*frame;
c = vec3(a_coord, coord.z);
v_animated = 1.0;
} else {
// static
v_coord = tex_coord;
c = coord.xyz;
v_animated = 0.0;
}
gl_Position = (vec4(c * scale, 1.0) * rotation() + translation)* mvp;
v_color = vec4(color.rgb*color.a, color.a);
}
""" @ glsl_vertex_shader
lib/gamnit/flat/flat_core.nit:638,2--720,26
redef var vertex_shader_source = """
// Vertex coordinates
attribute vec3 coord;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Output to the fragment shader
varying vec2 v_coord;
void main()
{
gl_Position = vec4(coord, 1.0);
v_coord = tex_coord;
}
""" @ glsl_vertex_shader
lib/gamnit/dynamic_resolution.nit:308,2--323,26
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
redef var vertex_shader_source = """
// Vertex coordinates
attribute vec4 coord;
// Vertex translation
uniform vec4 translation;
// Vertex scaling
uniform float scale;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Vertex normal
attribute vec3 normal;
// Model view projection matrix
uniform mat4 mvp;
// Rotation matrix
uniform mat4 rotation;
// Output for the fragment shader
varying vec2 v_tex_coord;
void main()
{
vec4 pos = (vec4(coord.xyz * scale, 1.0) * rotation + translation);
gl_Position = pos * mvp;
// Pass varyings to the fragment shader
v_tex_coord = vec2(tex_coord.x, 1.0 - tex_coord.y);
}
""" @ glsl_vertex_shader
lib/gamnit/depth/shadow.nit:348,2--381,26
redef var vertex_shader_source = """
// Vertex coordinates
attribute vec3 coord;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Output to the fragment shader
varying vec2 v_coord;
void main()
{
gl_Position = vec4(coord, 1.0);
v_coord = tex_coord;
}
""" @ glsl_vertex_shader
lib/gamnit/depth/shadow.nit:432,2--447,26
redef var vertex_shader_source = """
// Coordinates of particle effects
attribute vec4 center;
// Particles color tint
attribute vec4 color;
varying vec4 v_color;
// Per particle scaling
attribute float scale;
// Model view projection matrix
uniform mat4 mvp;
// Time-to-live of each particle
attribute float ttl;
// Creation time of each particle
attribute float ot;
// Current time
uniform float t;
void main()
{
// Pass varyings to the fragment shader
v_color = color;
float dt = t - ot;
float pt = dt/ttl;
// Discard expired or not yet created particles
if (dt > ttl || dt < 0.0) {
gl_PointSize = 0.0;
return;
}
{{{vertex_shader_core}}}
}
"""
lib/gamnit/depth/particles.nit:172,2--211,5
redef var vertex_shader_source = """
// Vertex coordinates
attribute vec4 coord;
// Vertex translation
uniform vec4 translation;
// Vertex scaling
uniform float scale;
// Vertex coordinates on textures
attribute vec2 tex_coord;
// Model view projection matrix
uniform mat4 mvp;
// Model rotation
uniform mat4 rotation;
// Output for the fragment shader
varying vec2 v_tex_coord;
void main()
{
v_tex_coord = vec2(tex_coord.x, 1.0 - tex_coord.y);
gl_Position = (vec4(coord.xyz * scale, 1.0) * rotation + translation) * mvp;
}
""" @ glsl_vertex_shader
lib/gamnit/depth/selection.nit:240,2--268,26