From 65a8ee0f2ebfa30c5d9602e82cd50762e3f6984a Mon Sep 17 00:00:00 2001 From: Nehon Date: Sat, 26 Mar 2016 10:32:59 +0100 Subject: [PATCH] PBRLighting now use the world normal to fetch irradiance instead of the reflection vector. Also added some comment for the parallax fix to explain what it does and where it comes from --- .../src/main/resources/Common/MatDefs/Light/PBRLighting.frag | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 11e69d7eb..2c9877e61 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -202,7 +202,8 @@ void main(){ } vec3 rv = reflect(-viewDir.xyz, normal.xyz); - //prallax fix for spherical bounds. + //prallax fix for spherical bounds from https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + // g_LightProbeData.w is 1/probe radius, g_LightProbeData.xyz is the position of the lightProbe. rv = g_LightProbeData.w * (wPosition - g_LightProbeData.xyz) +rv; //horizon fade from http://marmosetco.tumblr.com/post/81245981087 @@ -213,7 +214,7 @@ void main(){ vec3 indirectDiffuse = vec3(0.0); vec3 indirectSpecular = vec3(0.0); - indirectDiffuse = textureCube(g_IrradianceMap, rv.xyz).rgb * diffuseColor.rgb; + indirectDiffuse = textureCube(g_IrradianceMap, wNormal.xyz).rgb * diffuseColor.rgb; indirectSpecular = ApproximateSpecularIBLPolynomial(g_PrefEnvMap, specularColor.rgb, Roughness, ndotv, rv.xyz); indirectSpecular *= vec3(horiz);