mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 06:28:20 +00:00
Make SizeU/SizeV uniforms instead of per-vertex+reduce glyph info
This commit is contained in:
@ -1,41 +1,43 @@
|
||||
//shader:vertex
|
||||
#version 410
|
||||
|
||||
layout(location=0) in vec3 vertPosIn;
|
||||
layout(location=1) in vec2[4] vertUV0STIn; //[(u,v), (u+sizeU,v), (u,v+sizeV), (u+sizeU,v+sizeV)]
|
||||
layout(location=5) in vec4 vertColorIn;
|
||||
layout(location=6) in vec3 modelPos;
|
||||
layout(location=7) in vec3 modelScale;
|
||||
//aVertPos must be in the range [0,1]
|
||||
layout(location=0) in vec3 aVertPos;
|
||||
layout(location=1) in vec2 aUV0;
|
||||
layout(location=2) in vec4 aVertColor;
|
||||
layout(location=3) in vec3 aModelPos;
|
||||
layout(location=4) in vec3 aModelScale;
|
||||
|
||||
out vec2 vertUV0;
|
||||
out vec4 vertColor;
|
||||
out vec3 fragPos;
|
||||
out vec2 v2fUV0;
|
||||
out vec4 v2fColor;
|
||||
out vec3 v2fFragPos;
|
||||
|
||||
//MVP = Model View Projection
|
||||
uniform mat4 projViewMat;
|
||||
uniform vec2 sizeUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 modelMat = mat4(
|
||||
modelScale.x, 0.0, 0.0, 0.0,
|
||||
0.0, modelScale.y, 0.0, 0.0,
|
||||
0.0, 0.0, modelScale.z, 0.0,
|
||||
modelPos.x, modelPos.y, modelPos.z, 1.0
|
||||
aModelScale.x, 0.0, 0.0, 0.0,
|
||||
0.0, aModelScale.y, 0.0, 0.0,
|
||||
0.0, 0.0, aModelScale.z, 0.0,
|
||||
aModelPos.x, aModelPos.y, aModelPos.z, 1.0
|
||||
);
|
||||
|
||||
vertUV0 = vertUV0STIn[gl_VertexID];
|
||||
vertColor = vertColorIn;
|
||||
fragPos = vec3(modelMat * vec4(vertPosIn, 1.0));
|
||||
v2fUV0 = aUV0 + sizeUV*aVertPos.xy;
|
||||
v2fColor = aVertColor;
|
||||
v2fFragPos = vec3(modelMat * vec4(aVertPos, 1.0));
|
||||
|
||||
gl_Position = projViewMat * modelMat * vec4(vertPosIn, 1.0);
|
||||
gl_Position = projViewMat * modelMat * vec4(aVertPos, 1.0);
|
||||
}
|
||||
|
||||
//shader:fragment
|
||||
#version 410
|
||||
|
||||
in vec4 vertColor;
|
||||
in vec2 vertUV0;
|
||||
in vec3 fragPos;
|
||||
in vec4 v2fColor;
|
||||
in vec2 v2fUV0;
|
||||
in vec3 v2fFragPos;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
@ -43,13 +45,13 @@ uniform sampler2D diffTex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texColor = texture(diffTex, vertUV0);
|
||||
vec4 texColor = texture(diffTex, v2fUV0);
|
||||
// if (texColor.r == 0)
|
||||
// {
|
||||
// fragColor = vec4(0,1,0,0.25);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
fragColor = vec4(vertColor.rgb, texColor.r);
|
||||
fragColor = vec4(v2fColor.rgb, texColor.r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user