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
define_list_fix
Nehon 9 years ago
parent 754c256a66
commit 65a8ee0f2e
  1. 5
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag

@ -202,7 +202,8 @@ void main(){
} }
vec3 rv = reflect(-viewDir.xyz, normal.xyz); 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; rv = g_LightProbeData.w * (wPosition - g_LightProbeData.xyz) +rv;
//horizon fade from http://marmosetco.tumblr.com/post/81245981087 //horizon fade from http://marmosetco.tumblr.com/post/81245981087
@ -213,7 +214,7 @@ void main(){
vec3 indirectDiffuse = vec3(0.0); vec3 indirectDiffuse = vec3(0.0);
vec3 indirectSpecular = 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 = ApproximateSpecularIBLPolynomial(g_PrefEnvMap, specularColor.rgb, Roughness, ndotv, rv.xyz);
indirectSpecular *= vec3(horiz); indirectSpecular *= vec3(horiz);

Loading…
Cancel
Save