gl01/internal/asset/shader/world/geometry.vert

42 lines
891 B
GLSL
Raw Normal View History

2022-01-22 23:06:41 +08:00
#version 330
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
2022-02-15 23:37:42 +08:00
uniform mat4 mvp;
2022-01-22 23:06:41 +08:00
uniform mat4 lightspace;
uniform vec3 viewPos;
layout (location = 0) in vec3 vert;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 vertTexCoord;
layout (location = 3) in float light;
out vec3 fragPosWorld;
out float fragPosLightspaceZ;
2022-02-05 19:25:44 +08:00
out float fragDepthView;
2022-01-22 23:06:41 +08:00
out vec2 fragTexCoord;
out vec3 fragNormal;
out float fragLight;
void main() {
fragTexCoord = vertTexCoord;
fragNormal = normalize(normal);
fragLight = light;
vec4 pos4 = model * vec4(vert, 1);
fragPosWorld = pos4.xyz / pos4.w;
vec4 fragPosLightspace = lightspace * vec4(fragPosWorld, 1.0f);
fragPosLightspaceZ = fragPosLightspace.z / fragPosLightspace.w *0.5f + 0.5f;
2022-02-05 19:25:44 +08:00
vec4 posView = view * pos4;
fragDepthView = posView.z;
2022-02-15 23:37:42 +08:00
gl_Position = mvp * vec4(vert, 1);
2022-02-05 19:25:44 +08:00
2022-01-22 23:06:41 +08:00
fragPosWorld -= viewPos;
}