7da65c15f0
This will increase the memory footprint of lod object, however this is the only way I found to make meshbuffer using GE_NORMAL_MAP to provide the necessary info to this shader. Now the pedestal in overlord looks perfectly normal mapped.
26 lines
793 B
GLSL
26 lines
793 B
GLSL
#version 130
|
|
uniform sampler2D texture; //The texture
|
|
uniform sampler2D normalMap; //The bump-map
|
|
|
|
noperspective in vec3 tangent;
|
|
noperspective in vec3 bitangent;
|
|
in vec2 uv;
|
|
|
|
void main()
|
|
{
|
|
// normal in Tangent Space
|
|
vec3 TS_normal = 2.0 * texture2D (normalMap, uv).rgb - 1.0;
|
|
// Because of interpolation, we need to renormalize
|
|
vec3 Frag_tangent = normalize(tangent);
|
|
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
|
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
|
|
|
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
|
FragmentNormal = normalize(FragmentNormal);
|
|
|
|
|
|
gl_FragData[0] = texture2D (texture, uv);
|
|
gl_FragData[1] = vec4(0.5 * FragmentNormal + 0.5, gl_FragCoord.z);
|
|
gl_FragData[2] = vec4(0.);
|
|
}
|