Ao map now only attenuates indirect lighting in PBR shader

empirephoenix-patch-1
Nehon 7 years ago
parent a6b86ad24d
commit 12004217d1
  1. 5
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  2. 17
      jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java
  3. BIN
      jme3-testdata/src/main/resources/Models/Tank/Tank_AO.png
  4. 2
      jme3-testdata/src/main/resources/Models/Tank/tank.j3m

@ -196,6 +196,7 @@ void main(){
#endif
gl_FragColor.rgb = vec3(0.0);
vec3 ao = vec3(1.0);
#ifdef LIGHTMAP
vec3 lightMapColor;
@ -206,7 +207,7 @@ void main(){
#endif
#ifdef AO_MAP
lightMapColor.gb = lightMapColor.rr;
diffuseColor.rgb *= lightMapColor;
ao = lightMapColor;
#else
gl_FragColor.rgb += diffuseColor.rgb * lightMapColor;
#endif
@ -268,7 +269,7 @@ void main(){
indirectSpecular = ApproximateSpecularIBLPolynomial(g_PrefEnvMap, specularColor.rgb, Roughness, ndotv, dominantR, nbMipMaps);
indirectSpecular *= vec3(horiz);
vec3 indirectLighting = indirectDiffuse + indirectSpecular;
vec3 indirectLighting = (indirectDiffuse + indirectSpecular) * ao;
gl_FragColor.rgb = gl_FragColor.rgb + indirectLighting * step( 0.0, g_LightProbeData.w);
#endif

@ -33,27 +33,22 @@ package jme3test.light.pbr;
import com.jme3.app.SimpleApplication;
import com.jme3.bounding.BoundingSphere;
import com.jme3.environment.util.*;
import com.jme3.light.LightProbe;
import com.jme3.environment.LightProbeFactory;
import com.jme3.environment.EnvironmentCamera;
import com.jme3.environment.LightProbeFactory;
import com.jme3.environment.generation.JobProgressAdapter;
import com.jme3.environment.util.EnvMapUtils;
import com.jme3.environment.util.LightsDebugState;
import com.jme3.input.ChaseCamera;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.light.LightProbe;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.math.*;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.FXAAFilter;
import com.jme3.post.filters.ToneMapFilter;
import com.jme3.post.ssao.SSAOFilter;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.*;
import com.jme3.texture.plugins.ktx.KTXLoader;
import com.jme3.util.MaterialDebugAppState;
import com.jme3.util.SkyFactory;

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 MiB

@ -6,6 +6,8 @@ Material Tank : Common/MatDefs/Light/PBRLighting.j3md {
NormalMap : Flip Models/Tank/Tank_Normal.png
BaseColorMap : Flip Models/Tank/Tank_Base_Color.png
EmissiveMap : Flip Models/Tank/Tank_Emissive.png
LightMap: Flip Models/Tank/Tank_AO.png
LightMapAsAOMap: true;
EmissiveIntensity : 2.0
}

Loading…
Cancel
Save