Skip to main content
Added extra image
Source Link
Nick
  • 113
  • 2
  • 8

Working Not Working Half and Half

The first image shows a spotlight shining correctly on the floor. The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

The third image shows the light "half if and half out"

Can anyone understand what is happening here?

Normal mapping code:

Shader.fs

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}

The model is Sponza by crytek. Loaded using Assimp Model Loader.

Working Not Working

The first image shows a spotlight shining correctly on the floor. The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

Can anyone understand what is happening here?

Normal mapping code:

Shader.fs

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}

The model is Sponza by crytek. Loaded using Assimp Model Loader.

Working Not Working Half and Half

The first image shows a spotlight shining correctly on the floor. The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

The third image shows the light "half if and half out"

Can anyone understand what is happening here?

Normal mapping code:

Shader.fs

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}

The model is Sponza by crytek. Loaded using Assimp Model Loader.

Source Link
Nick
  • 113
  • 2
  • 8

Normal Mapping issue

Working Not Working

The first image shows a spotlight shining correctly on the floor. The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

Can anyone understand what is happening here?

Normal mapping code:

Shader.fs

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}

The model is Sponza by crytek. Loaded using Assimp Model Loader.