From 270f4957efee820c84e32107d3a09e5ab9e76a0a Mon Sep 17 00:00:00 2001 From: shadowislord Date: Sun, 22 Feb 2015 15:45:23 -0500 Subject: [PATCH] SinglePass Lighting: fix GLSL syntax error when parallax mapping is used --- .../Common/MatDefs/Light/SPLighting.frag | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag index c8471b0b9..5d5615fc2 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag @@ -72,6 +72,13 @@ uniform float m_Shininess; #endif void main(){ + #ifdef NORMALMAP + mat3 tbnMat = mat3(normalize(vTangent.xyz) , normalize(vBinormal.xyz) , normalize(vNormal.xyz)); + vec3 viewDir = normalize(-vPos.xyz * tbnMat); + #else + vec3 viewDir = normalize(-vPos.xyz); + #endif + vec2 newTexCoord; #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING) @@ -79,18 +86,18 @@ void main(){ #ifdef STEEP_PARALLAX #ifdef NORMALMAP_PARALLAX //parallax map is stored in the alpha channel of the normal map - newTexCoord = steepParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight); + newTexCoord = steepParallaxOffset(m_NormalMap, viewDir, texCoord, m_ParallaxHeight); #else //parallax map is a texture - newTexCoord = steepParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight); + newTexCoord = steepParallaxOffset(m_ParallaxMap, viewDir, texCoord, m_ParallaxHeight); #endif #else #ifdef NORMALMAP_PARALLAX //parallax map is stored in the alpha channel of the normal map - newTexCoord = classicParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight); + newTexCoord = classicParallaxOffset(m_NormalMap, viewDir, texCoord, m_ParallaxHeight); #else //parallax map is a texture - newTexCoord = classicParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight); + newTexCoord = classicParallaxOffset(m_ParallaxMap, viewDir, texCoord, m_ParallaxHeight); #endif #endif #else @@ -160,13 +167,6 @@ void main(){ vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz); #endif - #ifdef NORMALMAP - mat3 tbnMat = mat3(normalize(vTangent.xyz) , normalize(vBinormal.xyz) , normalize(vNormal.xyz)); - vec3 viewDir = normalize(-vPos.xyz * tbnMat); - #else - vec3 viewDir = normalize(-vPos.xyz); - #endif - for( int i = 0;i < NB_LIGHTS; i+=3){ vec4 lightColor = g_LightData[i]; vec4 lightData1 = g_LightData[i+1];