add c_gbuffer shader
This commit is contained in:
parent
946cef0e11
commit
8fc90afcfe
28
res/shader/c_gbuffer.frag
Normal file
28
res/shader/c_gbuffer.frag
Normal file
@ -0,0 +1,28 @@
|
||||
#version 450 core
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerAlbedo;
|
||||
layout (binding = 2) uniform sampler2D samplerNormalMap;
|
||||
|
||||
layout(location = 0) in vec3 FragmentColor;
|
||||
layout(location = 1) in vec3 FragmentNormal;
|
||||
layout(location = 2) in vec3 FragmentTangent;
|
||||
layout(location = 3) in vec3 FragmentWorldPos;
|
||||
layout(location = 4) in vec2 FragmentTexCoord;
|
||||
|
||||
layout (location = 0) out vec4 FragAlbedo;
|
||||
layout (location = 1) out vec4 FragNormal;
|
||||
layout (location = 2) out vec4 FragWorldPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragWorldPos=vec4(FragmentWorldPos,1.0);
|
||||
FragAlbedo =texture(samplerAlbedo,FragmentTexCoord)*vec4(FragmentColor,1.0);
|
||||
|
||||
vec3 N = normalize(FragmentNormal);
|
||||
N.y = -N.y;
|
||||
vec3 T = normalize(FragmentTangent);
|
||||
vec3 B = cross(N, T);
|
||||
mat3 TBN = mat3(T, B, N);
|
||||
vec3 tnorm = TBN * normalize(texture(samplerNormalMap, FragmentTexCoord).xyz * 2.0 - vec3(1.0));
|
||||
FragNormal = vec4(tnorm, 1.0);
|
||||
}
|
40
res/shader/c_gbuffer.vert
Normal file
40
res/shader/c_gbuffer.vert
Normal file
@ -0,0 +1,40 @@
|
||||
#version 450 core
|
||||
|
||||
layout(location = 0) in vec3 Vertex;
|
||||
layout(location = 1) in vec3 Color;
|
||||
layout(location = 2) in vec3 Normal;
|
||||
layout(location = 3) in vec3 Tangent;
|
||||
layout(location = 4) in vec2 TexCoord;
|
||||
|
||||
layout(binding = 0) uniform WorldMatrix
|
||||
{
|
||||
mat4 two_dim;
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
mat3 normal;
|
||||
} world;
|
||||
|
||||
layout(push_constant) uniform Consts {
|
||||
mat4 local_to_world;
|
||||
} pc;
|
||||
|
||||
layout(location = 0) out vec3 FragmentColor;
|
||||
layout(location = 1) out vec3 FragmentNormal;
|
||||
layout(location = 2) out vec3 FragmentTangent;
|
||||
layout(location = 3) out vec3 FragmentWorldPos;
|
||||
layout(location = 4) out vec2 FragmentTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragmentColor=Color;
|
||||
FragmentWorldPos=vec3(vec4(Vertex,1.0)*pc.local_to_world);
|
||||
FragmentTexCoord=TexCoord;
|
||||
FragmentTexCoord.t=1.0-TexCoord.t;
|
||||
|
||||
mat3 mNormal=transpose(inverse(mat3(pc.local_to_world)));
|
||||
FragmentNormal=mNormal*normalize(Normal);
|
||||
FragmentTangent=mNormal*normalize(Tangent);
|
||||
|
||||
gl_Position=vec4(Vertex,1.0)*world.mvp;
|
||||
}
|
@ -8,3 +8,6 @@ glslangValidator -V -o FlatTexture.frag.spv FlatTexture.frag
|
||||
|
||||
glslangValidator -V -o PositionColor3D.vert.spv PositionColor3D.vert
|
||||
glslangValidator -V -o OnlyPosition3D.vert.spv OnlyPosition3D.vert
|
||||
|
||||
glslangValidator -V -o c_gbuffer.vert.spv c_gbuffer.vert
|
||||
glslangValidator -V -o c_gbuffer.frag.spv c_gbuffer.frag
|
Loading…
x
Reference in New Issue
Block a user