Fixed an issue with parallax mapping thanks to this thread http://hub.jmonkeyengine.org/forum/topic/parallax-mapping-fundamental-bug/#post-256898
git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@10994 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
a0badf9d4c
commit
bace22528f
@ -211,11 +211,14 @@ void main(){
|
|||||||
// ***********************
|
// ***********************
|
||||||
#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
|
#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
|
||||||
vec4 normalHeight = texture2D(m_NormalMap, newTexCoord);
|
vec4 normalHeight = texture2D(m_NormalMap, newTexCoord);
|
||||||
vec3 normal = normalize((normalHeight.xyz * vec3(2.0) - vec3(1.0)));
|
//Note the -2.0 and -1.0. We invert the green channel of the normal map,
|
||||||
|
//as it's complient with normal maps generated with blender.
|
||||||
|
//see http://hub.jmonkeyengine.org/forum/topic/parallax-mapping-fundamental-bug/#post-256898
|
||||||
|
//for more explanation.
|
||||||
|
vec3 normal = normalize((normalHeight.xyz * vec3(2.0,-2.0,2.0) - vec3(1.0,-1.0,1.0)));
|
||||||
#ifdef LATC
|
#ifdef LATC
|
||||||
normal.z = sqrt(1.0 - (normal.x * normal.x) - (normal.y * normal.y));
|
normal.z = sqrt(1.0 - (normal.x * normal.x) - (normal.y * normal.y));
|
||||||
#endif
|
#endif
|
||||||
//normal.y = -normal.y;
|
|
||||||
#elif !defined(VERTEX_LIGHTING)
|
#elif !defined(VERTEX_LIGHTING)
|
||||||
vec3 normal = vNormal;
|
vec3 normal = vNormal;
|
||||||
#if !defined(LOW_QUALITY) && !defined(V_TANGENT)
|
#if !defined(LOW_QUALITY) && !defined(V_TANGENT)
|
||||||
|
@ -171,7 +171,7 @@ void main(){
|
|||||||
vec3 wvTangent = normalize(g_NormalMatrix * modelSpaceTan);
|
vec3 wvTangent = normalize(g_NormalMatrix * modelSpaceTan);
|
||||||
vec3 wvBinormal = cross(wvNormal, wvTangent);
|
vec3 wvBinormal = cross(wvNormal, wvTangent);
|
||||||
|
|
||||||
mat3 tbnMat = mat3(wvTangent, wvBinormal * -inTangent.w,wvNormal);
|
mat3 tbnMat = mat3(wvTangent, wvBinormal * inTangent.w,wvNormal);
|
||||||
|
|
||||||
//vPosition = wvPosition * tbnMat;
|
//vPosition = wvPosition * tbnMat;
|
||||||
//vViewDir = viewDir * tbnMat;
|
//vViewDir = viewDir * tbnMat;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user