Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions jme3-core/src/main/java/com/jme3/util/SkyFactory.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
}
}
}