qzdoom-gpl/wadsrc/static/shaders/glsl/main.vp

69 lines
2.1 KiB
Text
Raw Normal View History

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;
void main()
{
#ifndef SIMPLE
2014-08-01 20:42:39 +00:00
vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor);
#else
2014-08-01 20:42:39 +00:00
vec4 worldcoord = ModelMatrix * aPosition;
#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);
if (uSplitBottomPlane.z != 0.0)
{
gl_ClipDistance[3] = -((uSplitTopPlane.w + uSplitTopPlane.x * worldcoord.x + uSplitTopPlane.y * worldcoord.z) * uSplitTopPlane.z) - worldcoord.y;
gl_ClipDistance[4] = worldcoord.y + ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z);
}
#endif
#ifdef SPHEREMAP
vec3 u = normalize(eyeCoordPos.xyz);
2014-08-01 20:42:39 +00:00
vec4 n = normalize(TextureMatrix * vec4(aTexCoord.x, 0.0, aTexCoord.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 * vec4(aTexCoord, 0.0, 1.0);
#endif
gl_Position = ProjectionMatrix * eyeCoordPos;
2015-04-05 18:20:56 +00:00
2016-04-27 00:10:42 +00:00
#if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE
gl_ClipVertex = eyeCoordPos;
#endif
2015-04-05 18:20:56 +00:00
// clip planes used for reflective flats
2016-04-27 00:10:42 +00:00
if (uClipHeightDirection != 0.0)
{
2016-04-27 00:10:42 +00:00
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
}
2016-04-27 00:10:42 +00:00
// clip planes used for translucency splitting
gl_ClipDistance[1] = worldcoord.y - uClipSplit.x;
gl_ClipDistance[2] = uClipSplit.y - worldcoord.y;
}