diff options
Diffstat (limited to 'render/vulkan/shaders/texture.frag')
-rw-r--r-- | render/vulkan/shaders/texture.frag | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/render/vulkan/shaders/texture.frag b/render/vulkan/shaders/texture.frag new file mode 100644 index 00000000..7a7b8c57 --- /dev/null +++ b/render/vulkan/shaders/texture.frag @@ -0,0 +1,25 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D tex; + +layout(location = 0) in vec2 uv; +layout(location = 0) out vec4 out_color; + +layout(push_constant) uniform UBO { + layout(offset = 80) float alpha; +} data; + +void main() { + out_color = textureLod(tex, uv, 0); + + // We expect this shader to output pre-alpha-multiplied color values. + // alpha < 0.0 means that this shader should ignore the texture's alpha + // value. + if (data.alpha < 0.0) { + out_color.a = -data.alpha; + out_color.rgb *= -data.alpha; + } else { + out_color *= data.alpha; + } +} + |