mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
eb9d2d9917
- reactivate alpha testing per fixed function pipeline - use the 'modern' way to define clip planes (GL_CLIP_DISTANCE). This is far more portable than the old glClipPlane method and a lot more robust than checking this in the fragment shader.
70 lines
1.8 KiB
Text
70 lines
1.8 KiB
Text
|
|
in vec4 aPosition;
|
|
in vec2 aTexCoord;
|
|
in vec4 aColor;
|
|
#ifndef SIMPLE // we do not need these for simple shaders
|
|
in vec4 aVertex2;
|
|
out vec4 pixelpos;
|
|
out vec2 glowdist;
|
|
#endif
|
|
|
|
out vec4 vTexCoord;
|
|
out vec4 vColor;
|
|
|
|
#ifdef UNIFORM_VB
|
|
uniform float fakeVB[100];
|
|
#endif
|
|
|
|
void main()
|
|
{
|
|
vec4 vert;
|
|
vec4 tc;
|
|
|
|
#ifdef UNIFORM_VB
|
|
|
|
if (aTexCoord.x >= 100000.0)
|
|
{
|
|
int fakeVI = int(aTexCoord.y)*5;
|
|
vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0);
|
|
tc = vec4(fakeVB[fakeVI+3], fakeVB[fakeVI+4], 0.0, 0.0);
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
vert = aPosition;
|
|
tc = vec4(aTexCoord, 0.0, 0.0);
|
|
}
|
|
|
|
#ifndef SIMPLE
|
|
vec4 worldcoord = ModelMatrix * mix(vert, aVertex2, uInterpolationFactor);
|
|
#else
|
|
vec4 worldcoord = ModelMatrix * vert;
|
|
#endif
|
|
|
|
vec4 eyeCoordPos = ViewMatrix * worldcoord;
|
|
|
|
vColor = aColor;
|
|
|
|
#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
|
|
|
|
#ifdef SPHEREMAP
|
|
vec3 u = normalize(eyeCoordPos.xyz);
|
|
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);
|
|
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);
|
|
vTexCoord.xy = sst;
|
|
#else
|
|
vTexCoord = TextureMatrix * tc;
|
|
#endif
|
|
|
|
gl_Position = ProjectionMatrix * eyeCoordPos;
|
|
gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom;
|
|
gl_ClipDistance[1] = uClipHeightTop - worldcoord.y;
|
|
}
|