2012-04-04 21:39:46 +00:00
|
|
|
// Tree instance scheme:
|
|
|
|
// vertex - local position of quad vertex.
|
|
|
|
// normal - x y scaling, z number of varieties
|
|
|
|
// fog coord - rotation
|
|
|
|
// color - xyz of tree quad origin, replicated 4 times.
|
|
|
|
#version 120
|
|
|
|
|
2013-04-20 20:09:03 +00:00
|
|
|
uniform int season;
|
|
|
|
|
2012-04-04 21:39:46 +00:00
|
|
|
void main() {
|
|
|
|
|
|
|
|
// Texture coordinates
|
|
|
|
float numVarieties = gl_Normal.z;
|
2013-05-10 19:04:18 +00:00
|
|
|
float texFract = floor(fract(gl_MultiTexCoord0.x) * numVarieties) / (numVarieties * 4.0);
|
|
|
|
texFract += floor(gl_MultiTexCoord0.x) / (numVarieties * 4.0);
|
|
|
|
gl_TexCoord[0] = vec4(texFract + 0.5 * season, gl_MultiTexCoord0.y, 0.0, 0.0);
|
2012-04-04 21:39:46 +00:00
|
|
|
|
|
|
|
// Position and scaling
|
|
|
|
vec3 position = gl_Vertex.xyz * gl_Normal.xxy;
|
2012-07-31 20:44:38 +00:00
|
|
|
float sr = sin(gl_FogCoord + gl_Color.x);
|
|
|
|
float cr = cos(gl_FogCoord + gl_Color.x);
|
2012-04-04 21:39:46 +00:00
|
|
|
|
|
|
|
// Rotation of the generic quad to specific one for the tree.
|
|
|
|
position.xy = vec2(dot(position.xy, vec2(cr, sr)), dot(position.xy, vec2(-sr, cr)));
|
2012-07-31 20:44:38 +00:00
|
|
|
|
|
|
|
// Move to correct location (stored in gl_Color)
|
2012-04-04 21:39:46 +00:00
|
|
|
position = position + gl_Color.xyz;
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
|
|
|
|
|
|
|
|
// Color - white.
|
|
|
|
gl_FrontColor = vec4(1.0, 1.0, 1.0,1.0);
|
|
|
|
gl_BackColor = vec4(1.0, 1.0, 1.0,1.0);
|
|
|
|
}
|
|
|
|
|