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;
2013-06-23 09:13:01 +00:00
void main()
{
2014-07-10 08:33:07 +00:00
#ifndef SIMPLE
- decided to restrict the 2.0 beta to OpenGL 4.x with GL_ARB_buffer_storage extension and removed all code for supporting older versions.
Sadly, anything else makes no sense.
All the recently made changes live or die, depending on this extension's presence.
Without it, there are major performance issues with the buffer uploads. All of the traditional buffer upload methods are without exception horrendously slow, especially in the context of a Doom engine where frequent small updates are required.
It could be solved with a complete restructuring of the engine, of course, but that's hardly worth the effort, considering it's only for legacy hardware whose market share will inevitably shrink considerably over the next years.
And even then, under the best circumstances I'd still get the same performance as the old immediate mode renderer in GZDoom 1.x and still couldn't implement the additions I'd like to make.
So, since I need to keep GZDoom 1.x around anyway for older GL 2.x hardware, it may as well serve for 3.x hardware, too. It's certainly less work than constantly trying to find workarounds for the older hardware's limitations that cost more time than working on future-proofing the engine.
This new, trimmed down 4.x renderer runs on a core profile configuration and uses persistently mapped buffers for nearly everything that is getting transferred to the GPU. (The global uniforms are still being used as such but they'll be phased out after the first beta release.
2014-08-01 20:42:39 +00:00
vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor);
2014-07-10 08:33:07 +00:00
#else
- decided to restrict the 2.0 beta to OpenGL 4.x with GL_ARB_buffer_storage extension and removed all code for supporting older versions.
Sadly, anything else makes no sense.
All the recently made changes live or die, depending on this extension's presence.
Without it, there are major performance issues with the buffer uploads. All of the traditional buffer upload methods are without exception horrendously slow, especially in the context of a Doom engine where frequent small updates are required.
It could be solved with a complete restructuring of the engine, of course, but that's hardly worth the effort, considering it's only for legacy hardware whose market share will inevitably shrink considerably over the next years.
And even then, under the best circumstances I'd still get the same performance as the old immediate mode renderer in GZDoom 1.x and still couldn't implement the additions I'd like to make.
So, since I need to keep GZDoom 1.x around anyway for older GL 2.x hardware, it may as well serve for 3.x hardware, too. It's certainly less work than constantly trying to find workarounds for the older hardware's limitations that cost more time than working on future-proofing the engine.
This new, trimmed down 4.x renderer runs on a core profile configuration and uses persistently mapped buffers for nearly everything that is getting transferred to the GPU. (The global uniforms are still being used as such but they'll be phased out after the first beta release.
2014-08-01 20:42:39 +00:00
vec4 worldcoord = ModelMatrix * aPosition;
2014-07-10 08:33:07 +00:00
#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);
2016-01-30 22:01:11 +00:00
2016-04-26 09:31:27 +00:00
if (uSplitBottomPlane.z != 0.0)
2016-01-30 22:01:11 +00:00
{
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);
}
2014-07-10 08:33:07 +00:00
#endif
2013-06-23 09:13:01 +00:00
#ifdef SPHEREMAP
vec3 u = normalize(eyeCoordPos.xyz);
- decided to restrict the 2.0 beta to OpenGL 4.x with GL_ARB_buffer_storage extension and removed all code for supporting older versions.
Sadly, anything else makes no sense.
All the recently made changes live or die, depending on this extension's presence.
Without it, there are major performance issues with the buffer uploads. All of the traditional buffer upload methods are without exception horrendously slow, especially in the context of a Doom engine where frequent small updates are required.
It could be solved with a complete restructuring of the engine, of course, but that's hardly worth the effort, considering it's only for legacy hardware whose market share will inevitably shrink considerably over the next years.
And even then, under the best circumstances I'd still get the same performance as the old immediate mode renderer in GZDoom 1.x and still couldn't implement the additions I'd like to make.
So, since I need to keep GZDoom 1.x around anyway for older GL 2.x hardware, it may as well serve for 3.x hardware, too. It's certainly less work than constantly trying to find workarounds for the older hardware's limitations that cost more time than working on future-proofing the engine.
This new, trimmed down 4.x renderer runs on a core profile configuration and uses persistently mapped buffers for nearly everything that is getting transferred to the GPU. (The global uniforms are still being used as such but they'll be phased out after the first beta release.
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.
2014-07-14 19:14:43 +00:00
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-09-02 08:31:48 +00:00
vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 1.0);
2013-06-23 09:13:01 +00:00
#endif
2014-05-12 12:45:41 +00:00
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-01-27 11:30:55 +00:00
{
2016-04-27 00:10:42 +00:00
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
2016-01-27 11:30:55 +00:00
}
2016-04-27 00:10:42 +00:00
// clip planes used for translucency splitting
2016-01-27 11:32:39 +00:00
gl_ClipDistance[1] = worldcoord.y - uClipSplit.x;
gl_ClipDistance[2] = uClipSplit.y - worldcoord.y;
2016-01-30 22:01:11 +00:00
2013-06-23 09:13:01 +00:00
}