axmol/tests/cpp-tests/Source/shaders/OutLine.vert

22 lines
474 B
GLSL
Raw Normal View History

2023-07-22 23:59:17 +08:00
#version 310 es
2023-07-25 19:06:12 +08:00
#include "base.glsl"
layout(location = POSITION) in vec4 a_position;
layout(location = NORMAL) in vec3 a_normal;
2023-07-22 23:59:17 +08:00
layout(std140, binding = 0) uniform vs_ub {
float OutlineWidth;
mat4 u_MVPMatrix;
};
void main(void)
{
vec4 pos = u_MVPMatrix * a_position;
vec4 normalproj = u_MVPMatrix * vec4(a_normal, 0);
normalproj = normalize(normalproj);
pos.xy += normalproj.xy * (OutlineWidth * (pos.z * 0.5 + 0.5));
gl_Position = pos;
}