NormalMaps Working and started work on specular maps.
This commit is contained in:
@@ -24,6 +24,6 @@ void main()
|
||||
|
||||
vec4 _FragmentColor = DiffuseTexel * vec4(La, 1.0) + LightingTexel;
|
||||
FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
//FragmentColor = ShadowTexel;
|
||||
//FragmentColor = DiffuseTexel;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding=1) uniform sampler2D ShadowTexture;
|
||||
layout (binding=2) uniform sampler2D NormalMapTexture;
|
||||
layout (binding=3) uniform sampler2D SpecularMapTexture;
|
||||
|
||||
|
||||
in VertexData
|
||||
{
|
||||
@@ -9,11 +12,14 @@ in VertexData
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
vec4 ShadowCoord;
|
||||
vec3 Tangent;
|
||||
vec3 BiTangent;
|
||||
} Input;
|
||||
|
||||
out vec4 frag_Diffuse;
|
||||
out vec4 frag_Position;
|
||||
out vec4 frag_Normal;
|
||||
out vec4 frag_specular;
|
||||
|
||||
float Shadow(vec4 ShadowCoord)
|
||||
{
|
||||
@@ -32,6 +38,7 @@ float Shadow(vec4 ShadowCoord)
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
// Diffuse Texture
|
||||
frag_Diffuse = texture(DiffuseTexture, Input.TextureCoord) * Shadow(Input.ShadowCoord);
|
||||
|
||||
@@ -39,5 +46,10 @@ void main()
|
||||
frag_Position = vec4(Input.Position.xyz, 1.0);
|
||||
|
||||
// G-buffer Normal
|
||||
frag_Normal = vec4(Input.Normal, 0.0);
|
||||
mat3 TBN = transpose(mat3(Input.Tangent, Input.BiTangent, Input.Normal));
|
||||
frag_Normal = normalize(vec4(TBN * vec3(texture(NormalMapTexture, Input.TextureCoord)), 0.0));
|
||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||
|
||||
//G-buffer Specular
|
||||
frag_specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||
}
|
||||
@@ -81,4 +81,5 @@ void main()
|
||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||
|
||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel));
|
||||
//FragColor = NormalTexel;
|
||||
}
|
||||
@@ -9,6 +9,8 @@ uniform mat4 DepthMVP;
|
||||
layout (location = 0) in vec3 Position;
|
||||
layout (location = 1) in vec3 Normal;
|
||||
layout (location = 2) in vec2 TextureCoord;
|
||||
layout (location = 3) in vec3 Tangent;
|
||||
layout (location = 4) in vec3 BiTangent;
|
||||
|
||||
out VertexData
|
||||
{
|
||||
@@ -16,6 +18,8 @@ out VertexData
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
vec4 ShadowCoord;
|
||||
vec3 Tangent;
|
||||
vec3 BiTangent;
|
||||
} Output;
|
||||
|
||||
void main()
|
||||
@@ -26,4 +30,6 @@ void main()
|
||||
Output.Normal = normalize(vec3(inverse(transpose(V * M)) * vec4(Normal, 0.0)));
|
||||
Output.TextureCoord = TextureCoord;
|
||||
Output.ShadowCoord = DepthMVP * vec4(Position, 1.0);
|
||||
Output.Tangent = normalize(vec3(inverse(transpose(V * M)) * vec4(Tangent, 0.0)));
|
||||
Output.BiTangent = normalize(vec3(inverse(transpose(V * M)) * vec4(BiTangent, 0.0)));
|
||||
}
|
||||
Reference in New Issue
Block a user