فهرست منبع

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

Nehon 9 سال پیش
والد
کامیت
65a8ee0f2e
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 3 2
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag

+ 3 - 2
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);