mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-15 23:00:52 +00:00
8368331481
* Colors can npw be defined per sidedef, not only per sector. * Gradients can be selectively disabled or vertically flipped per wall tier. * Gradients can be clamped to their respective tier, i.e top and bottom of the tier, not the front sector defines where it starts. The per-wall colors are implemented for hardware and softpoly renderer only, but not for the classic software renderer, because its code is far too scattered to do this efficiently. # Conflicts: # src/hwrenderer/scene/hw_renderstate.h # src/hwrenderer/scene/hw_walls.cpp # Conflicts: # src/gl/scene/gl_walls_draw.cpp
108 lines
3.6 KiB
Text
108 lines
3.6 KiB
Text
|
|
in vec4 aPosition;
|
|
in vec2 aTexCoord;
|
|
in vec4 aColor;
|
|
#ifndef SIMPLE // we do not need these for simple shaders
|
|
in vec4 aVertex2;
|
|
in vec4 aNormal;
|
|
out vec4 pixelpos;
|
|
out vec3 glowdist;
|
|
out vec3 gradientdist;
|
|
|
|
out vec4 vWorldNormal;
|
|
out vec4 vEyeNormal;
|
|
#endif
|
|
|
|
out vec4 vTexCoord;
|
|
out vec4 vColor;
|
|
|
|
void main()
|
|
{
|
|
vec2 parmTexCoord;
|
|
vec4 parmPosition;
|
|
|
|
#ifndef USE_QUAD_DRAWER
|
|
parmTexCoord = aTexCoord;
|
|
parmPosition = aPosition;
|
|
#else
|
|
if (uQuadMode == 0)
|
|
{
|
|
parmTexCoord = aTexCoord;
|
|
parmPosition = aPosition;
|
|
}
|
|
else
|
|
{
|
|
parmPosition = uQuadVertices[int(aPosition.x)];
|
|
parmTexCoord = uQuadTexCoords[int(aPosition.x)].st;
|
|
}
|
|
#endif
|
|
|
|
#ifndef SIMPLE
|
|
vec4 worldcoord = ModelMatrix * mix(parmPosition, aVertex2, uInterpolationFactor);
|
|
#else
|
|
vec4 worldcoord = ModelMatrix * parmPosition;
|
|
#endif
|
|
|
|
vec4 eyeCoordPos = ViewMatrix * worldcoord;
|
|
|
|
vColor = aColor;
|
|
|
|
#ifndef SIMPLE
|
|
pixelpos.xyz = worldcoord.xyz;
|
|
pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w;
|
|
|
|
if (uGlowTopColor.a > 0 || uGlowBottomColor.a > 0)
|
|
{
|
|
float topatpoint = (uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z;
|
|
float bottomatpoint = (uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z;
|
|
glowdist.x = topatpoint - worldcoord.y;
|
|
glowdist.y = worldcoord.y - bottomatpoint;
|
|
glowdist.z = clamp(glowdist.x / (topatpoint - bottomatpoint), 0.0, 1.0);
|
|
}
|
|
|
|
if (uObjectColor2.a != 0)
|
|
{
|
|
float topatpoint = (uGradientTopPlane.w + uGradientTopPlane.x * worldcoord.x + uGradientTopPlane.y * worldcoord.z) * uGradientTopPlane.z;
|
|
float bottomatpoint = (uGradientBottomPlane.w + uGradientBottomPlane.x * worldcoord.x + uGradientBottomPlane.y * worldcoord.z) * uGradientBottomPlane.z;
|
|
gradientdist.x = topatpoint - worldcoord.y;
|
|
gradientdist.y = worldcoord.y - bottomatpoint;
|
|
gradientdist.z = clamp(gradientdist.x / (topatpoint - bottomatpoint), 0.0, 1.0);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
vWorldNormal = NormalModelMatrix * vec4(normalize(aNormal.xyz), 1.0);
|
|
vEyeNormal = NormalViewMatrix * vWorldNormal;
|
|
#endif
|
|
|
|
#ifdef SPHEREMAP
|
|
vec3 u = normalize(eyeCoordPos.xyz);
|
|
vec4 n = normalize(TextureMatrix * vec4(parmTexCoord.x, 0.0, parmTexCoord.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(parmTexCoord, 0.0, 1.0);
|
|
#endif
|
|
|
|
gl_Position = ProjectionMatrix * eyeCoordPos;
|
|
|
|
if (uClipHeightDirection != 0.0) // clip planes used for reflective flats
|
|
{
|
|
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
|
|
}
|
|
else if (uClipLine.x > -1000000.0) // and for line portals - this will never be active at the same time as the reflective planes clipping so it can use the same hardware clip plane.
|
|
{
|
|
gl_ClipDistance[0] = -( (worldcoord.z - uClipLine.y) * uClipLine.z + (uClipLine.x - worldcoord.x) * uClipLine.w ) + 1.0/32768.0; // allow a tiny bit of imprecisions for colinear linedefs.
|
|
}
|
|
|
|
// clip planes used for translucency splitting
|
|
gl_ClipDistance[1] = worldcoord.y - uClipSplit.x;
|
|
gl_ClipDistance[2] = uClipSplit.y - worldcoord.y;
|
|
|
|
}
|