Fixed so that we could use DTX5nm as normal map
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#version 430
|
||||
|
||||
#include "Shaders/Util/CommonNormalFunc.glsl"
|
||||
|
||||
#define MIN_AMBIENT_LIGHT 0.3
|
||||
#define MAX_SPLITS 4
|
||||
|
||||
|
||||
uniform mat4 VM;
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
@@ -18,6 +21,7 @@ uniform vec3 CameraPosition;
|
||||
uniform int SSAOQuality;
|
||||
uniform float FarDistance[MAX_SPLITS];
|
||||
|
||||
uniform int NormalTextureType;
|
||||
uniform vec2 DiffuseUVRepeat;
|
||||
uniform vec2 NormalUVRepeat;
|
||||
uniform vec2 SpecularUVRepeat;
|
||||
@@ -140,13 +144,6 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
||||
{
|
||||
mat3 TBN = mat3(tangent, bitangent, normal);
|
||||
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
||||
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||
}
|
||||
|
||||
// Returns a "random" value.
|
||||
float Random(vec3 seed, int i)
|
||||
{
|
||||
@@ -303,7 +300,7 @@ void main()
|
||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
||||
vec4 position = VM * vec4(Input.Position, 1.0);
|
||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture, NormalTextureType);
|
||||
normal = normalize(normal);
|
||||
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
||||
vec4 viewVec = normalize(-position);
|
||||
|
||||
Reference in New Issue
Block a user