mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-27 14:12:28 +00:00
a8e9c1832f
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.
48 lines
1.5 KiB
Text
48 lines
1.5 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;
|
|
|
|
void main()
|
|
{
|
|
#ifndef SIMPLE
|
|
vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor);
|
|
#else
|
|
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);
|
|
#endif
|
|
|
|
#ifdef SPHEREMAP
|
|
vec3 u = normalize(eyeCoordPos.xyz);
|
|
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, 0.0);
|
|
#endif
|
|
|
|
gl_Position = ProjectionMatrix * eyeCoordPos;
|
|
gl_ClipDistance[0] = worldcoord.y - uClipHeightBottom;
|
|
gl_ClipDistance[1] = uClipHeightTop - worldcoord.y;
|
|
}
|