57 | * This setting is ignored when singleDome is true.
58 | */
59 | @Parameter(names = {"-n", "--nocubes"},
60 | description = "don't use star cubes")
61 | private boolean noCubes = false;
62 | /**
63 | * true means use a shadow filter; false means use a shadow renderer
64 | */
65 | @Parameter(names = {"-f", "--filter"}, description = "use a shadow filter")
66 | private boolean shadowFilter = false;
67 | /**
68 | * true means show the setting dialog; false means don't show it
69 | */
70 | @Parameter(names = "--showSettingsDialog",
71 | description = "show the setting dialog")
72 | private boolean showSettingsDialog = false;
73 | /**
74 | * true means use just a single dome; false means use multiple domes
75 | */
76 | @Parameter(names = {"-s", "--single"},
77 | description = "use just a single dome")
78 | private boolean singleDome = false;
79 | /**
80 | * true means just display the usage message; false means run the
81 | * application
82 | */
83 | @Parameter(names = {"-h", "-u", "--help", "--usage"}, help = true,
84 | description = "display this usage message")
85 | private boolean usageOnly = false;
86 | /**
87 | * true means more log output; false means less output
88 | */
89 | @Parameter(names = {"-v", "--verbose"},
90 | description = "additional log output")
91 | private boolean verboseLogging = false;
92 | /**
93 | * true means scene with water; false means no water
94 | */
95 | @Parameter(names = {"-w", "--water"}, description = "scene with water")
96 | private boolean water = false;
97 | // *************************************************************************
98 | // new methods exposed
99 |
100 | /**
101 | * Test whether star cubes are allowed.
102 | *
103 | * @return true if allowed, otherwise false
104 | */
105 | boolean cubes() {
106 | return !noCubes;
107 | }
108 |
109 | /**
110 | * Test whether the cyclone option was specified.
111 | *
112 | * @return true if specified, otherwise false
113 | */
114 | boolean cyclone() {
115 | return cyclone;
116 | }
117 |
118 | /**
119 | * Test whether the shadow filter option was specified.
120 | *
121 | * @return true if specified, otherwise false
122 | */
123 | boolean shadowFilter() {
124 | return shadowFilter;
125 | }
126 |
127 | /**
128 | * Test whether the settings-dialog option was specified.
129 | *
130 | * @return true if specified, otherwise false
131 | */
132 | boolean showSettingsDialog() {
133 | return showSettingsDialog;
134 | }
135 |
136 | /**
137 | * Test whether the single-dome option was specified.
138 | *
139 | * @return true if specified, otherwise false
140 | */
141 | boolean singleDome() {
142 | return singleDome;
143 | }
144 |
145 | /**
146 | * Test whether the "usage only" option was specified.
147 | *
148 | * @return true if specified, otherwise false
149 | */
150 | boolean usageOnly() {
151 | return usageOnly;
152 | }
153 |
154 | /**
155 | * Test whether the verbose-logging option was specified.
156 | *
157 | * @return true if specified, otherwise false
158 | */
159 | boolean verboseLogging() {
160 | return verboseLogging;
161 | }
162 |
163 | /**
164 | * Test whether the water option was specified.
165 | *
166 | * @return true if specified, otherwise false
167 | */
168 | boolean water() {
169 | return water;
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/SkyLibrary/src/main/resources/Shaders/skies/dome60/dome60.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014-2022, Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software
13 | without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | /*
28 | * fragment shader used by dome60.j3md
29 | */
30 | #import "Common/ShaderLib/GLSLCompat.glsllib"
31 | uniform vec4 m_ClearColor;
32 | varying vec2 skyTexCoord;
33 |
34 | #ifdef HAS_STARS
35 | uniform sampler2D m_StarsColorMap;
36 | #endif
37 |
38 | #ifdef HAS_OBJECT0
39 | uniform vec4 m_Object0Color;
40 | uniform sampler2D m_Object0ColorMap;
41 | varying vec2 object0Coord;
42 | #endif
43 |
44 | #ifdef HAS_OBJECT1
45 | uniform vec4 m_Object1Color;
46 | uniform sampler2D m_Object1ColorMap;
47 | varying vec2 object1Coord;
48 | #endif
49 |
50 | #ifdef HAS_OBJECT2
51 | uniform vec4 m_Object2Color;
52 | uniform sampler2D m_Object2ColorMap;
53 | varying vec2 object2Coord;
54 | #endif
55 |
56 | #ifdef HAS_OBJECT3
57 | uniform vec4 m_Object3Color;
58 | uniform sampler2D m_Object3ColorMap;
59 | varying vec2 object3Coord;
60 | #endif
61 |
62 | #ifdef HAS_OBJECT4
63 | uniform vec4 m_Object4Color;
64 | uniform sampler2D m_Object4ColorMap;
65 | varying vec2 object4Coord;
66 | #endif
67 |
68 | #ifdef HAS_OBJECT5
69 | uniform vec4 m_Object5Color;
70 | uniform sampler2D m_Object5ColorMap;
71 | varying vec2 object5Coord;
72 | #endif
73 |
74 | #ifdef HAS_HAZE
75 | uniform sampler2D m_HazeAlphaMap;
76 | uniform vec4 m_HazeColor;
77 | #endif
78 |
79 | vec4 mixColors(vec4 color0, vec4 color1) {
80 | vec4 result;
81 | float a0 = color0.a * (1.0 - color1.a);
82 | result.a = a0 + color1.a;
83 | if (result.a > 0.0) {
84 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a;
85 | } else {
86 | result.rgb = vec3(0.0);
87 | }
88 | return result;
89 | }
90 |
91 | void main() {
92 | #ifdef HAS_STARS
93 | vec4 stars = texture2D(m_StarsColorMap, skyTexCoord);
94 | #else
95 | vec4 stars = vec4(0.0);
96 | #endif
97 |
98 | vec4 objects = vec4(0.0);
99 |
100 | #ifdef HAS_OBJECT0
101 | if (floor(object0Coord.s) == 0.0 &&
102 | floor(object0Coord.t) == 0.0) {
103 | objects = m_Object0Color;
104 | objects *= texture2D(m_Object0ColorMap, object0Coord);
105 | }
106 | #endif
107 |
108 | #ifdef HAS_OBJECT1
109 | if (floor(object1Coord.s) == 0.0 &&
110 | floor(object1Coord.t) == 0.0) {
111 | vec4 object1 = m_Object1Color;
112 | object1 *= texture2D(m_Object1ColorMap, object1Coord);
113 | objects = mixColors(objects, object1);
114 | }
115 | #endif
116 |
117 | #ifdef HAS_OBJECT2
118 | if (floor(object2Coord.s) == 0.0 &&
119 | floor(object2Coord.t) == 0.0) {
120 | vec4 object2 = m_Object2Color;
121 | object2 *= texture2D(m_Object2ColorMap, object2Coord);
122 | objects = mixColors(objects, object2);
123 | }
124 | #endif
125 |
126 | #ifdef HAS_OBJECT3
127 | if (floor(object3Coord.s) == 0.0 &&
128 | floor(object3Coord.t) == 0.0) {
129 | vec4 object3 = m_Object3Color;
130 | object3 *= texture2D(m_Object3ColorMap, object3Coord);
131 | objects = mixColors(objects, object3);
132 | }
133 | #endif
134 |
135 | #ifdef HAS_OBJECT4
136 | if (floor(object4Coord.s) == 0.0 &&
137 | floor(object4Coord.t) == 0.0) {
138 | vec4 object4 = m_Object4Color;
139 | object4 *= texture2D(m_Object4ColorMap, object4Coord);
140 | objects = mixColors(objects, object4);
141 | }
142 | #endif
143 |
144 | #ifdef HAS_OBJECT5
145 | if (floor(object5Coord.s) == 0.0 &&
146 | floor(object5Coord.t) == 0.0) {
147 | vec4 object5 = m_Object5Color;
148 | object5 *= texture2D(m_Object5ColorMap, object5Coord);
149 | objects = mixColors(objects, object5);
150 | }
151 | #endif
152 |
153 | vec4 color = mixColors(stars, objects);
154 |
155 | vec4 clear = m_ClearColor;
156 | #ifdef HAS_HAZE
157 | vec4 haze = m_HazeColor;
158 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r;
159 | clear = mixColors(clear, haze);
160 | #endif
161 | color = mixColors(color, clear);
162 | // Bright parts of objects shine through the clear areas.
163 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a;
164 |
165 | gl_FragColor = color;
166 | }
--------------------------------------------------------------------------------
/SkyLibrary/build.gradle:
--------------------------------------------------------------------------------
1 | // Gradle script to build and publish the SkyLibrary subproject of SkyControl
2 |
3 | // Note: "common.gradle" in the root project contains additional initialization
4 | // for this project. This initialization is applied in the "build.gradle"
5 | // script of the root project.
6 |
7 | plugins {
8 | id 'java-library' // to build JVM libraries
9 | id 'maven-publish' // to publish artifacts to Maven repositories
10 | id 'signing' // to sign artifacts for publication
11 | }
12 |
13 | ext {
14 | group = 'com.github.stephengold'
15 | artifact = 'SkyControl'
16 | version = skycontrolVersion
17 | baseName = "${artifact}-${version}" // for artifacts
18 | websiteUrl = 'https://github.com/stephengold/SkyControl'
19 | }
20 |
21 | processResources.dependsOn(':SkyAssets:skyTextures')
22 |
23 | dependencies {
24 | api(libs.jme3.effects)
25 | api(libs.heart)
26 |
27 | testImplementation(libs.jme3.desktop)
28 | testImplementation(libs.junit4)
29 | }
30 |
31 | // Register publishing tasks:
32 |
33 | tasks.register('install') {
34 | dependsOn 'publishMavenPublicationToMavenLocal'
35 | description = 'Installs the Maven artifacts to the local repository.'
36 | }
37 | tasks.register('release') {
38 | dependsOn 'publishMavenPublicationToCentralRepository'
39 | description = 'Stages the Maven artifacts to the Central Publisher Portal.'
40 | }
41 |
42 | jar {
43 | archiveBaseName = project.ext.baseName
44 | doLast {
45 | println "built using Java ${JavaVersion.current()} (${System.getProperty("java.vendor")})"
46 | }
47 | manifest {
48 | attributes 'Created-By': "${JavaVersion.current()} (${System.getProperty("java.vendor")})"
49 | }
50 | }
51 | java.withJavadocJar()
52 | javadocJar { archiveBaseName = project.ext.baseName }
53 | tasks.register('sourcesJar', Jar) {
54 | archiveBaseName = project.ext.baseName
55 | archiveClassifier = 'sources'
56 | description = 'Creates a JAR of Java sourcecode.'
57 | from sourceSets.main.allJava // default is ".allSource", which includes resources
58 | }
59 |
60 | assemble.dependsOn('module', 'moduleAsc', 'pom', 'pomAsc')
61 | tasks.register('module', Copy) {
62 | dependsOn 'generateMetadataFileForMavenPublication'
63 | description = 'Copies the module metadata to build/libs.'
64 | from "${buildDir}/publications/maven/module.json"
65 | into "${buildDir}/libs"
66 | rename 'module.json', project.ext.baseName + '.module'
67 | }
68 | tasks.register('moduleAsc', Copy) {
69 | dependsOn 'signMavenPublication'
70 | description = 'Copies the signature of the module metadata to build/libs.'
71 | from "${buildDir}/publications/maven/module.json.asc"
72 | into "${buildDir}/libs"
73 | rename 'module.json.asc', project.ext.baseName + '.module.asc'
74 | }
75 | tasks.register('pom', Copy) {
76 | dependsOn 'generatePomFileForMavenPublication'
77 | description = 'Copies the Maven POM to build/libs.'
78 | from "${buildDir}/publications/maven/pom-default.xml"
79 | into "${buildDir}/libs"
80 | rename 'pom-default.xml', project.ext.baseName + '.pom'
81 | }
82 | tasks.register('pomAsc', Copy) {
83 | dependsOn 'signMavenPublication'
84 | description = 'Copies the signature of the Maven POM to build/libs.'
85 | from "${buildDir}/publications/maven/pom-default.xml.asc"
86 | into "${buildDir}/libs"
87 | rename 'pom-default.xml.asc', project.ext.baseName + '.pom.asc'
88 | }
89 |
90 | publishing {
91 | publications {
92 | maven(MavenPublication) {
93 | artifact sourcesJar
94 | artifactId = artifact
95 | from components.java
96 | groupId = project.ext.group
97 | pom {
98 | description = 'A sky-simulation library for jMonkeyEngine'
99 | developers {
100 | developer {
101 | email = 'sgold@sonic.net'
102 | id = 'stephengold'
103 | name = 'Stephen Gold'
104 | }
105 | }
106 | licenses {
107 | license {
108 | distribution = 'repo'
109 | name = 'New BSD (3-clause) License'
110 | url = 'https://opensource.org/licenses/BSD-3-Clause'
111 | }
112 | }
113 | name = project.ext.group + ':' + artifact
114 | scm {
115 | connection = 'scm:git:git://github.com/stephengold/SkyControl.git'
116 | developerConnection = 'scm:git:ssh://github.com:stephengold/SkyControl.git'
117 | url = project.ext.websiteUrl + '/tree/master'
118 | }
119 | url = project.ext.websiteUrl
120 | }
121 | version = project.ext.version
122 | }
123 | }
124 | // Staging to the Central Publisher Portal relies on the existence of 2 properties
125 | // (centralUsername and centralPassword)
126 | // which should be set in the ~/.gradle/gradle.properties file
127 | // or by -P options on the command line.
128 | repositories {
129 | maven {
130 | credentials {
131 | username = project.hasProperty('centralUsername') ? centralUsername : 'Unknown user'
132 | password = project.hasProperty('centralPassword') ? centralPassword : 'Unknown password'
133 | }
134 | name = 'Central'
135 | url = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
136 | }
137 | }
138 | }
139 | generateMetadataFileForMavenPublication.dependsOn('pom')
140 | publishMavenPublicationToMavenLocal.dependsOn('assemble')
141 | publishMavenPublicationToMavenLocal.doLast {
142 | println 'installed locally as ' + baseName
143 | }
144 | publishMavenPublicationToCentralRepository.dependsOn('assemble')
145 |
146 | // Register tasks to sign the Maven artifacts for publication:
147 |
148 | // Signing relies on the existence of 3 properties
149 | // (signing.keyId, signing.password, and signing.secretKeyRingFile)
150 | // which should be set in the ~/.gradle/gradle.properties file
151 | // or by -P options on the Gradle command line.
152 |
153 | signing {
154 | sign publishing.publications.maven
155 | }
156 | tasks.withType(Sign).configureEach {
157 | onlyIf { rootProject.hasProperty('signing.keyId') }
158 | }
159 | signMavenPublication.dependsOn('module')
--------------------------------------------------------------------------------
/SkyLibrary/src/main/resources/Shaders/skies/dome66/dome66.vert:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014-2022, Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software
13 | without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | /*
28 | * vertex shader used by dome66.j3md
29 | */
30 | #import "Common/ShaderLib/GLSLCompat.glsllib"
31 | attribute vec2 inTexCoord;
32 | attribute vec3 inPosition;
33 | uniform mat4 g_WorldViewProjectionMatrix;
34 | uniform vec2 m_TopCoord;
35 | varying vec2 skyTexCoord;
36 |
37 | #ifdef HAS_OBJECT0
38 | uniform vec2 m_Object0Center;
39 | uniform vec2 m_Object0TransformU;
40 | uniform vec2 m_Object0TransformV;
41 | varying vec2 object0Coord;
42 | varying vec2 object0Offset;
43 | #endif
44 |
45 | #ifdef HAS_OBJECT1
46 | uniform vec2 m_Object1Center;
47 | uniform vec2 m_Object1TransformU;
48 | uniform vec2 m_Object1TransformV;
49 | varying vec2 object1Coord;
50 | varying vec2 object1Offset;
51 | #endif
52 |
53 | #ifdef HAS_OBJECT2
54 | uniform vec2 m_Object2Center;
55 | uniform vec2 m_Object2TransformU;
56 | uniform vec2 m_Object2TransformV;
57 | varying vec2 object2Coord;
58 | varying vec2 object2Offset;
59 | #endif
60 |
61 | #ifdef HAS_OBJECT3
62 | uniform vec2 m_Object3Center;
63 | uniform vec2 m_Object3TransformU;
64 | uniform vec2 m_Object3TransformV;
65 | varying vec2 object3Coord;
66 | varying vec2 object3Offset;
67 | #endif
68 |
69 | #ifdef HAS_OBJECT4
70 | uniform vec2 m_Object4Center;
71 | uniform vec2 m_Object4TransformU;
72 | uniform vec2 m_Object4TransformV;
73 | varying vec2 object4Coord;
74 | varying vec2 object4Offset;
75 | #endif
76 |
77 | #ifdef HAS_OBJECT5
78 | uniform vec2 m_Object5Center;
79 | uniform vec2 m_Object5TransformU;
80 | uniform vec2 m_Object5TransformV;
81 | varying vec2 object5Coord;
82 | varying vec2 object5Offset;
83 | #endif
84 |
85 | #ifdef HAS_CLOUDS0
86 | uniform float m_Clouds0Scale;
87 | uniform vec2 m_Clouds0Offset;
88 | varying vec2 clouds0Coord;
89 | #endif
90 |
91 | #ifdef HAS_CLOUDS1
92 | uniform float m_Clouds1Scale;
93 | uniform vec2 m_Clouds1Offset;
94 | varying vec2 clouds1Coord;
95 | #endif
96 |
97 | #ifdef HAS_CLOUDS2
98 | uniform float m_Clouds2Scale;
99 | uniform vec2 m_Clouds2Offset;
100 | varying vec2 clouds2Coord;
101 | #endif
102 |
103 | #ifdef HAS_CLOUDS3
104 | uniform float m_Clouds3Scale;
105 | uniform vec2 m_Clouds3Offset;
106 | varying vec2 clouds3Coord;
107 | #endif
108 |
109 | #ifdef HAS_CLOUDS4
110 | uniform float m_Clouds4Scale;
111 | uniform vec2 m_Clouds4Offset;
112 | varying vec2 clouds4Coord;
113 | #endif
114 |
115 | #ifdef HAS_CLOUDS5
116 | uniform float m_Clouds5Scale;
117 | uniform vec2 m_Clouds5Offset;
118 | varying vec2 clouds5Coord;
119 | #endif
120 |
121 | void main(){
122 | skyTexCoord = inTexCoord;
123 | /*
124 | * The following cloud texture coordinate calculations must be kept
125 | * consistent with those in SkyMaterial.getTransparency(int,Vector2f) .
126 | */
127 | #ifdef HAS_CLOUDS0
128 | clouds0Coord = inTexCoord * m_Clouds0Scale + m_Clouds0Offset;
129 | #endif
130 | #ifdef HAS_CLOUDS1
131 | clouds1Coord = inTexCoord * m_Clouds1Scale + m_Clouds1Offset;
132 | #endif
133 | #ifdef HAS_CLOUDS2
134 | clouds2Coord = inTexCoord * m_Clouds2Scale + m_Clouds2Offset;
135 | #endif
136 | #ifdef HAS_CLOUDS3
137 | clouds3Coord = inTexCoord * m_Clouds3Scale + m_Clouds3Offset;
138 | #endif
139 | #ifdef HAS_CLOUDS4
140 | clouds4Coord = inTexCoord * m_Clouds4Scale + m_Clouds4Offset;
141 | #endif
142 | #ifdef HAS_CLOUDS5
143 | clouds5Coord = inTexCoord * m_Clouds5Scale + m_Clouds5Offset;
144 | #endif
145 |
146 | #ifdef HAS_OBJECT0
147 | object0Offset = inTexCoord - m_Object0Center;
148 | object0Coord.x = dot(m_Object0TransformU, object0Offset);
149 | object0Coord.y = dot(m_Object0TransformV, object0Offset);
150 | object0Coord += m_TopCoord;
151 | #endif
152 | #ifdef HAS_OBJECT1
153 | object1Offset = inTexCoord - m_Object1Center;
154 | object1Coord.x = dot(m_Object1TransformU, object1Offset);
155 | object1Coord.y = dot(m_Object1TransformV, object1Offset);
156 | object1Coord += m_TopCoord;
157 | #endif
158 | #ifdef HAS_OBJECT2
159 | object2Offset = inTexCoord - m_Object2Center;
160 | object2Coord.x = dot(m_Object2TransformU, object2Offset);
161 | object2Coord.y = dot(m_Object2TransformV, object2Offset);
162 | object2Coord += m_TopCoord;
163 | #endif
164 | #ifdef HAS_OBJECT3
165 | object3Offset = inTexCoord - m_Object3Center;
166 | object3Coord.x = dot(m_Object3TransformU, object3Offset);
167 | object3Coord.y = dot(m_Object3TransformV, object3Offset);
168 | object3Coord += m_TopCoord;
169 | #endif
170 | #ifdef HAS_OBJECT4
171 | object4Offset = inTexCoord - m_Object4Center;
172 | object4Coord.x = dot(m_Object4TransformU, object4Offset);
173 | object4Coord.y = dot(m_Object4TransformV, object4Offset);
174 | object4Coord += m_TopCoord;
175 | #endif
176 | #ifdef HAS_OBJECT5
177 | object5Offset = inTexCoord - m_Object5Center;
178 | object5Coord.x = dot(m_Object5TransformU, object5Offset);
179 | object5Coord.y = dot(m_Object5TransformV, object5Offset);
180 | object5Coord += m_TopCoord;
181 | #endif
182 |
183 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1);
184 | }
--------------------------------------------------------------------------------
/SkyAssets/src/main/java/jme3utilities/sky/textures/StarMapPreset.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013-2024 Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software without
13 | specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 | package jme3utilities.sky.textures;
27 |
28 | import com.jme3.math.FastMath;
29 | import jme3utilities.math.MyMath;
30 |
31 | /**
32 | * Enumerate the pre-set conditions for MakeStarMaps.
33 | *
34 | * @author Stephen Gold sgold@sonic.net
35 | */
36 | enum StarMapPreset {
37 | // *************************************************************************
38 | // values
39 |
40 | /**
41 | * Equator 0h local sidereal time at 2048x2048 resolution (for cube)
42 | */
43 | EQUATOR_4M,
44 | /**
45 | * Equator 0h local sidereal time at 4096x4096 resolution (for cube)
46 | */
47 | EQUATOR_16M,
48 | /**
49 | * stars of the Northern Hemisphere at 2048x2048 resolution
50 | */
51 | NORTH_4M,
52 | /**
53 | * stars of the Northern Hemisphere at 4096x4096 resolution
54 | */
55 | NORTH_16M,
56 | /**
57 | * stars of the Southern Hemisphere at 2048x2048 resolution
58 | */
59 | SOUTH_4M,
60 | /**
61 | * stars of the Southern Hemisphere at 4096x4096 resolution
62 | */
63 | SOUTH_16M,
64 | /**
65 | * stars of Wiltshire 10h33m local sidereal time at 2048x2048 resolution
66 | */
67 | WILTSHIRE_4M,
68 | /**
69 | * stars of Wiltshire 10h33m local sidereal time at 4096x4096 resolution
70 | */
71 | WILTSHIRE_16M;
72 | // *************************************************************************
73 | // new methods exposed
74 |
75 | /**
76 | * Look up the textual description of this preset.
77 | *
78 | * @return a description (not null, not empty)
79 | */
80 | String describe() {
81 | switch (this) {
82 | case EQUATOR_4M:
83 | return "equator";
84 | case EQUATOR_16M:
85 | return "equator_16m";
86 | case NORTH_4M:
87 | return "north";
88 | case NORTH_16M:
89 | return "north_16m";
90 | case SOUTH_4M:
91 | return "south";
92 | case SOUTH_16M:
93 | return "south_16m";
94 | case WILTSHIRE_4M:
95 | return "wiltshire";
96 | case WILTSHIRE_16M:
97 | return "wiltshire_16m";
98 | default:
99 | return "?";
100 | }
101 | }
102 |
103 | /**
104 | * Find a preset value based on its textual description.
105 | *
106 | * @param description textual description of the desired preset
107 | * @return the preset value, or null if not found
108 | */
109 | static StarMapPreset fromDescription(String description) {
110 | for (StarMapPreset preset : values()) {
111 | String d = preset.describe();
112 | if (d.equals(description)) {
113 | return preset;
114 | }
115 | }
116 |
117 | return null;
118 | }
119 |
120 | /**
121 | * Look up the sidereal time for this preset.
122 | *
123 | * @return number of hours since midnight (≤24, ≥0)
124 | */
125 | float hour() {
126 | switch (this) {
127 | case EQUATOR_4M:
128 | case EQUATOR_16M:
129 | case NORTH_4M:
130 | case NORTH_16M:
131 | case SOUTH_4M:
132 | case SOUTH_16M:
133 | return 0f;
134 | case WILTSHIRE_4M:
135 | case WILTSHIRE_16M:
136 | /*
137 | * At 10h33m, Orion is about to set in the west and the
138 | * Pointers of the Big Dipper are near the meridian.
139 | */
140 | return 10.55f;
141 | default:
142 | throw new IllegalStateException("preset = " + this);
143 | }
144 | }
145 |
146 | /**
147 | * Return the observer's latitude for this preset.
148 | *
149 | * @return radians north of the equator (≤Pi/2, ≥-Pi/2)
150 | */
151 | float latitude() {
152 | switch (this) {
153 | case EQUATOR_4M:
154 | case EQUATOR_16M:
155 | return 0f;
156 | case NORTH_4M:
157 | case NORTH_16M:
158 | return FastMath.HALF_PI;
159 | case SOUTH_4M:
160 | case SOUTH_16M:
161 | return -FastMath.HALF_PI;
162 | case WILTSHIRE_4M:
163 | case WILTSHIRE_16M:
164 | // Stonehenge
165 | return MyMath.toRadians(51.1788f);
166 |
167 | default:
168 | throw new IllegalStateException("preset = " + this);
169 | }
170 | }
171 |
172 | /**
173 | * Return the name of the texture asset file or folder for this preset.
174 | *
175 | * @return the name (not null, not empty)
176 | */
177 | String textureFileName() {
178 | switch (this) {
179 | case EQUATOR_4M:
180 | return "equator";
181 | case EQUATOR_16M:
182 | return "equator16m";
183 | case NORTH_4M:
184 | return "northern";
185 | case NORTH_16M:
186 | return "16m/northern";
187 | case SOUTH_4M:
188 | return "southern";
189 | case SOUTH_16M:
190 | return "16m/southern";
191 | case WILTSHIRE_4M:
192 | return "wiltshire";
193 | case WILTSHIRE_16M:
194 | return "16m/wiltshire";
195 | default:
196 | throw new IllegalStateException("preset = " + this);
197 | }
198 | }
199 |
200 | /**
201 | * Look up the texture resolution for this preset.
202 | *
203 | * @return size of each texture map (pixels per side)
204 | */
205 | int textureSize() {
206 | switch (this) {
207 | case EQUATOR_4M:
208 | case NORTH_4M:
209 | case SOUTH_4M:
210 | case WILTSHIRE_4M:
211 | return 2_048;
212 | case EQUATOR_16M:
213 | case NORTH_16M:
214 | case SOUTH_16M:
215 | case WILTSHIRE_16M:
216 | return 4_096;
217 | default:
218 | throw new IllegalStateException("preset = " + this);
219 | }
220 | }
221 | }
222 |
--------------------------------------------------------------------------------
/SkyAssets/src/main/java/jme3utilities/sky/textures/MakeMoons.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2017-2023, Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software without
13 | specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 | package jme3utilities.sky.textures;
27 |
28 | import com.beust.jcommander.JCommander;
29 | import com.beust.jcommander.Parameter;
30 | import com.jme3.math.FastMath;
31 | import com.jme3.math.Vector3f;
32 | import java.awt.Graphics2D;
33 | import java.awt.image.BufferedImage;
34 | import java.io.IOException;
35 | import java.util.logging.Level;
36 | import java.util.logging.Logger;
37 | import jme3utilities.Heart;
38 | import jme3utilities.MyString;
39 | import jme3utilities.math.MyMath;
40 | import jme3utilities.sky.LunarPhase;
41 |
42 | /**
43 | * Console application to generate moon images for use with SkyMaterial.
44 | *
45 | * @author Stephen Gold sgold@sonic.net
46 | */
47 | final class MakeMoons {
48 | // *************************************************************************
49 | // constants and loggers
50 |
51 | /**
52 | * UV radius of a moon disc
53 | */
54 | final private static float discRadius = 0.49f;
55 | /**
56 | * 1/gamma for gamma correction
57 | */
58 | final private static float inverseGamma = 0.2f;
59 | /**
60 | * size of the texture map (pixels per side)
61 | */
62 | final private static int textureSize = 128;
63 | /**
64 | * message logger for this class
65 | */
66 | final private static Logger logger
67 | = Logger.getLogger(MakeMoons.class.getName());
68 | /**
69 | * application name for the usage message
70 | */
71 | final private static String applicationName = "MakeMoons";
72 | /**
73 | * filesystem path to the asset directory/folder for output
74 | */
75 | final private static String assetDirPath
76 | = "../SkyLibrary/src/main/resources";
77 | // *************************************************************************
78 | // fields
79 |
80 | /**
81 | * true means just display the usage message; false means run the
82 | * application
83 | */
84 | @Parameter(names = {"-h", "-u", "--help", "--usage"}, help = true,
85 | description = "display this usage message")
86 | private static boolean usageOnly = false;
87 | /**
88 | * name of style
89 | */
90 | @Parameter(names = {"-p", "--phase"}, description = "specify phase")
91 | private static String phaseName = "all";
92 | // *************************************************************************
93 | // constructors
94 |
95 | /**
96 | * A private constructor to inhibit instantiation of this class.
97 | */
98 | private MakeMoons() {
99 | }
100 | // *************************************************************************
101 | // new methods exposed
102 |
103 | /**
104 | * Main entry point for the MakeMoons application.
105 | *
106 | * @param arguments array of command-line arguments (not null)
107 | */
108 | public static void main(String[] arguments) {
109 | // Mute the chatty loggers found in some imported packages.
110 | Heart.setLoggingLevels(Level.WARNING);
111 |
112 | // Instantiate the application.
113 | MakeMoons application = new MakeMoons();
114 |
115 | // Parse the command-line arguments, if any.
116 | JCommander jCommander = new JCommander(application);
117 | jCommander.parse(arguments);
118 | jCommander.setProgramName(applicationName);
119 | if (usageOnly) {
120 | jCommander.usage();
121 | return;
122 | }
123 |
124 | // Log the working directory.
125 | String userDir = System.getProperty("user.dir");
126 | logger.log(Level.INFO, "working directory is {0}",
127 | MyString.quote(userDir));
128 |
129 | // Generate color image maps.
130 | if ("all".equals(phaseName)) {
131 | for (LunarPhase phase : LunarPhase.values()) {
132 | if (phase != LunarPhase.CUSTOM) {
133 | makeMoon(phase);
134 | }
135 | }
136 | } else {
137 | LunarPhase phase = LunarPhase.fromDescription(phaseName);
138 | makeMoon(phase);
139 | }
140 | }
141 | // *************************************************************************
142 | // private methods
143 |
144 | /**
145 | * Generate an image map for a moon shape.
146 | *
147 | * @param phase (not null, not CUSTOM)
148 | */
149 | private static void makeMoon(LunarPhase phase) {
150 | assert phase != null;
151 | assert phase != LunarPhase.CUSTOM;
152 |
153 | // Create a blank, color buffered image for the texture map.
154 | BufferedImage image = new BufferedImage(
155 | textureSize, textureSize, BufferedImage.TYPE_4BYTE_ABGR);
156 | Graphics2D graphics = image.createGraphics();
157 |
158 | // Calculate the direction to the light source.
159 | float angle = phase.longitudeDifference();
160 | float cos = FastMath.cos(angle);
161 | float sin = FastMath.sin(angle);
162 | Vector3f lightDirection = new Vector3f(sin, 0f, -cos);
163 |
164 | // Compute the opacity and luminance of each pixel.
165 | Vector3f normal = new Vector3f();
166 | for (int x = 0; x < textureSize; ++x) {
167 | float u = ((float) x) / textureSize;
168 | float du = (u - 0.5f) / discRadius;
169 | for (int y = 0; y < textureSize; ++y) {
170 | float v = ((float) y) / textureSize;
171 | float dv = (v - 0.5f) / discRadius;
172 |
173 | // Convert Cartesian texture coordinates to polar coordinates.
174 | double uvRadiusSquared = MyMath.sumOfSquares(dv, du);
175 |
176 | float opacity;
177 | float brightness;
178 | if (uvRadiusSquared > 1.0) {
179 | opacity = 0f;
180 | brightness = 0f;
181 | } else {
182 | opacity = 1f;
183 | float dw = (float) Math.sqrt(1.0 - uvRadiusSquared);
184 | normal.set(du, dv, dw);
185 | float dot = lightDirection.dot(normal);
186 | brightness = FastMath.saturate(dot);
187 | brightness = FastMath.pow(brightness, inverseGamma);
188 | }
189 |
190 | Heart.setGrayPixel(graphics, x, y, brightness, opacity);
191 | }
192 | }
193 |
194 | // Write the image to the asset file.
195 | String assetPath = phase.imagePath("-nonviral");
196 | String filePath = String.format("%s/%s", assetDirPath, assetPath);
197 | try {
198 | Heart.writeImage(filePath, image);
199 | } catch (IOException exception) {
200 | throw new RuntimeException(exception);
201 | }
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/SkyAssets/src/main/java/jme3utilities/sky/textures/Star.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013-2024 Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software without
13 | specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 | package jme3utilities.sky.textures;
27 |
28 | import com.jme3.math.FastMath;
29 | import com.jme3.math.Vector3f;
30 | import java.util.logging.Logger;
31 | import jme3utilities.Validate;
32 |
33 | /**
34 | * An immutable star in a star catalog, used by MakeStarMaps.
35 | *
36 | * @author Stephen Gold sgold@sonic.net
37 | */
38 | class Star implements Comparable
51 | * This application was used as an example in a tutorial.
52 | *
53 | * This application also uses assets from the jme3-testdata library.
54 | *
55 | * @author Stephen Gold sgold@sonic.net
56 | */
57 | final class CubeMapExample extends SimpleApplication {
58 | // *************************************************************************
59 | // constants and loggers
60 |
61 | /**
62 | * message logger for this class
63 | */
64 | final private static Logger logger
65 | = Logger.getLogger(CubeMapExample.class.getName());
66 | // *************************************************************************
67 | // new methods exposed
68 |
69 | /**
70 | * Main entry point for the application.
71 | *
72 | * @param arguments array of command-line arguments (not null)
73 | */
74 | public static void main(String[] arguments) {
75 | SimpleApplication application = new CubeMapExample();
76 | Heart.parseAppArgs(application, arguments);
77 |
78 | boolean loadDefaults = true;
79 | AppSettings settings = new AppSettings(loadDefaults);
80 | settings.setTitle("CubeMapExample");
81 | application.setSettings(settings);
82 | application.setShowSettings(false);
83 | application.start();
84 | }
85 | // *************************************************************************
86 | // SimpleApplication methods
87 |
88 | /**
89 | * Initialize this application.
90 | */
91 | @Override
92 | public void simpleInitApp() {
93 | initializeCamera();
94 | initializeLandscape();
95 | initializeLights();
96 | initializeSky();
97 |
98 | stateManager.attach(new PerformanceAppState());
99 |
100 | // Detach any JME stats app state(s).
101 | Heart.detachAll(stateManager, StatsAppState.class);
102 | }
103 | // *************************************************************************
104 | // private methods
105 |
106 | /**
107 | * Configure the camera, including flyCam.
108 | */
109 | private void initializeCamera() {
110 | cam.setLocation(new Vector3f(177f, 17f, 326f));
111 | Vector3f direction = new Vector3f(31f, -7f, -95f);
112 | MyCamera.look(cam, direction);
113 |
114 | flyCam.setDragToRotate(true);
115 | flyCam.setRotationSpeed(2f);
116 | flyCam.setMoveSpeed(20f);
117 | flyCam.setUpVector(Vector3f.UNIT_Y);
118 | flyCam.setZoomSpeed(20f);
119 | }
120 |
121 | /**
122 | * Create, configure, add, and enable the landscape.
123 | */
124 | private void initializeLandscape() {
125 | // textures
126 | Texture alphaMap = assetManager.loadTexture(
127 | "Textures/Terrain/splat/alphamap.png");
128 | Texture dirt = loadSplatTexture("dirt.jpg");
129 | Texture dirtNormal = loadSplatTexture("dirt_normal.png");
130 | Texture grass = loadSplatTexture("grass.jpg");
131 | Texture grassNormal = loadSplatTexture("grass_normal.jpg");
132 | Texture heights = assetManager.loadTexture(
133 | "Textures/Terrain/splat/mountains512.png");
134 | Texture road = loadSplatTexture("road.jpg");
135 | Texture roadNormal = loadSplatTexture("road_normal.png");
136 |
137 | // material
138 | Material terrainMaterial = new Material(
139 | assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
140 | terrainMaterial.setBoolean("useTriPlanarMapping", false);
141 | terrainMaterial.setBoolean("WardIso", true);
142 | terrainMaterial.setFloat("DiffuseMap_0_scale", 64f);
143 | terrainMaterial.setFloat("DiffuseMap_1_scale", 16f);
144 | terrainMaterial.setFloat("DiffuseMap_2_scale", 128f);
145 | terrainMaterial.setTexture("AlphaMap", alphaMap);
146 | terrainMaterial.setTexture("DiffuseMap", grass);
147 | terrainMaterial.setTexture("DiffuseMap_1", dirt);
148 | terrainMaterial.setTexture("DiffuseMap_2", road);
149 | terrainMaterial.setTexture("NormalMap", grassNormal);
150 | terrainMaterial.setTexture("NormalMap_1", dirtNormal);
151 | terrainMaterial.setTexture("NormalMap_2", roadNormal);
152 |
153 | // spatials
154 | Image image = heights.getImage();
155 | ImageBasedHeightMap heightMap = new ImageBasedHeightMap(image);
156 | heightMap.load();
157 | float[] heightArray = heightMap.getHeightMap();
158 | TerrainQuad terrain = new TerrainQuad("terrain", 65, 513, heightArray);
159 | rootNode.attachChild(terrain);
160 | terrain.setLocalScale(2f, 0.25f, 2f);
161 | terrain.setMaterial(terrainMaterial);
162 | }
163 |
164 | /**
165 | * Create, configure, and add light sources.
166 | */
167 | private void initializeLights() {
168 | DirectionalLight mainLight = new DirectionalLight();
169 | Vector3f lightDirection = new Vector3f(-2f, -5f, 4f).normalize();
170 | mainLight.setColor(ColorRGBA.White.mult(1f));
171 | mainLight.setDirection(lightDirection);
172 | mainLight.setName("main");
173 | rootNode.addLight(mainLight);
174 |
175 | AmbientLight ambientLight = new AmbientLight();
176 | ambientLight.setColor(ColorRGBA.White.mult(0.2f));
177 | ambientLight.setName("ambient");
178 | rootNode.addLight(ambientLight);
179 | }
180 |
181 | /**
182 | * Create and attach the sky.
183 | */
184 | private void initializeSky() {
185 | Spatial starMap = MyAsset.createStarMapSphere(
186 | assetManager, "purple-nebula-complex", 100f);
187 | rootNode.attachChild(starMap);
188 | }
189 |
190 | /**
191 | * Load an inverted splat texture asset in "repeat" mode.
192 | *
193 | * @param fileName (not null)
194 | * @return a new texture instance
195 | */
196 | private Texture loadSplatTexture(String fileName) {
197 | assert fileName != null;
198 |
199 | String path = String.format("Textures/Terrain/splat/%s", fileName);
200 | Texture result = assetManager.loadTexture(path);
201 | result.setWrap(Texture.WrapMode.Repeat);
202 |
203 | return result;
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/SkyLibrary/src/main/resources/Shaders/skies/dome66/dome66.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014-2022, Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software
13 | without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | /*
28 | * fragment shader used by dome66.j3md
29 | */
30 | #import "Common/ShaderLib/GLSLCompat.glsllib"
31 | uniform vec4 m_ClearColor;
32 | varying vec2 skyTexCoord;
33 |
34 | #ifdef HAS_STARS
35 | uniform sampler2D m_StarsColorMap;
36 | #endif
37 |
38 | #ifdef HAS_OBJECT0
39 | uniform vec4 m_Object0Color;
40 | uniform sampler2D m_Object0ColorMap;
41 | varying vec2 object0Coord;
42 | #endif
43 |
44 | #ifdef HAS_OBJECT1
45 | uniform vec4 m_Object1Color;
46 | uniform sampler2D m_Object1ColorMap;
47 | varying vec2 object1Coord;
48 | #endif
49 |
50 | #ifdef HAS_OBJECT2
51 | uniform vec4 m_Object2Color;
52 | uniform sampler2D m_Object2ColorMap;
53 | varying vec2 object2Coord;
54 | #endif
55 |
56 | #ifdef HAS_OBJECT3
57 | uniform vec4 m_Object3Color;
58 | uniform sampler2D m_Object3ColorMap;
59 | varying vec2 object3Coord;
60 | #endif
61 |
62 | #ifdef HAS_OBJECT4
63 | uniform vec4 m_Object4Color;
64 | uniform sampler2D m_Object4ColorMap;
65 | varying vec2 object4Coord;
66 | #endif
67 |
68 | #ifdef HAS_OBJECT5
69 | uniform vec4 m_Object5Color;
70 | uniform sampler2D m_Object5ColorMap;
71 | varying vec2 object5Coord;
72 | #endif
73 |
74 | #ifdef HAS_HAZE
75 | uniform sampler2D m_HazeAlphaMap;
76 | uniform vec4 m_HazeColor;
77 | #endif
78 |
79 | #ifdef HAS_CLOUDS0
80 | uniform sampler2D m_Clouds0AlphaMap;
81 | uniform vec4 m_Clouds0Color;
82 | varying vec2 clouds0Coord;
83 | #endif
84 |
85 | #ifdef HAS_CLOUDS1
86 | uniform sampler2D m_Clouds1AlphaMap;
87 | uniform vec4 m_Clouds1Color;
88 | varying vec2 clouds1Coord;
89 | #endif
90 |
91 | #ifdef HAS_CLOUDS2
92 | uniform sampler2D m_Clouds2AlphaMap;
93 | uniform vec4 m_Clouds2Color;
94 | varying vec2 clouds2Coord;
95 | #endif
96 |
97 | #ifdef HAS_CLOUDS3
98 | uniform sampler2D m_Clouds3AlphaMap;
99 | uniform vec4 m_Clouds3Color;
100 | varying vec2 clouds3Coord;
101 | #endif
102 |
103 | #ifdef HAS_CLOUDS4
104 | uniform sampler2D m_Clouds4AlphaMap;
105 | uniform vec4 m_Clouds4Color;
106 | varying vec2 clouds4Coord;
107 | #endif
108 |
109 | #ifdef HAS_CLOUDS5
110 | uniform sampler2D m_Clouds5AlphaMap;
111 | uniform vec4 m_Clouds5Color;
112 | varying vec2 clouds5Coord;
113 | #endif
114 |
115 | vec4 mixColors(vec4 color0, vec4 color1) {
116 | vec4 result;
117 | float a0 = color0.a * (1.0 - color1.a);
118 | result.a = a0 + color1.a;
119 | if (result.a > 0.0) {
120 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a;
121 | } else {
122 | result.rgb = vec3(0.0);
123 | }
124 | return result;
125 | }
126 |
127 | void main() {
128 | #ifdef HAS_STARS
129 | vec4 stars = texture2D(m_StarsColorMap, skyTexCoord);
130 | #else
131 | vec4 stars = vec4(0.0);
132 | #endif
133 |
134 | vec4 objects = vec4(0.0);
135 |
136 | #ifdef HAS_OBJECT0
137 | if (floor(object0Coord.s) == 0.0 &&
138 | floor(object0Coord.t) == 0.0) {
139 | objects = m_Object0Color;
140 | objects *= texture2D(m_Object0ColorMap, object0Coord);
141 | }
142 | #endif
143 |
144 | #ifdef HAS_OBJECT1
145 | if (floor(object1Coord.s) == 0.0 &&
146 | floor(object1Coord.t) == 0.0) {
147 | vec4 object1 = m_Object1Color;
148 | object1 *= texture2D(m_Object1ColorMap, object1Coord);
149 | objects = mixColors(objects, object1);
150 | }
151 | #endif
152 |
153 | #ifdef HAS_OBJECT2
154 | if (floor(object2Coord.s) == 0.0 &&
155 | floor(object2Coord.t) == 0.0) {
156 | vec4 object2 = m_Object2Color;
157 | object2 *= texture2D(m_Object2ColorMap, object2Coord);
158 | objects = mixColors(objects, object2);
159 | }
160 | #endif
161 |
162 | #ifdef HAS_OBJECT3
163 | if (floor(object3Coord.s) == 0.0 &&
164 | floor(object3Coord.t) == 0.0) {
165 | vec4 object3 = m_Object3Color;
166 | object3 *= texture2D(m_Object3ColorMap, object3Coord);
167 | objects = mixColors(objects, object3);
168 | }
169 | #endif
170 |
171 | #ifdef HAS_OBJECT4
172 | if (floor(object4Coord.s) == 0.0 &&
173 | floor(object4Coord.t) == 0.0) {
174 | vec4 object4 = m_Object4Color;
175 | object4 *= texture2D(m_Object4ColorMap, object4Coord);
176 | objects = mixColors(objects, object4);
177 | }
178 | #endif
179 |
180 | #ifdef HAS_OBJECT5
181 | if (floor(object5Coord.s) == 0.0 &&
182 | floor(object5Coord.t) == 0.0) {
183 | vec4 object5 = m_Object5Color;
184 | object5 *= texture2D(m_Object5ColorMap, object5Coord);
185 | objects = mixColors(objects, object5);
186 | }
187 | #endif
188 |
189 | vec4 color = mixColors(stars, objects);
190 |
191 | vec4 clear = m_ClearColor;
192 | #ifdef HAS_HAZE
193 | vec4 haze = m_HazeColor;
194 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r;
195 | clear = mixColors(clear, haze);
196 | #endif
197 | color = mixColors(color, clear);
198 | // Bright parts of objects shine through the clear areas.
199 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a;
200 |
201 | #ifdef HAS_CLOUDS0
202 | vec4 clouds0 = m_Clouds0Color;
203 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r;
204 | color = mixColors(color, clouds0);
205 | #endif
206 |
207 | #ifdef HAS_CLOUDS1
208 | vec4 clouds1 = m_Clouds1Color;
209 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r;
210 | color = mixColors(color, clouds1);
211 | #endif
212 |
213 | #ifdef HAS_CLOUDS2
214 | vec4 clouds2 = m_Clouds2Color;
215 | clouds2.a *= texture2D(m_Clouds2AlphaMap, clouds2Coord).r;
216 | color = mixColors(color, clouds2);
217 | #endif
218 |
219 | #ifdef HAS_CLOUDS3
220 | vec4 clouds3 = m_Clouds3Color;
221 | clouds3.a *= texture2D(m_Clouds3AlphaMap, clouds3Coord).r;
222 | color = mixColors(color, clouds3);
223 | #endif
224 |
225 | #ifdef HAS_CLOUDS4
226 | vec4 clouds4 = m_Clouds4Color;
227 | clouds4.a *= texture2D(m_Clouds4AlphaMap, clouds4Coord).r;
228 | color = mixColors(color, clouds4);
229 | #endif
230 |
231 | #ifdef HAS_CLOUDS5
232 | vec4 clouds5 = m_Clouds5Color;
233 | clouds5.a *= texture2D(m_Clouds5AlphaMap, clouds5Coord).r;
234 | color = mixColors(color, clouds5);
235 | #endif
236 |
237 | gl_FragColor = color;
238 | }
--------------------------------------------------------------------------------
100 | *
104 | *
105 | * @param siderealTime radians since sidereal midnight (≥0, <2*Pi)
106 | * @return new unit vector
107 | */
108 | Vector3f getEquatorialLocation(float siderealTime) {
109 | assert siderealTime >= 0f : siderealTime;
110 | assert siderealTime < FastMath.TWO_PI : siderealTime;
111 |
112 | // Compute the hour angle.
113 | float hourAngle = siderealTime - rightAscension;
114 |
115 | // Convert hour angle and declination to Cartesian coordinates.
116 | float cosDec = FastMath.cos(declination);
117 | float cosHA = FastMath.cos(hourAngle);
118 | float sinDec = FastMath.sin(declination);
119 | float sinHA = FastMath.sin(hourAngle);
120 | float x = cosDec * cosHA;
121 | float y = -cosDec * sinHA;
122 | float z = sinDec;
123 | Vector3f result = new Vector3f(x, y, z);
124 |
125 | assert result.isUnitVector() : result;
126 | return result;
127 | }
128 | // *************************************************************************
129 | // Comparable methods
130 |
131 | /**
132 | * Compare this star to another star.
133 | *
134 | * @param other the other star
135 | * @return 0 if the stars are identical or not comparable
136 | */
137 | @Override
138 | public int compareTo(Star other) {
139 | Validate.nonNull(other, "object");
140 |
141 | if (apparentMagnitude < other.getApparentMagnitude()) {
142 | return 1;
143 | } else if (apparentMagnitude > other.getApparentMagnitude()) {
144 | return -1;
145 | }
146 | if (rightAscension < other.getRightAscension()) {
147 | return 1;
148 | } else if (rightAscension > other.getRightAscension()) {
149 | return -1;
150 | }
151 | if (declination < other.getDeclination()) {
152 | return 1;
153 | } else if (declination > other.getDeclination()) {
154 | return -1;
155 | }
156 |
157 | return 0;
158 | }
159 | // *************************************************************************
160 | // Object methods
161 |
162 | /**
163 | * Test for equality with another object.
164 | *
165 | * @param otherObject the object to compare (may be null, unaffected)
166 | * @return true if equivalent, otherwise false
167 | */
168 | @Override
169 | public boolean equals(Object otherObject) {
170 | boolean result;
171 | if (otherObject == this) {
172 | result = true;
173 | } else if (otherObject != null
174 | && otherObject.getClass() == getClass()) {
175 | Star otherStar = (Star) otherObject;
176 | result = (compareTo(otherStar) == 0);
177 | } else {
178 | result = false;
179 | }
180 |
181 | return result;
182 | }
183 |
184 | /**
185 | * Generate the hash code for this star.
186 | *
187 | * @return value for use in hashing
188 | */
189 | @Override
190 | public int hashCode() {
191 | int result = 137;
192 | result = 37 * result + Float.floatToIntBits(apparentMagnitude);
193 | result = 37 * result + Float.floatToIntBits(rightAscension);
194 | result = 37 * result + Float.floatToIntBits(declination);
195 |
196 | return result;
197 | }
198 | // *************************************************************************
199 | // private methods
200 |
201 | /**
202 | * Read the declination of the star.
203 | *
204 | * @return the declination angle (in radians)
205 | */
206 | private float getDeclination() {
207 | return declination;
208 | }
209 |
210 | /**
211 | * Read the right ascension of the star.
212 | *
213 | * @return the right-ascension angle (in radians)
214 | */
215 | private float getRightAscension() {
216 | return rightAscension;
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/SkyLibrary/src/main/resources/Shaders/skies/dome66/dome66glow.frag:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014-2022, Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software
13 | without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | /*
28 | * fragment shader used by dome66.j3md in its "Glow" technique
29 | */
30 | #import "Common/ShaderLib/GLSLCompat.glsllib"
31 | uniform vec4 m_ClearGlow;
32 | varying vec2 skyTexCoord;
33 |
34 | #ifdef HAS_OBJECT0
35 | uniform sampler2D m_Object0ColorMap;
36 | uniform vec4 m_Object0Glow;
37 | varying vec2 object0Coord;
38 | #endif
39 |
40 | #ifdef HAS_OBJECT1
41 | uniform sampler2D m_Object1ColorMap;
42 | uniform vec4 m_Object1Glow;
43 | varying vec2 object1Coord;
44 | #endif
45 |
46 | #ifdef HAS_OBJECT2
47 | uniform sampler2D m_Object2ColorMap;
48 | uniform vec4 m_Object2Glow;
49 | varying vec2 object2Coord;
50 | #endif
51 |
52 | #ifdef HAS_OBJECT3
53 | uniform sampler2D m_Object3ColorMap;
54 | uniform vec4 m_Object3Glow;
55 | varying vec2 object3Coord;
56 | #endif
57 |
58 | #ifdef HAS_OBJECT4
59 | uniform sampler2D m_Object4ColorMap;
60 | uniform vec4 m_Object4Glow;
61 | varying vec2 object4Coord;
62 | #endif
63 |
64 | #ifdef HAS_OBJECT5
65 | uniform sampler2D m_Object5ColorMap;
66 | uniform vec4 m_Object5Glow;
67 | varying vec2 object5Coord;
68 | #endif
69 |
70 | #ifdef HAS_HAZE
71 | uniform sampler2D m_HazeAlphaMap;
72 | uniform vec4 m_HazeGlow;
73 | #endif
74 |
75 | #ifdef HAS_CLOUDS0
76 | uniform sampler2D m_Clouds0AlphaMap;
77 | uniform vec4 m_Clouds0Glow;
78 | varying vec2 clouds0Coord;
79 | #endif
80 |
81 | #ifdef HAS_CLOUDS1
82 | uniform sampler2D m_Clouds1AlphaMap;
83 | uniform vec4 m_Clouds1Glow;
84 | varying vec2 clouds1Coord;
85 | #endif
86 |
87 | #ifdef HAS_CLOUDS2
88 | uniform sampler2D m_Clouds2AlphaMap;
89 | uniform vec4 m_Clouds2Glow;
90 | varying vec2 clouds2Coord;
91 | #endif
92 |
93 | #ifdef HAS_CLOUDS3
94 | uniform sampler2D m_Clouds3AlphaMap;
95 | uniform vec4 m_Clouds3Glow;
96 | varying vec2 clouds3Coord;
97 | #endif
98 |
99 | #ifdef HAS_CLOUDS4
100 | uniform sampler2D m_Clouds4AlphaMap;
101 | uniform vec4 m_Clouds4Glow;
102 | varying vec2 clouds4Coord;
103 | #endif
104 |
105 | #ifdef HAS_CLOUDS5
106 | uniform sampler2D m_Clouds5AlphaMap;
107 | uniform vec4 m_Clouds5Glow;
108 | varying vec2 clouds5Coord;
109 | #endif
110 |
111 | vec4 mixColors(vec4 color0, vec4 color1) {
112 | vec4 result;
113 | float a0 = color0.a * (1.0 - color1.a);
114 | result.a = a0 + color1.a;
115 | if (result.a > 0.0) {
116 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a;
117 | } else {
118 | result.rgb = vec3(0.0);
119 | }
120 | return result;
121 | }
122 |
123 | void main() {
124 | vec4 stars = vec4(0.0);
125 |
126 | vec4 objects = vec4(0.0);
127 |
128 | #ifdef HAS_OBJECT0
129 | if (floor(object0Coord.s) == 0.0 &&
130 | floor(object0Coord.t) == 0.0) {
131 | objects = m_Object0Glow;
132 | objects *= texture2D(m_Object0ColorMap, object0Coord);
133 | }
134 | #endif
135 |
136 | #ifdef HAS_OBJECT1
137 | if (floor(object1Coord.s) == 0.0 &&
138 | floor(object1Coord.t) == 0.0) {
139 | vec4 object1 = m_Object1Glow;
140 | object1 *= texture2D(m_Object1ColorMap, object1Coord);
141 | objects = mixColors(objects, object1);
142 | }
143 | #endif
144 |
145 | #ifdef HAS_OBJECT2
146 | if (floor(object2Coord.s) == 0.0 &&
147 | floor(object2Coord.t) == 0.0) {
148 | vec4 object2 = m_Object2Glow;
149 | object2 *= texture2D(m_Object2ColorMap, object2Coord);
150 | objects = mixColors(objects, object2);
151 | }
152 | #endif
153 |
154 | #ifdef HAS_OBJECT3
155 | if (floor(object3Coord.s) == 0.0 &&
156 | floor(object3Coord.t) == 0.0) {
157 | vec4 object3 = m_Object3Glow;
158 | object3 *= texture2D(m_Object3ColorMap, object3Coord);
159 | objects = mixColors(objects, object3);
160 | }
161 | #endif
162 |
163 | #ifdef HAS_OBJECT4
164 | if (floor(object4Coord.s) == 0.0 &&
165 | floor(object4Coord.t) == 0.0) {
166 | vec4 object4 = m_Object4Glow;
167 | object4 *= texture2D(m_Object4ColorMap, object4Coord);
168 | objects = mixColors(objects, object4);
169 | }
170 | #endif
171 |
172 | #ifdef HAS_OBJECT5
173 | if (floor(object5Coord.s) == 0.0 &&
174 | floor(object5Coord.t) == 0.0) {
175 | vec4 object5 = m_Object5Glow;
176 | object5 *= texture2D(m_Object5ColorMap, object5Coord);
177 | objects = mixColors(objects, object5);
178 | }
179 | #endif
180 |
181 | vec4 color = mixColors(stars, objects);
182 |
183 | vec4 clear = m_ClearGlow;
184 | #ifdef HAS_HAZE
185 | vec4 haze = m_HazeGlow;
186 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r;
187 | clear = mixColors(clear, haze);
188 | #endif
189 | color = mixColors(color, clear);
190 | // Bright parts of objects shine through the clear areas.
191 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a;
192 |
193 | #ifdef HAS_CLOUDS0
194 | vec4 clouds0 = m_Clouds0Glow;
195 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r;
196 | color = mixColors(color, clouds0);
197 | #endif
198 |
199 | #ifdef HAS_CLOUDS1
200 | vec4 clouds1 = m_Clouds1Glow;
201 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r;
202 | color = mixColors(color, clouds1);
203 | #endif
204 |
205 | #ifdef HAS_CLOUDS2
206 | vec4 clouds2 = m_Clouds2Glow;
207 | clouds2.a *= texture2D(m_Clouds2AlphaMap, clouds2Coord).r;
208 | color = mixColors(color, clouds2);
209 | #endif
210 |
211 | #ifdef HAS_CLOUDS3
212 | vec4 clouds3 = m_Clouds3Glow;
213 | clouds3.a *= texture2D(m_Clouds3AlphaMap, clouds3Coord).r;
214 | color = mixColors(color, clouds3);
215 | #endif
216 |
217 | #ifdef HAS_CLOUDS4
218 | vec4 clouds4 = m_Clouds4Glow;
219 | clouds4.a *= texture2D(m_Clouds4AlphaMap, clouds4Coord).r;
220 | color = mixColors(color, clouds4);
221 | #endif
222 |
223 | #ifdef HAS_CLOUDS5
224 | vec4 clouds5 = m_Clouds5Glow;
225 | clouds5.a *= texture2D(m_Clouds5AlphaMap, clouds5Coord).r;
226 | color = mixColors(color, clouds5);
227 | #endif
228 |
229 | gl_FragColor = color;
230 | }
--------------------------------------------------------------------------------
/SkyExamples/src/main/java/jme3utilities/sky/test/CubeMapExample.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014-2024 Stephen Gold
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the copyright holder nor the names of its contributors
12 | may be used to endorse or promote products derived from this software without
13 | specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 | package jme3utilities.sky.test;
27 |
28 | import com.jme3.app.SimpleApplication;
29 | import com.jme3.app.StatsAppState;
30 | import com.jme3.light.AmbientLight;
31 | import com.jme3.light.DirectionalLight;
32 | import com.jme3.material.Material;
33 | import com.jme3.math.ColorRGBA;
34 | import com.jme3.math.Vector3f;
35 | import com.jme3.scene.Spatial;
36 | import com.jme3.system.AppSettings;
37 | import com.jme3.terrain.geomipmap.TerrainQuad;
38 | import com.jme3.terrain.heightmap.ImageBasedHeightMap;
39 | import com.jme3.texture.Image;
40 | import com.jme3.texture.Texture;
41 | import java.util.logging.Logger;
42 | import jme3utilities.Heart;
43 | import jme3utilities.MyAsset;
44 | import jme3utilities.MyCamera;
45 | import jme3utilities.debug.PerformanceAppState;
46 |
47 | /**
48 | * Load a cubical star map generated by Alex Peterson's Spacescape tool:
49 | * http://alexcpeterson.com/spacescape
50 | *