first commit
This commit is contained in:
45
assets/shaders/mesh.vert
Normal file
45
assets/shaders/mesh.vert
Normal file
@@ -0,0 +1,45 @@
|
||||
#version 450 core
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
layout(std140, binding = 0) uniform PerFrame {
|
||||
mat4 uView;
|
||||
mat4 uProj;
|
||||
vec4 uLightDir; // xyz used, w padding
|
||||
};
|
||||
layout(std140, binding = 1) uniform PerObject {
|
||||
mat4 uModel;
|
||||
};
|
||||
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aUV;
|
||||
|
||||
out VS_OUT {
|
||||
vec3 wPos;
|
||||
vec3 wNrm;
|
||||
vec2 uv;
|
||||
flat int hasNrm;
|
||||
flat int hasUV;
|
||||
} v;
|
||||
|
||||
void main() {
|
||||
vec4 wpos4 = uModel * vec4(aPos, 1.0);
|
||||
v.wPos = wpos4.xyz;
|
||||
|
||||
float nLen2 = dot(aNormal, aNormal);
|
||||
if(nLen2 > 1e-10) {
|
||||
mat3 nrmMat = mat3(transpose(inverse(uModel)));
|
||||
v.wNrm = normalize(nrmMat * aNormal);
|
||||
v.hasNrm = 1;
|
||||
} else {
|
||||
v.wNrm = vec3(0.0);
|
||||
v.hasNrm = 0;
|
||||
}
|
||||
|
||||
v.uv = aUV;
|
||||
v.hasUV = (abs(aUV.x) + abs(aUV.y)) > 1e-10 ? 1 : 0;
|
||||
|
||||
gl_Position = uProj * uView * wpos4;
|
||||
}
|
||||
Reference in New Issue
Block a user