gzdoom/wadsrc/static/shaders/glsl/swshader.fp
Christoph Oelckers ad7aaa8f2a - specify fragment output locations in the shader source.
OpenGL has been supporting this since version 3.3 and Vulkan requires it so it's the way to go.
2018-06-12 23:52:33 +02:00

31 lines
647 B
GLSL

in vec4 vTexCoord;
layout(location=0) out vec4 FragColor;
vec4 TextureLookup(vec2 tex_coord)
{
if (uTextureMode == 1)
{
float index = texture(tex, tex_coord).x;
index = index * 256.0 + 0.5; // We only have 256 color palettes here.
return texture(texture2, vec2(index, 0.5));
}
else
{
return texture(tex, tex_coord);
}
}
void main()
{
if (uFixedColormap == 0)
{
FragColor = TextureLookup(vTexCoord.xy);
}
else
{
vec4 frag = TextureLookup(vTexCoord.xy);
float gray = dot(frag.rgb, vec3(0.4, 0.56, 0.14));
vec4 cm = uFixedColormapStart + gray * uFixedColormapRange;
FragColor = vec4(clamp(cm.rgb, 0.0, 1.0), 1.0);
}
}