Skip to content

Commit

Permalink
Add MipMaps to PBRTerrainAdvancedTest.java (#2289)
Browse files Browse the repository at this point in the history
This test case has some noisey rendering that are due to not setting mipMaps on the TextureArray.

So I added the MinFilter.Trilinear to fix this issue, and also added MagFilter.Bilinear.
  • Loading branch information
yaRnMcDonuts authored Jul 2, 2024
1 parent 88adea8 commit 6c0ab69
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import com.jme3.texture.Image;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.texture.Texture.MagFilter;
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.TextureArray;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -279,10 +281,10 @@ private void setUpTerrainMaterial() {
TextureArray metallicRoughnessAoEiTextureArray = new TextureArray(metallicRoughnessAoEiMapImages);

//apply wrapMode to the whole texture array, rather than each individual texture in the array
albedoTextureArray.setWrap(WrapMode.Repeat);
normalParallaxTextureArray.setWrap(WrapMode.Repeat);
metallicRoughnessAoEiTextureArray.setWrap(WrapMode.Repeat);

setWrapAndMipMaps(albedoTextureArray);
setWrapAndMipMaps(normalParallaxTextureArray);
setWrapAndMipMaps(metallicRoughnessAoEiTextureArray);
//assign texture array to materials
matTerrain.setParam("AlbedoTextureArray", VarType.TextureArray, albedoTextureArray);
matTerrain.setParam("NormalParallaxTextureArray", VarType.TextureArray, normalParallaxTextureArray);
Expand Down Expand Up @@ -430,6 +432,12 @@ private void setUpTerrain() {
rootNode.attachChild(terrain);
}

private void setWrapAndMipMaps(Texture texture){
texture.setWrap(WrapMode.Repeat);
texture.setMinFilter(MinFilter.Trilinear);
texture.setMagFilter(MagFilter.Bilinear);
}

private void setUpLights() {
LightProbe probe = (LightProbe) assetManager.loadAsset("Scenes/LightProbes/quarry_Probe.j3o");

Expand Down

0 comments on commit 6c0ab69

Please sign in to comment.