vulkan: Update texture shader to do AA
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
#include "rect.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inTexCoord;
|
||||
layout(location = 1) in Rect inRect;
|
||||
layout(location = 2) in vec2 inTexCoord;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D inTexture;
|
||||
|
||||
@@ -11,5 +13,6 @@ layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = clip (inPos, texture (inTexture, inTexCoord));
|
||||
float alpha = rect_coverage (inRect, inPos);
|
||||
color = clip_scaled (inPos, texture (inTexture, inTexCoord) * alpha);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,20 @@
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
#include "common.vert.glsl"
|
||||
#include "rect.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTexRect;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out vec2 outTexCoord;
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
layout(location = 1) out flat Rect outRect;
|
||||
layout(location = 2) out vec2 outTexCoord;
|
||||
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
|
||||
Rect r = rect_from_gsk (inRect);
|
||||
vec2 pos = set_position_from_rect (r);
|
||||
|
||||
outPos = pos;
|
||||
|
||||
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
|
||||
rect.zw / inRect.zw);
|
||||
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
||||
inTexRect.zw * texrect.zw);
|
||||
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
||||
outRect = r;
|
||||
outTexCoord = scale_tex_coord (pos, r, inTexRect);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user