2013-06-23 09:13:01 +00:00
2014-07-14 23:02:48 +00:00
in vec4 aPosition;
2014-07-14 22:59:01 +00:00
in vec2 aTexCoord;
2014-07-14 22:37:13 +00:00
in vec4 aColor;
2014-07-10 08:33:07 +00:00
#ifndef SIMPLE // we do not need these for simple shaders
2014-06-29 09:00:21 +00:00
in vec4 aVertex2;
2014-05-12 12:45:41 +00:00
out vec4 pixelpos;
out vec2 glowdist;
2014-07-10 08:33:07 +00:00
#endif
2013-06-23 09:13:01 +00:00
2014-07-14 22:19:41 +00:00
out vec4 vTexCoord;
out vec4 vColor;
2014-06-30 16:10:55 +00:00
#ifdef UNIFORM_VB
uniform float fakeVB[100];
#endif
2014-06-29 09:00:21 +00:00
2013-06-23 09:13:01 +00:00
void main()
{
2014-06-30 16:10:55 +00:00
vec4 vert;
vec4 tc;
2014-07-14 22:59:01 +00:00
#ifdef UNIFORM_VB
2014-06-30 16:10:55 +00:00
2014-07-15 00:26:23 +00:00
if (aTexCoord.x >= 100000.0)
2014-06-30 16:10:55 +00:00
{
2014-07-14 22:59:01 +00:00
int fakeVI = int(aTexCoord.y)*5;
2014-07-14 23:02:48 +00:00
vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0);
2014-06-30 16:10:55 +00:00
tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0);
}
else
2014-07-14 22:59:01 +00:00
#endif
2014-06-30 16:10:55 +00:00
{
2014-07-14 23:02:48 +00:00
vert = aPosition;
2014-07-14 22:59:01 +00:00
tc = vec4(aTexCoord, 0.0, 0.0);
2014-06-30 16:10:55 +00:00
}
2014-07-10 08:33:07 +00:00
#ifndef SIMPLE
vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor);
#else
vec4 worldcoord = ModelMatrix * vert;
#endif
2014-05-12 12:45:41 +00:00
vec4 eyeCoordPos = ViewMatrix * worldcoord;
2013-06-23 09:13:01 +00:00
2014-07-14 22:37:13 +00:00
vColor = aColor;
2014-05-12 12:45:41 +00:00
2014-07-10 08:33:07 +00:00
#ifndef SIMPLE
pixelpos.xyz = worldcoord.xyz;
pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w;
glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y;
glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z);
#endif
2013-06-23 09:13:01 +00:00
#ifdef SPHEREMAP
vec3 u = normalize(eyeCoordPos.xyz);
2014-07-14 19:14:43 +00:00
vec4 n = normalize(TextureMatrix * vec4(tc.x, 0.0, tc.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
vec3 r = reflect(u, n.xyz);
2013-06-23 09:13:01 +00:00
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5);
2014-07-14 22:19:41 +00:00
vTexCoord.xy = sst;
2014-05-12 12:45:41 +00:00
#else
2014-07-14 22:19:41 +00:00
vTexCoord = TextureMatrix * tc;
2013-06-23 09:13:01 +00:00
#endif
2014-05-12 12:45:41 +00:00
gl_Position = ProjectionMatrix * eyeCoordPos;
2014-07-17 00:37:18 +00:00
gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom;
gl_ClipDistance[1] = uClipHeightTop - worldcoord.y;
2013-06-23 09:13:01 +00:00
}