Skip to content

Commit

Permalink
resolve issue #1414 (checkSetParam warning while creating sky) (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Dec 1, 2020
1 parent ee4eb53 commit d7a363c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
20 changes: 14 additions & 6 deletions jme3-core/src/main/java/com/jme3/util/SkyFactory.java
Expand Up @@ -186,24 +186,32 @@ public static Spatial createSky(AssetManager assetManager, Texture texture,
sky.setCullHint(Spatial.CullHint.Never);
sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO));

Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
skyMat.setVector3("NormalScale", normalScale);
switch (envMapType){
case CubeMap :
Material skyMat;
switch (envMapType) {
case CubeMap:
// make sure it's a cubemap
if (!(texture instanceof TextureCubeMap)) {
Image img = texture.getImage();
texture = new TextureCubeMap();
texture.setImage(img);
}
skyMat = new Material(assetManager,
"Common/MatDefs/Misc/Sky.j3md");
break;
case SphereMap :
case SphereMap:
skyMat = new Material(assetManager,
"Common/MatDefs/Misc/SkyNonCube.j3md");
skyMat.setBoolean("SphereMap", true);
break;
case EquirectMap :
case EquirectMap:
skyMat = new Material(assetManager,
"Common/MatDefs/Misc/SkyNonCube.j3md");
skyMat.setBoolean("EquirectMap", true);
break;
default:
throw new IllegalArgumentException("envMapType=" + envMapType);
}
skyMat.setVector3("NormalScale", normalScale);
texture.setMagFilter(Texture.MagFilter.Bilinear);
texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
texture.setAnisotropicFilter(0);
Expand Down
28 changes: 28 additions & 0 deletions jme3-core/src/main/resources/Common/MatDefs/Misc/SkyNonCube.j3md
@@ -0,0 +1,28 @@
MaterialDef Sky Plane {
MaterialParameters {
Texture2D Texture
Boolean SphereMap
Boolean EquirectMap
Vector3 NormalScale
}
Technique {
VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.vert
FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.frag

WorldParameters {
ViewMatrix
ProjectionMatrix
WorldMatrixInverse
}

Defines {
SPHERE_MAP : SphereMap
EQUIRECT_MAP : EquirectMap
}

RenderState {
DepthWrite Off
DepthFunc Equal
}
}
}

0 comments on commit d7a363c

Please sign in to comment.