ULRE/res/shader/gbuffer_opaque.vert

40 lines
887 B
GLSL
Raw Normal View History

2019-07-08 17:50:19 +08:00
#version 450 core
layout(location = 0) in vec3 Vertex;
layout(location = 1) in vec2 TexCoord;
layout(location = 2) in vec3 Normal;
layout(location = 3) in vec3 Tangent;
layout(binding = 0) uniform WorldMatrix
{
2019-07-17 12:01:20 +08:00
mat4 ortho;
2019-07-08 17:50:19 +08:00
mat4 projection;
mat4 modelview;
mat4 mvp;
2019-07-08 18:18:35 +08:00
vec4 view_pos;
2019-07-08 17:50:19 +08:00
} world;
layout(push_constant) uniform Consts {
mat4 local_to_world;
} pc;
layout(location = 0) out vec3 FragmentNormal;
layout(location = 1) out vec3 FragmentTangent;
layout(location = 2) out vec3 FragmentPosition;
layout(location = 3) out vec2 FragmentTexCoord;
void main()
{
vec4 pos=vec4(Vertex,1.0)*pc.local_to_world;
gl_Position=pos*world.mvp;
2019-07-11 01:07:16 +08:00
FragmentPosition=(pos*world.modelview).xyz;
2019-07-08 17:50:19 +08:00
FragmentTexCoord=TexCoord;
mat3 n=mat3(pc.local_to_world*world.modelview);
2019-07-08 17:50:19 +08:00
FragmentNormal=normalize(Normal)*n;
FragmentTangent=normalize(Tangent)*n;
2019-07-08 17:50:19 +08:00
}