Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve issue #1414 (checkSetParam warning while creating sky) #1438

Merged
merged 1 commit into from Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
}
}