Pong/resources/shaders/Portrait.frag

31 lines
784 B
GLSL
Raw Normal View History

2024-07-01 19:55:24 -07:00
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec2 fUv;
layout(location = 1) in flat uint fChannels;
layout(location = 0) out vec4 result;
layout(binding = 1) uniform Opt
{
bool preMultiply;
vec4 multiplier;
} opt;
layout(binding = 2) uniform sampler2D render;
void main()
{
result = opt.multiplier;
if (fChannels == 1)
result *= vec4(texture(render, fUv).rrr, 1.0f);
else if (fChannels == 2)
result *= vec4(texture(render, fUv).rrr, texture(render, fUv).g);
else if (fChannels == 3)
result *= vec4(texture(render, fUv).rgb, 1.0f);
else if (fChannels == 4)
result *= texture(render, fUv).rgba;
if (opt.preMultiply)
result = vec4(result.rgb * result.a, result.a);
}