Merge pull request #283 from jekstrand/vk-shader-fixes

vulkan: Add locations to fragment shader inputs
This commit is contained in:
Baldur Karlsson
2016-06-15 14:14:49 -04:00
committed by GitHub
2 changed files with 10 additions and 16 deletions
+6 -9
View File
@@ -25,22 +25,19 @@
layout (binding = 3) uniform sampler2D tex0;
layout (location = 0) out vec4 color_out;
in v2f
{
vec4 tex;
vec2 glyphuv;
} IN;
layout (location = 0) in vec4 tex;
layout (location = 1) in vec2 glyphuv;
void main(void)
{
float text = 0;
if(IN.glyphuv.x >= 0.0f && IN.glyphuv.x <= 1.0f &&
IN.glyphuv.y >= 0.0f && IN.glyphuv.y <= 1.0f)
if(glyphuv.x >= 0.0f && glyphuv.x <= 1.0f &&
glyphuv.y >= 0.0f && glyphuv.y <= 1.0f)
{
vec2 uv;
uv.x = mix(IN.tex.x, IN.tex.z, IN.glyphuv.x);
uv.y = mix(IN.tex.y, IN.tex.w, IN.glyphuv.y);
uv.x = mix(tex.x, tex.z, glyphuv.x);
uv.y = mix(tex.y, tex.w, glyphuv.y);
text = texture(tex0, uv.xy).x;
}
+4 -7
View File
@@ -28,11 +28,8 @@ out gl_PerVertex
float gl_PointSize;
};
out v2f
{
vec4 tex;
vec2 glyphuv;
} OUT;
layout (location = 0) out vec4 tex;
layout (location = 1) out vec2 glyphuv;
void main(void)
{
@@ -50,6 +47,6 @@ void main(void)
FontGlyphData G = glyphs.data[ str.chars[strindex].x ];
gl_Position = vec4(charPos.xy*2.0f*general.TextSize*general.FontScreenAspect.xy + vec2(-1, -1), 1, 1);
OUT.glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
OUT.tex = G.uvdata * general.CharacterSize.xyxy;
glyphuv.xy = (pos.xy - G.posdata.xy) * G.posdata.zw;
tex = G.uvdata * general.CharacterSize.xyxy;
}