├── .github └── workflows │ └── push.yml ├── .gitignore ├── LICENSE ├── MANIFEST.MF ├── README.md ├── SkyAssets ├── build.gradle └── src │ └── main │ ├── java │ └── jme3utilities │ │ └── sky │ │ └── textures │ │ ├── MakeClouds.java │ │ ├── MakeMoons.java │ │ ├── MakeRamps.java │ │ ├── MakeStarMaps.java │ │ ├── MakeSun.java │ │ ├── Star.java │ │ ├── StarMapPreset.java │ │ └── package-info.java │ └── resources │ └── empty ├── SkyExamples ├── build.gradle └── src │ └── main │ ├── java │ └── jme3utilities │ │ └── sky │ │ └── test │ │ ├── AppChooser.java │ │ ├── CubeMapExample.java │ │ ├── CubeMapExampleAfter.java │ │ ├── LandscapeControl.java │ │ ├── TestGlobeRenderer.java │ │ ├── TestSkyControl.java │ │ ├── TestSkyControlHud.java │ │ ├── TestSkyControlParameters.java │ │ ├── TestSkyControlRun.java │ │ ├── TestSkyMaterial.java │ │ ├── TestSkyMaterialHud.java │ │ ├── WaterExample.java │ │ └── package-info.java │ └── resources │ ├── Interface │ ├── Nifty │ │ ├── huds │ │ │ ├── test-sky-control.xml │ │ │ └── test-sky-material.xml │ │ └── screens │ │ │ └── AppChooser │ │ │ └── mainScreen.xml │ └── bindings │ │ └── TestSkyControl.properties │ └── Textures │ ├── skies │ ├── clouds │ │ ├── cyclone.png │ │ └── license.txt │ ├── star-maps │ │ └── purple-nebula-complex │ │ │ ├── license.txt │ │ │ ├── purple-nebula-complex_back6.png │ │ │ ├── purple-nebula-complex_bottom4.png │ │ │ ├── purple-nebula-complex_front5.png │ │ │ ├── purple-nebula-complex_left2.png │ │ │ ├── purple-nebula-complex_right1.png │ │ │ └── purple-nebula-complex_top3.png │ └── t0neg0d │ │ ├── Clouds_L.png │ │ ├── Sun_L.png │ │ └── license.txt │ └── terrain │ └── height │ └── basin.png ├── SkyLibrary ├── build.gradle ├── release-notes.md └── src │ ├── main │ ├── java │ │ └── jme3utilities │ │ │ └── sky │ │ │ ├── CloudLayer.java │ │ │ ├── Constants.java │ │ │ ├── FloorControl.java │ │ │ ├── GlobeRenderer.java │ │ │ ├── LunarPhase.java │ │ │ ├── SkyControl.java │ │ │ ├── SkyControlCore.java │ │ │ ├── SkyMaterial.java │ │ │ ├── SkyMaterialCore.java │ │ │ ├── StarsOption.java │ │ │ ├── SunAndStars.java │ │ │ ├── Updater.java │ │ │ ├── WaterProcessor.java │ │ │ └── package-info.java │ └── resources │ │ ├── MatDefs │ │ └── skies │ │ │ ├── dome02 │ │ │ └── dome02.j3md │ │ │ ├── dome06 │ │ │ └── dome06.j3md │ │ │ ├── dome20 │ │ │ └── dome20.j3md │ │ │ ├── dome22 │ │ │ └── dome22.j3md │ │ │ ├── dome60 │ │ │ └── dome60.j3md │ │ │ └── dome66 │ │ │ └── dome66.j3md │ │ └── Shaders │ │ └── skies │ │ ├── dome02 │ │ ├── dome02.frag │ │ ├── dome02.vert │ │ └── dome02glow.frag │ │ ├── dome06 │ │ ├── dome06.frag │ │ ├── dome06.vert │ │ └── dome06glow.frag │ │ ├── dome20 │ │ ├── dome20.frag │ │ ├── dome20.vert │ │ └── dome20glow.frag │ │ ├── dome22 │ │ ├── dome22.frag │ │ ├── dome22.vert │ │ └── dome22glow.frag │ │ ├── dome60 │ │ ├── dome60.frag │ │ ├── dome60.vert │ │ └── dome60glow.frag │ │ └── dome66 │ │ ├── dome66.frag │ │ ├── dome66.vert │ │ └── dome66glow.frag │ └── test │ └── java │ └── jme3utilities │ └── sky │ └── test │ ├── TestClone.java │ ├── TestSunAndStars.java │ └── package-info.java ├── build.gradle ├── common.gradle ├── config └── checkstyle │ ├── checkstyle.xml │ └── java-header ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # GitHub Actions workflow for commits pushed to the SkyControl repo - all branches 3 | 4 | name: CI at GitHub 5 | on: [push] 6 | 7 | jobs: 8 | Java8-Linux: 9 | if: contains(toJson(github.event.commits), '[ci skip] ') == false 10 | runs-on: ubuntu-22.04 11 | timeout-minutes: 3 12 | steps: 13 | - uses: actions/setup-java@v4 14 | with: 15 | distribution: 'zulu' 16 | java-version: 8 17 | - uses: actions/checkout@v4 18 | - run: ./gradlew build --console=plain --stacktrace 19 | 20 | Java11-Linux: 21 | if: contains(toJson(github.event.commits), '[ci skip] ') == false 22 | runs-on: ubuntu-24.04 23 | timeout-minutes: 3 24 | steps: 25 | - uses: actions/setup-java@v4 26 | with: 27 | distribution: 'zulu' 28 | java-version: 11 29 | - uses: actions/checkout@v4 30 | - uses: gradle/actions/wrapper-validation@v4 31 | - run: ./gradlew build --console=plain --stacktrace 32 | 33 | Java17-MacOS: 34 | if: contains(toJson(github.event.commits), '[ci skip] ') == false 35 | runs-on: macOS-13 36 | timeout-minutes: 10 37 | steps: 38 | - uses: actions/setup-java@v4 39 | with: 40 | distribution: 'zulu' 41 | java-version: 17 42 | - uses: actions/checkout@v4 43 | - run: ./gradlew build --console=plain --stacktrace 44 | 45 | Java21-MacOS: 46 | if: contains(toJson(github.event.commits), '[ci skip] ') == false 47 | runs-on: macOS-15 48 | timeout-minutes: 10 49 | steps: 50 | - uses: actions/setup-java@v4 51 | with: 52 | distribution: 'zulu' 53 | java-version: 21 54 | - uses: actions/checkout@v4 55 | - run: ./gradlew build --console=plain --stacktrace 56 | 57 | Java24-Windows: 58 | if: contains(toJson(github.event.commits), '[ci skip] ') == false 59 | runs-on: windows-2025 60 | timeout-minutes: 3 61 | steps: 62 | - uses: actions/setup-java@v4 63 | with: 64 | distribution: 'zulu' 65 | java-version: 24 66 | - uses: actions/checkout@v4 67 | - run: ./gradlew build --console=plain --stacktrace 68 | shell: bash 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.dylib 3 | *.so 4 | /SkyAssets/src/main/resources/bsc5.dat 5 | /SkyAssets/src/main/resources/bsc5.dat.gz 6 | /SkyExamples/private/ 7 | /SkyExamples/Written Assets/ 8 | /SkyLibrary/src/main/resources/Textures/skies/ 9 | 10 | # Ignore Gradle's project-specific cache directory: 11 | /.gradle/ 12 | 13 | # Ignore Gradle's build output directories: 14 | /build/ 15 | /SkyAssets/build/ 16 | /SkyExamples/build/ 17 | /SkyLibrary/build/ 18 | 19 | # Ignore IDE-specific directories: 20 | /.idea/ 21 | /.nb-gradle/ 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2025 Stephen Gold 2 | 3 | Note: the following license does not apply to certain assets/resources 4 | (1 file in SkyExamples/src/main/resources/Textures/skies/clouds and 5 | 2 files in SkyExamples/src/main/resources/Textures/skies/t0neg0d) 6 | which are separately licensed. 7 | 8 | BSD 3-Clause License 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 16 | 2. Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | 3. Neither the name of the copyright holder nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /MANIFEST.MF: -------------------------------------------------------------------------------- 1 | X-Comment: Created with jMonkeyPlatform 2 | -------------------------------------------------------------------------------- /SkyAssets/build.gradle: -------------------------------------------------------------------------------- 1 | // Gradle script to build the SkyAssets 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 | // of the root project. 6 | 7 | plugins { 8 | alias(libs.plugins.download) // to retrieve files from URLs 9 | } 10 | 11 | ext { 12 | bsc = 'src/main/resources/bsc5.dat' 13 | skies = '../SkyLibrary/src/main/resources/Textures/skies' 14 | } 15 | 16 | sourceSets.main.java { 17 | srcDir 'src/main/java' 18 | srcDir '../SkyLibrary/src/main/java' 19 | } 20 | 21 | dependencies { 22 | implementation(libs.heart) 23 | implementation(libs.jcommander) 24 | 25 | implementation(libs.jme3.core) 26 | implementation(libs.jme3.effects) 27 | } 28 | 29 | // Register cleanup tasks: 30 | 31 | clean.dependsOn('cleanCatalog', 'cleanDownload', 'cleanSkyTextures') 32 | 33 | // decompress the Yale Bright Star Catalog 34 | 35 | tasks.register('catalog') { 36 | dependsOn 'download' 37 | doLast { file(bsc).text = resources.gzip("${bsc}.gz").read().text } 38 | } 39 | tasks.register('cleanCatalog', Delete) { 40 | delete file(bsc) 41 | } 42 | 43 | // download gzipped Yale Bright Star Catalog 44 | 45 | processResources.dependsOn('download') 46 | tasks.register('download', Download) { 47 | src 'http://tdc-www.harvard.edu/catalogs/bsc5.dat.gz' 48 | dest file("${bsc}.gz") 49 | overwrite false 50 | } 51 | tasks.register('cleanDownload', Delete) { 52 | delete file("${bsc}.gz") 53 | } 54 | 55 | // Register tasks to generate sky textures: 56 | 57 | tasks.register('skyTextures') { 58 | dependsOn = ['clouds', 'equator', 'equator16m', 'moons', 'north', \ 59 | 'north16m', 'ramps', 'south', 'south16m', 'suns', 'wiltshire', \ 60 | 'wiltshire16m'] 61 | description = 'generate texture assets distributed with SkyControl' 62 | } 63 | tasks.register('cleanSkyTextures', Delete) { 64 | delete fileTree(dir: skies) 65 | } 66 | 67 | tasks.register('clouds', JavaExec) { 68 | mainClass = 'jme3utilities.sky.textures.MakeClouds' 69 | outputs.files(["$skies/clouds/clear.png", \ 70 | "$skies/clouds/fbm.png", \ 71 | "$skies/clouds/overcast.png"]) 72 | } 73 | tasks.register('debugEquator', JavaExec) { 74 | args = ['-c', '-p', 'equator'] 75 | debug true 76 | dependsOn catalog 77 | inputs.files(bsc) 78 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 79 | } 80 | tasks.register('equator', JavaExec) { 81 | args = ['-c', '-p', 'equator'] 82 | dependsOn catalog 83 | inputs.files(bsc) 84 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 85 | outputs.files(fileTree("$skies/star-maps/equator")) 86 | } 87 | tasks.register('equator16m', JavaExec) { 88 | args = ['-c', '-p', 'equator_16m'] 89 | dependsOn catalog 90 | inputs.files(bsc) 91 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 92 | outputs.files(fileTree("$skies/star-maps/equator16m")) 93 | } 94 | tasks.register('moons', JavaExec) { 95 | mainClass = 'jme3utilities.sky.textures.MakeMoons' 96 | outputs.files(fileTree("$skies/moon-nonviral")) 97 | } 98 | tasks.register('north', JavaExec) { 99 | args = ['-p', 'north'] 100 | dependsOn catalog 101 | inputs.files(bsc) 102 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 103 | outputs.files("$skies/star-maps/northern.png") 104 | } 105 | tasks.register('north16m', JavaExec) { 106 | args = ['-p', 'north_16m'] 107 | dependsOn catalog 108 | inputs.files(bsc) 109 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 110 | outputs.files("$skies/star-maps/16m/northern.png") 111 | } 112 | tasks.register('ramps', JavaExec) { 113 | mainClass = 'jme3utilities.sky.textures.MakeRamps' 114 | outputs.files("$skies/ramps/haze.png") 115 | } 116 | tasks.register('south', JavaExec) { 117 | args = ['-p', 'south'] 118 | dependsOn catalog 119 | inputs.files(bsc) 120 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 121 | outputs.files("$skies/star-maps/southern.png") 122 | } 123 | tasks.register('south16m', JavaExec) { 124 | args = ['-p', 'south_16m'] 125 | dependsOn catalog 126 | inputs.files(bsc) 127 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 128 | outputs.files("$skies/star-maps/16m/southern.png") 129 | } 130 | tasks.register('suns', JavaExec) { 131 | mainClass = 'jme3utilities.sky.textures.MakeSun' 132 | outputs.files(fileTree("$skies/suns")) 133 | } 134 | tasks.register('wiltshire', JavaExec) { 135 | args = ['-p', 'wiltshire'] 136 | dependsOn catalog 137 | inputs.files(bsc) 138 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 139 | outputs.files("$skies/star-maps/wiltshire.png") 140 | } 141 | tasks.register('wiltshire16m', JavaExec) { 142 | args = ['-p', 'wiltshire_16m'] 143 | dependsOn catalog 144 | inputs.files(bsc) 145 | mainClass = 'jme3utilities.sky.textures.MakeStarMaps' 146 | outputs.files("$skies/star-maps/16m/wiltshire.png") 147 | } 148 | -------------------------------------------------------------------------------- /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 { 39 | // ************************************************************************* 40 | // constants 41 | 42 | /** 43 | * message logger for this class 44 | */ 45 | final private static Logger logger = Logger.getLogger(Star.class.getName()); 46 | // ************************************************************************* 47 | // fields 48 | 49 | /** 50 | * apparent brightness (inverted logarithmic scale, set by constructor) 51 | */ 52 | final private float apparentMagnitude; 53 | /** 54 | * declination (radians north of the celestial equator, ≤Pi/2, ≥-Pi/2, 55 | * set by constructor) 56 | */ 57 | final private float declination; 58 | /** 59 | * right ascension (radians east of the March equinox, <2*Pi, ≥0, set 60 | * by constructor) 61 | */ 62 | final private float rightAscension; 63 | // ************************************************************************* 64 | // constructors 65 | 66 | /** 67 | * Instantiate a star. 68 | * 69 | * @param rightAscension radians east of the March equinox (≤2*Pi, ≥0) 70 | * @param declination radians north of the celestial equator (≤Pi/2, 71 | * ≥-Pi/2) 72 | * 73 | * @param apparentMagnitude apparent brightness (inverted logarithmic scale) 74 | */ 75 | Star(float rightAscension, float declination, float apparentMagnitude) { 76 | assert declination <= FastMath.HALF_PI : declination; 77 | assert declination >= -FastMath.HALF_PI : declination; 78 | assert rightAscension >= 0f : rightAscension; 79 | assert rightAscension < FastMath.TWO_PI : rightAscension; 80 | 81 | this.rightAscension = rightAscension; 82 | this.declination = declination; 83 | this.apparentMagnitude = apparentMagnitude; 84 | } 85 | // ************************************************************************* 86 | // new methods exposed 87 | 88 | /** 89 | * Read the star's apparent brightness. 90 | * 91 | * @return magnitude (inverted logarithmic scale) 92 | */ 93 | float getApparentMagnitude() { 94 | return apparentMagnitude; 95 | } 96 | 97 | /** 98 | * Compute a star's position in a right-handed Cartesian equatorial 99 | * coordinate system where: 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 | -------------------------------------------------------------------------------- /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/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, 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 | /** 27 | * Classes to generate static textures used by SkyControl and SkyMaterial. 28 | */ 29 | package jme3utilities.sky.textures; -------------------------------------------------------------------------------- /SkyAssets/src/main/resources/empty: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /SkyExamples/build.gradle: -------------------------------------------------------------------------------- 1 | // Gradle script to build and run the SkyExamples 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 | // of the root project. 6 | 7 | plugins { 8 | id 'application' // to build JVM applications 9 | } 10 | 11 | dependencies { 12 | implementation(libs.commons.exec) 13 | 14 | implementation(libs.acorus) 15 | implementation(libs.heart) 16 | implementation(libs.jcommander) 17 | implementation(libs.jme3.utilities.nifty) 18 | 19 | runtimeOnly(libs.nifty.style.black) 20 | runtimeOnly(libs.jme3.awt.dialogs) 21 | runtimeOnly(libs.jme3.desktop) 22 | implementation(libs.jme3.lwjgl3) 23 | implementation(libs.jme3.terrain) 24 | runtimeOnly(libs.jme3.testdata) 25 | 26 | // SkyExamples doesn't use jme3-jogg nor jme3-plugins 27 | // -- they are included solely to avoid runtime warnings from AssetConfig: 28 | runtimeOnly(libs.jme3.jogg) 29 | runtimeOnly(libs.jme3.plugins) 30 | 31 | //implementation 'com.github.stephengold:SkyControl:' + skycontrolVersion // for published library 32 | implementation project(':SkyLibrary') // for latest sourcecode 33 | } 34 | 35 | import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform 36 | Boolean isMacOS = DefaultNativePlatform.currentOperatingSystem.isMacOsX() 37 | 38 | tasks.withType(JavaExec).configureEach { // Java runtime options: 39 | if (isMacOS) { 40 | jvmArgs '-XstartOnFirstThread' 41 | } 42 | //args '--verbose' // to enable additional log output 43 | dependsOn 'installDist' 44 | } 45 | 46 | startScripts.dependsOn(':SkyLibrary:assemble') 47 | 48 | // Register cleanup tasks: 49 | 50 | clean.dependsOn('cleanDLLs', 'cleanDyLibs', 'cleanLogs', 'cleanSandbox', 'cleanSOs') 51 | 52 | tasks.register('cleanDLLs', Delete) { // extracted Windows native libraries 53 | delete fileTree(dir: '.', include: '*.dll') 54 | } 55 | tasks.register('cleanDyLibs', Delete) { // extracted macOS native libraries 56 | delete fileTree(dir: '.', include: '*.dylib') 57 | } 58 | tasks.register('cleanLogs', Delete) { // JVM crash logs 59 | delete fileTree(dir: '.', include: 'hs_err_pid*.log') 60 | } 61 | tasks.register('cleanSandbox', Delete) { // Acorus sandbox 62 | delete 'Written Assets' 63 | } 64 | tasks.register('cleanSOs', Delete) { // extracted Linux and Android native libraries 65 | delete fileTree(dir: '.', include: '*.so') 66 | } 67 | 68 | // Register tasks to run the example apps: 69 | 70 | tasks.register('AppChooser', JavaExec) { 71 | mainClass = 'jme3utilities.sky.test.AppChooser' 72 | } 73 | 74 | tasks.register('CubeMapExample', JavaExec) { 75 | mainClass = 'jme3utilities.sky.test.CubeMapExample' 76 | } 77 | tasks.register('CubeMapExampleAfter', JavaExec) { 78 | mainClass = 'jme3utilities.sky.test.CubeMapExampleAfter' 79 | } 80 | tasks.register('TestGlobeRenderer', JavaExec) { 81 | mainClass = 'jme3utilities.sky.test.TestGlobeRenderer' 82 | } 83 | tasks.register('WaterExample', JavaExec) { 84 | mainClass = 'jme3utilities.sky.test.WaterExample' 85 | } 86 | 87 | tasks.register('debugTestSkyControl', JavaExec) { 88 | debug true 89 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 90 | } 91 | tasks.register('TestSkyControl', JavaExec) { 92 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 93 | } 94 | tasks.register('TestSkyControlCyclone', JavaExec) { 95 | args '-c' 96 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 97 | } 98 | tasks.register('TestSkyControlShadowFilter', JavaExec) { 99 | args '-f' 100 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 101 | } 102 | tasks.register('TestSkyControlNoCubes', JavaExec) { 103 | args '-n' 104 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 105 | } 106 | tasks.register('TestSkyControlSingleDome', JavaExec) { 107 | args '-s' 108 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 109 | } 110 | tasks.register('TestSkyControlUsage', JavaExec) { 111 | args '-u' 112 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 113 | } 114 | tasks.register('TestSkyControlWater', JavaExec) { 115 | args '-w' 116 | mainClass = 'jme3utilities.sky.test.TestSkyControl' 117 | } 118 | 119 | tasks.register('TestSkyMaterial', JavaExec) { 120 | mainClass = 'jme3utilities.sky.test.TestSkyMaterial' 121 | } 122 | -------------------------------------------------------------------------------- /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 | *

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 | -------------------------------------------------------------------------------- /SkyExamples/src/main/java/jme3utilities/sky/test/TestSkyControlParameters.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.test; 27 | 28 | import com.beust.jcommander.Parameter; 29 | import java.util.logging.Logger; 30 | 31 | /** 32 | * Command-line parameters of the TestSkyControl application. 33 | * 34 | * @author Stephen Gold sgold@sonic.net 35 | */ 36 | class TestSkyControlParameters { 37 | // ************************************************************************* 38 | // constants and loggers 39 | 40 | /** 41 | * message logger for this class 42 | */ 43 | final private static Logger logger 44 | = Logger.getLogger(TestSkyControlParameters.class.getName()); 45 | // ************************************************************************* 46 | // fields 47 | 48 | /** 49 | * true means use the cyclone cloud map; false means use default cloud maps 50 | */ 51 | @Parameter(names = {"-c", "--cyclone"}, 52 | description = "use cyclone cloud map") 53 | private boolean cyclone = false; 54 | /** 55 | * true means use a star cube; false means use star domes instead 56 | *

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 | -------------------------------------------------------------------------------- /SkyExamples/src/main/java/jme3utilities/sky/test/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, 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 | /** 27 | * Applications to test and/or demonstrate the capabilities of the 28 | * jme3utilities.sky package. 29 | */ 30 | package jme3utilities.sky.test; -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Interface/Nifty/screens/AppChooser/mainScreen.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 31 | 32 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Interface/bindings/TestSkyControl.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | custom hotkey bindings for default mode 5 | signal FLYCAM_StrafeRight 6 | SIMPLEAPP_CameraPos 7 | signal FLYCAM_StrafeLeft 8 | SIMPLEAPP_HideStats 9 | signal FLYCAM_Forward 10 | signal FLYCAM_Backward 11 | edit bindings 12 | signal FLYCAM_Lower 13 | signal FLYCAM_Rise 14 | SIMPLEAPP_Memory 15 | SIMPLEAPP_Exit 16 | toggle hud 17 | load scene 18 | save scene 19 | print scene 20 | signal FLYCAM_Lower 21 | 22 | -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/clouds/cyclone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/clouds/cyclone.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/clouds/license.txt: -------------------------------------------------------------------------------- 1 | Licensing history for assets in SkyExamples/src/main/resources/Textures/skies/clouds 2 | 3 | The file "cyclone.jpg" is derived from an image downloaded from 4 | http://eoimages.gsfc.nasa.gov/images/imagerecords/68000/68479/Isabel.A2003257.1445.250m.jpg 5 | where it was described as a "true-color image of Hurricane Isabel about 400 miles 6 | north of Puerto Rico on September 14, 2003" and credited to "Jacques 7 | Descloitres, MODIS Rapid Response Team, NASA/GSFC". According to the site, 8 | "Most images published in Visible Earth are freely available for re-publication 9 | or re-use, including commercial purposes, except for where copyright is 10 | indicated. We ask that you use the credit statement attached with each image or 11 | else credit Visible Earth; the only mandatory credit is NASA." 12 | 13 | Stephen Gold makes "cyclone.jpg" available under the Creative Commons 14 | Attribution-Share Alike 3.0 Unported license -- see 15 | https://creativecommons.org/licenses/by-sa/3.0/ 16 | for details. When sharing or reusing this file, please attribute it to 17 | "Stephen Gold's jme3-utilities Project at https://github.com/stephengold/jme3-utilities" 18 | 19 | It is easier to ask permission than forgiveness. To request a custom license 20 | granting rights not included in the CC-BY-SA terms, send an e-mail to 21 | sgold@sonic.net with "custom license request" in the subject. Please 22 | clearly indicate: 23 | (1) your legal name 24 | (2) which assets you want to license 25 | (3) name and brief description of your project, if applicable 26 | (4) the licensee (person or organization that will hold the custom license) 27 | (5) what rights you are requesting (i.e. "non-exclusive and non-transferable 28 | perpetual license to incorporate into proprietary software with worldwide 29 | distribution") -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/license.txt: -------------------------------------------------------------------------------- 1 | Licensing history for files in "src/main/resources/Textures/skies/star-maps/purple-nebula-complex" 2 | 3 | * title of work: "Purple Nebula Complex" 4 | * download URL: https://github.com/stephengold/SkyControl/tree/master/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex 5 | * author: Stephen Gold 6 | * author URL: https://github.com/stephengold 7 | * copyright: none (dedicated to the public domain) 8 | * license type: CC0 1.0 Universal 9 | * license URL: https://creativecommons.org/publicdomain/zero/1.0/ 10 | 11 | Files: 12 | * license.txt 13 | * purple-nebula-complex_back6.png 14 | * purple-nebula-complex_bottom4.png 15 | * purple-nebula-complex_front5.png 16 | * purple-nebula-complex_left2.png 17 | * purple-nebula-complex_right1.png 18 | * purple-nebula-complex_top3.png 19 | 20 | Created using Alex C. Peterson's Spacescape tool: 21 | http://alexcpeterson.com/spacescape -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_back6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_back6.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_bottom4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_bottom4.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_front5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_front5.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_left2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_left2.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_right1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_right1.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_top3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/star-maps/purple-nebula-complex/purple-nebula-complex_top3.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/t0neg0d/Clouds_L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/t0neg0d/Clouds_L.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/t0neg0d/Sun_L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/skies/t0neg0d/Sun_L.png -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/skies/t0neg0d/license.txt: -------------------------------------------------------------------------------- 1 | Licensing history for assets in SkyExamples/src/main/resources/Textures/skies/t0neg0d 2 | 3 | Note: the file "Sun_L.png" has been cropped since it was downloaded. 4 | 5 | The files "Clouds_L.j3o", "Sun_L.png", and "license.txt" were originally 6 | downloaded from 7 | http://code.google.com/p/jmonkeyplatform-contributions/source/browse/trunk/SkyDome 8 | where they were licensed as follows: 9 | 10 | Copyright (c) 2013, t0neg0d 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 16 | 1. Redistributions of source code must retain the above copyright notice, this 17 | list of conditions and the following disclaimer. 18 | 2. Redistributions in binary form must reproduce the above copyright notice, 19 | this list of conditions and the following disclaimer in the documentation 20 | and/or other materials provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 26 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | The views and conclusions contained in the software and documentation are those 34 | of the authors and should not be interpreted as representing official policies, 35 | either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- /SkyExamples/src/main/resources/Textures/terrain/height/basin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/SkyExamples/src/main/resources/Textures/terrain/height/basin.png -------------------------------------------------------------------------------- /SkyLibrary/build.gradle: -------------------------------------------------------------------------------- 1 | // Gradle script to build 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 | // 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 | alias(libs.plugins.validate.poms) // to verify POMs provide all info required by Maven Central 12 | } 13 | 14 | ext { 15 | group = 'com.github.stephengold' 16 | artifact = 'SkyControl' 17 | version = skycontrolVersion 18 | baseName = "${artifact}-${version}" // for artifacts 19 | websiteUrl = 'https://github.com/stephengold/SkyControl' 20 | } 21 | 22 | processResources.dependsOn(':SkyAssets:skyTextures') 23 | 24 | dependencies { 25 | api(libs.jme3.effects) 26 | api(libs.heart) 27 | 28 | testImplementation(libs.jme3.desktop) 29 | testImplementation(libs.junit4) 30 | } 31 | 32 | // Register publishing tasks: 33 | 34 | tasks.register('install') { 35 | dependsOn 'publishMavenPublicationToMavenLocal' 36 | description = 'Installs Maven artifacts to the local repository.' 37 | } 38 | tasks.register('release') { 39 | dependsOn 'publishMavenPublicationToOSSRHRepository' 40 | description = 'Stages Maven artifacts to Sonatype OSSRH.' 41 | } 42 | 43 | jar { 44 | archiveBaseName = project.ext.baseName 45 | doLast { 46 | println "using Java ${JavaVersion.current()} (${System.getProperty("java.vendor")})" 47 | } 48 | manifest { 49 | attributes 'Created-By': "${JavaVersion.current()} (${System.getProperty("java.vendor")})" 50 | } 51 | } 52 | java.withJavadocJar() 53 | javadocJar { archiveBaseName = project.ext.baseName } 54 | tasks.register('sourcesJar', Jar) { 55 | archiveBaseName = project.ext.baseName 56 | archiveClassifier = 'sources' 57 | description = 'Creates a JAR of Java sourcecode.' 58 | from sourceSets.main.allJava // default is ".allSource", which includes resources 59 | } 60 | 61 | assemble.dependsOn('module', 'moduleAsc', 'pom', 'pomAsc') 62 | tasks.register('module', Copy) { 63 | dependsOn 'generateMetadataFileForMavenPublication' 64 | description = 'Copies the module metadata to build/libs.' 65 | from "${buildDir}/publications/maven/module.json" 66 | into "${buildDir}/libs" 67 | rename 'module.json', project.ext.baseName + '.module' 68 | } 69 | tasks.register('moduleAsc', Copy) { 70 | dependsOn 'signMavenPublication' 71 | description = 'Copies the signature of the module metadata to build/libs.' 72 | from "${buildDir}/publications/maven/module.json.asc" 73 | into "${buildDir}/libs" 74 | rename 'module.json.asc', project.ext.baseName + '.module.asc' 75 | } 76 | tasks.register('pom', Copy) { 77 | dependsOn 'generatePomFileForMavenPublication' 78 | description = 'Copies the Maven POM to build/libs.' 79 | from "${buildDir}/publications/maven/pom-default.xml" 80 | into "${buildDir}/libs" 81 | rename 'pom-default.xml', project.ext.baseName + '.pom' 82 | } 83 | tasks.register('pomAsc', Copy) { 84 | dependsOn 'signMavenPublication' 85 | description = 'Copies the signature of the Maven POM to build/libs.' 86 | from "${buildDir}/publications/maven/pom-default.xml.asc" 87 | into "${buildDir}/libs" 88 | rename 'pom-default.xml.asc', project.ext.baseName + '.pom.asc' 89 | } 90 | 91 | publishing { 92 | publications { 93 | maven(MavenPublication) { 94 | artifact sourcesJar 95 | artifactId = artifact 96 | from components.java 97 | groupId = project.ext.group 98 | pom { 99 | description = 'A sky-simulation library for jMonkeyEngine' 100 | developers { 101 | developer { 102 | email = 'sgold@sonic.net' 103 | id = 'stephengold' 104 | name = 'Stephen Gold' 105 | } 106 | } 107 | licenses { 108 | license { 109 | distribution = 'repo' 110 | name = 'New BSD (3-clause) License' 111 | url = 'https://opensource.org/licenses/BSD-3-Clause' 112 | } 113 | } 114 | name = project.ext.group + ':' + artifact 115 | scm { 116 | connection = 'scm:git:git://github.com/stephengold/SkyControl.git' 117 | developerConnection = 'scm:git:ssh://github.com:stephengold/SkyControl.git' 118 | url = project.ext.websiteUrl + '/tree/master' 119 | } 120 | url = project.ext.websiteUrl 121 | } 122 | version = project.ext.version 123 | } 124 | } 125 | // Staging to OSSRH relies on the existence of 2 properties 126 | // (ossrhUsername and ossrhPassword) 127 | // which should be stored in ~/.gradle/gradle.properties 128 | repositories { 129 | maven { 130 | credentials { 131 | username = project.hasProperty('ossrhUsername') ? ossrhUsername : 'Unknown user' 132 | password = project.hasProperty('ossrhPassword') ? ossrhPassword : 'Unknown password' 133 | } 134 | name = 'OSSRH' 135 | url = 'https://s01.oss.sonatype.org/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 | publishMavenPublicationToOSSRHRepository.dependsOn('assemble') 145 | 146 | // Register signing tasks: 147 | 148 | // Signing relies on the existence of 3 properties 149 | // (signing.keyId, signing.password, and signing.secretKeyRingFile) 150 | // which should be stored in ~/.gradle/gradle.properties 151 | 152 | signing { 153 | sign publishing.publications.maven 154 | } 155 | tasks.withType(Sign).configureEach { 156 | onlyIf { rootProject.hasProperty('signing.keyId') } 157 | } 158 | signMavenPublication.dependsOn('module') -------------------------------------------------------------------------------- /SkyLibrary/src/main/java/jme3utilities/sky/Constants.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; 27 | 28 | import com.jme3.math.FastMath; 29 | import com.jme3.math.Vector2f; 30 | import jme3utilities.math.MyMath; 31 | 32 | /** 33 | * Constants shared among classes the jme3utilities.sky package. 34 | * 35 | * @author Stephen Gold sgold@sonic.net 36 | */ 37 | final public class Constants { 38 | // ************************************************************************* 39 | // constants and loggers 40 | 41 | /** 42 | * maximum value for any opacity 43 | */ 44 | final static float alphaMax = 1f; 45 | /** 46 | * minimum value for opacity 47 | */ 48 | final static float alphaMin = 0f; 49 | /** 50 | * default observer's latitude - Wiltshire (radians north of the equator) 51 | */ 52 | final static float defaultLatitude = MyMath.toRadians(51.1788f); 53 | /** 54 | * UV diameter of a sun's disc: in order to leave room for rays, haloes, and 55 | * haze, the disc is only 1/4 as wide as the color map. 56 | */ 57 | final public static float discDiameter = 0.25f; 58 | /** 59 | * first (U) texture coordinate of the top of a DomeMesh 60 | */ 61 | final static float topU = 0.5f; 62 | /** 63 | * 2nd (V) texture coordinate of the top of a DomeMesh 64 | */ 65 | final static float topV = 0.5f; 66 | /** 67 | * maximum value for texture coordinates that do not wrap 68 | */ 69 | final public static float uvMax = 1f; 70 | /** 71 | * minimum value for texture coordinates that do not wrap 72 | */ 73 | final public static float uvMin = 0f; 74 | /** 75 | * UV distance from top to rim (<0.5, >0) 76 | */ 77 | final static float uvScale = 0.44f; 78 | /** 79 | * coefficient used to compute the stretchFactor for objects projected onto 80 | * a DomeMesh 81 | */ 82 | final public static float stretchCoefficient 83 | = (FastMath.HALF_PI - uvMax) / (uvScale * uvScale); 84 | /** 85 | * the duration of a full day (in hours) 86 | */ 87 | final public static int hoursPerDay = 24; 88 | /** 89 | * texture coordinates of the top of a DomeMesh 90 | */ 91 | final public static Vector2f topUV = new Vector2f(topU, topV); 92 | // ************************************************************************* 93 | // constructors 94 | 95 | /** 96 | * A private constructor to inhibit instantiation of this class. 97 | */ 98 | private Constants() { 99 | } 100 | // ************************************************************************* 101 | // new methods exposed 102 | 103 | /** 104 | * Determine the terse version string for the SkyControl library. 105 | * 106 | * @return branch and revision (not null, not empty) 107 | */ 108 | public static String versionShort() { 109 | return "master 1.1.1-SNAPSHOT"; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /SkyLibrary/src/main/java/jme3utilities/sky/LunarPhase.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-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; 27 | 28 | import com.jme3.math.FastMath; 29 | import jme3utilities.Validate; 30 | 31 | /** 32 | * Enumerate some phases of the moon. 33 | * 34 | * @author Stephen Gold sgold@sonic.net 35 | */ 36 | public enum LunarPhase { 37 | // ************************************************************************* 38 | // values 39 | 40 | /** 41 | * full moon: phase angle = 180 degrees 42 | */ 43 | FULL, 44 | /** 45 | * 65% past full: phase angle = 297 degrees 46 | */ 47 | WANING_CRESCENT, 48 | /** 49 | * 1/4 past full: phase angle = 225 degrees 50 | */ 51 | WANING_GIBBOUS, 52 | /** 53 | * 35% past new: phase angle = 63 degrees 54 | */ 55 | WAXING_CRESCENT, 56 | /** 57 | * 3/4 past new: phase angle = 135 degrees 58 | */ 59 | WAXING_GIBBOUS, 60 | /** 61 | * custom phase: phase angle not defined 62 | */ 63 | CUSTOM; 64 | // ************************************************************************* 65 | // new methods exposed 66 | 67 | /** 68 | * Look up the textual description of this phase. Unlike toString(), the 69 | * description is in lower case. 70 | * 71 | * @return descriptive string of text (not null) 72 | */ 73 | public String describe() { 74 | String result; 75 | switch (this) { 76 | case CUSTOM: 77 | result = "custom"; 78 | break; 79 | case FULL: 80 | result = "full"; 81 | break; 82 | case WANING_CRESCENT: 83 | result = "waning-crescent"; 84 | break; 85 | case WANING_GIBBOUS: 86 | result = "waning-gibbous"; 87 | break; 88 | case WAXING_CRESCENT: 89 | result = "waxing-crescent"; 90 | break; 91 | case WAXING_GIBBOUS: 92 | result = "waxing-gibbous"; 93 | break; 94 | default: 95 | result = String.format("ordinal=%d", ordinal()); 96 | } 97 | return result; 98 | } 99 | 100 | /** 101 | * Find a phase based on its textual description. 102 | * 103 | * @param description returned by describe() (not null, not empty) 104 | * @return phase, or null if the description does not match any value 105 | */ 106 | public static LunarPhase fromDescription(String description) { 107 | Validate.nonEmpty(description, "description"); 108 | 109 | for (LunarPhase phase : values()) { 110 | String d = phase.describe(); 111 | if (d.equals(description)) { 112 | return phase; 113 | } 114 | } 115 | 116 | return null; 117 | } 118 | 119 | /** 120 | * Look up the asset path to the color map for this phase. 121 | * 122 | * @param suffix folder name suffix ("" → default) 123 | * @return asset path (not null) 124 | */ 125 | public String imagePath(String suffix) { 126 | if (this == CUSTOM) { 127 | throw new IllegalStateException("custom phase has no color map"); 128 | } 129 | String description = describe(); 130 | String assetPath = String.format( 131 | "Textures/skies/moon%s/%s.png", suffix, description); 132 | 133 | return assetPath; 134 | } 135 | 136 | /** 137 | * Look up the celestial longitude difference for this phase. 138 | * 139 | * @return radians east of the sun (<2*Pi. ≥0) 140 | */ 141 | public float longitudeDifference() { 142 | switch (this) { 143 | case FULL: 144 | return FastMath.PI; 145 | case WANING_CRESCENT: 146 | return 1.65f * FastMath.PI; 147 | case WANING_GIBBOUS: 148 | return 1.25f * FastMath.PI; 149 | case WAXING_CRESCENT: 150 | return 0.35f * FastMath.PI; 151 | case WAXING_GIBBOUS: 152 | return 0.75f * FastMath.PI; 153 | default: 154 | throw new IllegalStateException(describe()); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /SkyLibrary/src/main/java/jme3utilities/sky/StarsOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018, 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; 27 | 28 | /** 29 | * Enumerate the options for rendering stars in SkyControl. 30 | * 31 | * @author Stephen Gold sgold@sonic.net 32 | */ 33 | public enum StarsOption { 34 | /** 35 | * Render stars on a cube. If realistic star motion is required, this is the 36 | * most efficient option, requiring only 12 additional triangles. 37 | */ 38 | Cube, 39 | /** 40 | * Render stars on the top dome. This uses the fewest triangles, but star 41 | * motion will be disabled. A fine option for daytime use. 42 | */ 43 | TopDome, 44 | /** 45 | * Render stars on 2 separate domes, one for the northern hemisphere and one 46 | * for the southern hemisphere. Use this option when combining star motion 47 | * with an edge filter. 48 | */ 49 | TwoDomes 50 | } 51 | -------------------------------------------------------------------------------- /SkyLibrary/src/main/java/jme3utilities/sky/WaterProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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; 27 | 28 | import com.jme3.asset.AssetManager; 29 | import com.jme3.renderer.RenderManager; 30 | import com.jme3.renderer.ViewPort; 31 | import com.jme3.water.SimpleWaterProcessor; 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | import java.util.logging.Logger; 35 | import jme3utilities.Validate; 36 | import jme3utilities.ViewPortListener; 37 | 38 | /** 39 | * Simple water processor, extended to interact with viewport listeners. 40 | * 41 | * @author Stephen Gold sgold@sonic.net 42 | */ 43 | public class WaterProcessor extends SimpleWaterProcessor { 44 | // ************************************************************************* 45 | // constants and loggers 46 | 47 | /** 48 | * message logger for this class 49 | */ 50 | final private static Logger logger 51 | = Logger.getLogger(WaterProcessor.class.getName()); 52 | // ************************************************************************* 53 | // fields 54 | 55 | /** 56 | * viewport listeners registered prior to initialization 57 | */ 58 | final private List listeners = new ArrayList<>(3); 59 | // ************************************************************************* 60 | // constructors 61 | 62 | /** 63 | * Instantiate a processor. 64 | * 65 | * @param manager asset manager (not null) 66 | */ 67 | public WaterProcessor(AssetManager manager) { 68 | super(manager); 69 | } 70 | // ************************************************************************* 71 | // new methods exposed 72 | 73 | /** 74 | * Add a viewport listener to this processor. 75 | * 76 | * @param listener (not null) 77 | */ 78 | public void addListener(ViewPortListener listener) { 79 | Validate.nonNull(listener, "listener"); 80 | 81 | if (isInitialized()) { 82 | // Inform the listener about the already-created viewports. 83 | listener.addViewPort(reflectionView); 84 | listener.addViewPort(refractionView); 85 | } else { 86 | /* 87 | * The viewports haven't been created yet, so queue up the listener 88 | * to be notified after they're created. 89 | */ 90 | listeners.add(listener); 91 | } 92 | } 93 | // ************************************************************************* 94 | // SimpleWaterProcessor methods 95 | 96 | /** 97 | * Initialize this processor prior to its first update. 98 | * 99 | * @param renderManager (not null) 100 | * @param viewPort (not null) 101 | */ 102 | @Override 103 | public void initialize(RenderManager renderManager, ViewPort viewPort) { 104 | super.initialize(renderManager, viewPort); 105 | 106 | // Inform registered listeners about two new viewports. 107 | for (ViewPortListener listener : listeners) { 108 | listener.addViewPort(reflectionView); 109 | listener.addViewPort(refractionView); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /SkyLibrary/src/main/java/jme3utilities/sky/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, 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 | /** 27 | * Reusable classes for simulating skies, including SkyControl. 28 | */ 29 | package jme3utilities.sky; -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome02/dome02.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes zero 27 | // objects and two cloud layers. 28 | 29 | MaterialDef dome02 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Clouds0Color 38 | Color Clouds0Glow 39 | Float Clouds0Scale : 1.0 40 | Texture2D Clouds0AlphaMap 41 | Vector2 Clouds0Offset 42 | 43 | Color Clouds1Color 44 | Color Clouds1Glow 45 | Float Clouds1Scale : 1.0 46 | Texture2D Clouds1AlphaMap 47 | Vector2 Clouds1Offset 48 | 49 | Color HazeColor 50 | Color HazeGlow 51 | Texture2D HazeAlphaMap 52 | } 53 | 54 | Technique { 55 | Defines { 56 | HAS_STARS : StarsColorMap 57 | HAS_CLOUDS0 : Clouds0AlphaMap 58 | HAS_CLOUDS1 : Clouds1AlphaMap 59 | HAS_HAZE : HazeAlphaMap 60 | } 61 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome02/dome02.frag 62 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome02/dome02.vert 63 | WorldParameters { 64 | WorldViewProjectionMatrix 65 | } 66 | } 67 | 68 | Technique Glow { 69 | Defines { 70 | HAS_CLOUDS0 : Clouds0AlphaMap 71 | HAS_CLOUDS1 : Clouds1AlphaMap 72 | HAS_HAZE : HazeAlphaMap 73 | } 74 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome02/dome02glow.frag 75 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome02/dome02.vert 76 | WorldParameters { 77 | WorldViewProjectionMatrix 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome06/dome06.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes zero 27 | // objects and six cloud layers. 28 | 29 | MaterialDef dome06 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Clouds0Color 38 | Color Clouds0Glow 39 | Float Clouds0Scale : 1.0 40 | Texture2D Clouds0AlphaMap 41 | Vector2 Clouds0Offset 42 | 43 | Color Clouds1Color 44 | Color Clouds1Glow 45 | Float Clouds1Scale : 1.0 46 | Texture2D Clouds1AlphaMap 47 | Vector2 Clouds1Offset 48 | 49 | Color Clouds2Color 50 | Color Clouds2Glow 51 | Float Clouds2Scale : 1.0 52 | Texture2D Clouds2AlphaMap 53 | Vector2 Clouds2Offset 54 | 55 | Color Clouds3Color 56 | Color Clouds3Glow 57 | Float Clouds3Scale : 1.0 58 | Texture2D Clouds3AlphaMap 59 | Vector2 Clouds3Offset 60 | 61 | Color Clouds4Color 62 | Color Clouds4Glow 63 | Float Clouds4Scale : 1.0 64 | Texture2D Clouds4AlphaMap 65 | Vector2 Clouds4Offset 66 | 67 | Color Clouds5Color 68 | Color Clouds5Glow 69 | Float Clouds5Scale : 1.0 70 | Texture2D Clouds5AlphaMap 71 | Vector2 Clouds5Offset 72 | 73 | Color HazeColor 74 | Color HazeGlow 75 | Texture2D HazeAlphaMap 76 | } 77 | 78 | Technique { 79 | Defines { 80 | HAS_STARS : StarsColorMap 81 | HAS_CLOUDS0 : Clouds0AlphaMap 82 | HAS_CLOUDS1 : Clouds1AlphaMap 83 | HAS_CLOUDS2 : Clouds2AlphaMap 84 | HAS_CLOUDS3 : Clouds3AlphaMap 85 | HAS_CLOUDS4 : Clouds4AlphaMap 86 | HAS_CLOUDS5 : Clouds5AlphaMap 87 | HAS_HAZE : HazeAlphaMap 88 | } 89 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome06/dome06.frag 90 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome06/dome06.vert 91 | WorldParameters { 92 | WorldViewProjectionMatrix 93 | } 94 | } 95 | 96 | Technique Glow { 97 | Defines { 98 | HAS_CLOUDS0 : Clouds0AlphaMap 99 | HAS_CLOUDS1 : Clouds1AlphaMap 100 | HAS_CLOUDS2 : Clouds2AlphaMap 101 | HAS_CLOUDS3 : Clouds3AlphaMap 102 | HAS_CLOUDS4 : Clouds4AlphaMap 103 | HAS_CLOUDS5 : Clouds5AlphaMap 104 | HAS_HAZE : HazeAlphaMap 105 | } 106 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome06/dome06glow.frag 107 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome06/dome06.vert 108 | WorldParameters { 109 | WorldViewProjectionMatrix 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome20/dome20.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes two 27 | // objects and zero cloud layers. 28 | 29 | MaterialDef dome20 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Object0Color 38 | Color Object0Glow 39 | Texture2D Object0ColorMap 40 | Vector2 Object0Center 41 | Vector2 Object0TransformU 42 | Vector2 Object0TransformV 43 | 44 | Color Object1Color 45 | Color Object1Glow 46 | Texture2D Object1ColorMap 47 | Vector2 Object1Center 48 | Vector2 Object1TransformU 49 | Vector2 Object1TransformV 50 | 51 | Color HazeColor 52 | Color HazeGlow 53 | Texture2D HazeAlphaMap 54 | } 55 | 56 | Technique { 57 | Defines { 58 | HAS_STARS : StarsColorMap 59 | HAS_OBJECT0 : Object0ColorMap 60 | HAS_OBJECT1 : Object1ColorMap 61 | HAS_HAZE : HazeAlphaMap 62 | } 63 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome20/dome20.frag 64 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome20/dome20.vert 65 | WorldParameters { 66 | WorldViewProjectionMatrix 67 | } 68 | } 69 | 70 | Technique Glow { 71 | Defines { 72 | HAS_OBJECT0 : Object0ColorMap 73 | HAS_OBJECT1 : Object1ColorMap 74 | HAS_HAZE : HazeAlphaMap 75 | } 76 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome20/dome20glow.frag 77 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome20/dome20.vert 78 | WorldParameters { 79 | WorldViewProjectionMatrix 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome22/dome22.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes two 27 | // objects and two cloud layers. 28 | 29 | MaterialDef dome22 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Object0Color 38 | Color Object0Glow 39 | Texture2D Object0ColorMap 40 | Vector2 Object0Center 41 | Vector2 Object0TransformU 42 | Vector2 Object0TransformV 43 | 44 | Color Object1Color 45 | Color Object1Glow 46 | Texture2D Object1ColorMap 47 | Vector2 Object1Center 48 | Vector2 Object1TransformU 49 | Vector2 Object1TransformV 50 | 51 | Color Clouds0Color 52 | Color Clouds0Glow 53 | Float Clouds0Scale : 1.0 54 | Texture2D Clouds0AlphaMap 55 | Vector2 Clouds0Offset 56 | 57 | Color Clouds1Color 58 | Color Clouds1Glow 59 | Float Clouds1Scale : 1.0 60 | Texture2D Clouds1AlphaMap 61 | Vector2 Clouds1Offset 62 | 63 | Color HazeColor 64 | Color HazeGlow 65 | Texture2D HazeAlphaMap 66 | } 67 | 68 | Technique { 69 | Defines { 70 | HAS_STARS : StarsColorMap 71 | HAS_OBJECT0 : Object0ColorMap 72 | HAS_OBJECT1 : Object1ColorMap 73 | HAS_CLOUDS0 : Clouds0AlphaMap 74 | HAS_CLOUDS1 : Clouds1AlphaMap 75 | HAS_HAZE : HazeAlphaMap 76 | } 77 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome22/dome22.frag 78 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome22/dome22.vert 79 | WorldParameters { 80 | WorldViewProjectionMatrix 81 | } 82 | } 83 | 84 | Technique Glow { 85 | Defines { 86 | HAS_OBJECT0 : Object0ColorMap 87 | HAS_OBJECT1 : Object1ColorMap 88 | HAS_CLOUDS0 : Clouds0AlphaMap 89 | HAS_CLOUDS1 : Clouds1AlphaMap 90 | HAS_HAZE : HazeAlphaMap 91 | } 92 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome22/dome22glow.frag 93 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome22/dome22.vert 94 | WorldParameters { 95 | WorldViewProjectionMatrix 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome60/dome60.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes six 27 | // objects and zero cloud layers. 28 | 29 | MaterialDef dome60 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Object0Color 38 | Color Object0Glow 39 | Texture2D Object0ColorMap 40 | Vector2 Object0Center 41 | Vector2 Object0TransformU 42 | Vector2 Object0TransformV 43 | 44 | Color Object1Color 45 | Color Object1Glow 46 | Texture2D Object1ColorMap 47 | Vector2 Object1Center 48 | Vector2 Object1TransformU 49 | Vector2 Object1TransformV 50 | 51 | Color Object2Color 52 | Color Object2Glow 53 | Texture2D Object2ColorMap 54 | Vector2 Object2Center 55 | Vector2 Object2TransformU 56 | Vector2 Object2TransformV 57 | 58 | Color Object3Color 59 | Color Object3Glow 60 | Texture2D Object3ColorMap 61 | Vector2 Object3Center 62 | Vector2 Object3TransformU 63 | Vector2 Object3TransformV 64 | 65 | Color Object4Color 66 | Color Object4Glow 67 | Texture2D Object4ColorMap 68 | Vector2 Object4Center 69 | Vector2 Object4TransformU 70 | Vector2 Object4TransformV 71 | 72 | Color Object5Color 73 | Color Object5Glow 74 | Texture2D Object5ColorMap 75 | Vector2 Object5Center 76 | Vector2 Object5TransformU 77 | Vector2 Object5TransformV 78 | 79 | Color HazeColor 80 | Color HazeGlow 81 | Texture2D HazeAlphaMap 82 | } 83 | 84 | Technique { 85 | Defines { 86 | HAS_STARS : StarsColorMap 87 | HAS_OBJECT0 : Object0ColorMap 88 | HAS_OBJECT1 : Object1ColorMap 89 | HAS_OBJECT2 : Object2ColorMap 90 | HAS_OBJECT3 : Object3ColorMap 91 | HAS_OBJECT4 : Object4ColorMap 92 | HAS_OBJECT5 : Object5ColorMap 93 | HAS_HAZE : HazeAlphaMap 94 | } 95 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome60/dome60.frag 96 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome60/dome60.vert 97 | WorldParameters { 98 | WorldViewProjectionMatrix 99 | } 100 | } 101 | 102 | Technique Glow { 103 | Defines { 104 | HAS_OBJECT0 : Object0ColorMap 105 | HAS_OBJECT1 : Object1ColorMap 106 | HAS_OBJECT2 : Object2ColorMap 107 | HAS_OBJECT3 : Object3ColorMap 108 | HAS_OBJECT4 : Object4ColorMap 109 | HAS_OBJECT5 : Object5ColorMap 110 | HAS_HAZE : HazeAlphaMap 111 | } 112 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome60/dome60glow.frag 113 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome60/dome60.vert 114 | WorldParameters { 115 | WorldViewProjectionMatrix 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/MatDefs/skies/dome66/dome66.j3md: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014-2022, Stephen Gold 2 | 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are met: 5 | // * Redistributions of source code must retain the above copyright 6 | // notice, this list of conditions and the following disclaimer. 7 | // * Redistributions in binary form must reproduce the above copyright 8 | // notice, this list of conditions and the following disclaimer in the 9 | // documentation and/or other materials provided with the distribution. 10 | // * Neither the name of the copyright holder nor the names of its 11 | // contributors may be used to endorse or promote products derived from 12 | // this software without specific prior written permission. 13 | 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | // POSSIBILITY OF SUCH DAMAGE. 25 | 26 | // A material for use with the SkyMaterial class: this version includes six 27 | // objects and six cloud layers. 28 | 29 | MaterialDef dome66 { 30 | MaterialParameters { 31 | Color ClearColor 32 | Color ClearGlow 33 | Vector2 TopCoord 34 | 35 | Texture2D StarsColorMap 36 | 37 | Color Object0Color 38 | Color Object0Glow 39 | Texture2D Object0ColorMap 40 | Vector2 Object0Center 41 | Vector2 Object0TransformU 42 | Vector2 Object0TransformV 43 | 44 | Color Object1Color 45 | Color Object1Glow 46 | Texture2D Object1ColorMap 47 | Vector2 Object1Center 48 | Vector2 Object1TransformU 49 | Vector2 Object1TransformV 50 | 51 | Color Object2Color 52 | Color Object2Glow 53 | Texture2D Object2ColorMap 54 | Vector2 Object2Center 55 | Vector2 Object2TransformU 56 | Vector2 Object2TransformV 57 | 58 | Color Object3Color 59 | Color Object3Glow 60 | Texture2D Object3ColorMap 61 | Vector2 Object3Center 62 | Vector2 Object3TransformU 63 | Vector2 Object3TransformV 64 | 65 | Color Object4Color 66 | Color Object4Glow 67 | Texture2D Object4ColorMap 68 | Vector2 Object4Center 69 | Vector2 Object4TransformU 70 | Vector2 Object4TransformV 71 | 72 | Color Object5Color 73 | Color Object5Glow 74 | Texture2D Object5ColorMap 75 | Vector2 Object5Center 76 | Vector2 Object5TransformU 77 | Vector2 Object5TransformV 78 | 79 | Color Clouds0Color 80 | Color Clouds0Glow 81 | Float Clouds0Scale : 1.0 82 | Texture2D Clouds0AlphaMap 83 | Vector2 Clouds0Offset 84 | 85 | Color Clouds1Color 86 | Color Clouds1Glow 87 | Float Clouds1Scale : 1.0 88 | Texture2D Clouds1AlphaMap 89 | Vector2 Clouds1Offset 90 | 91 | Color Clouds2Color 92 | Color Clouds2Glow 93 | Float Clouds2Scale : 1.0 94 | Texture2D Clouds2AlphaMap 95 | Vector2 Clouds2Offset 96 | 97 | Color Clouds3Color 98 | Color Clouds3Glow 99 | Float Clouds3Scale : 1.0 100 | Texture2D Clouds3AlphaMap 101 | Vector2 Clouds3Offset 102 | 103 | Color Clouds4Color 104 | Color Clouds4Glow 105 | Float Clouds4Scale : 1.0 106 | Texture2D Clouds4AlphaMap 107 | Vector2 Clouds4Offset 108 | 109 | Color Clouds5Color 110 | Color Clouds5Glow 111 | Float Clouds5Scale : 1.0 112 | Texture2D Clouds5AlphaMap 113 | Vector2 Clouds5Offset 114 | 115 | Color HazeColor 116 | Color HazeGlow 117 | Texture2D HazeAlphaMap 118 | } 119 | 120 | Technique { 121 | Defines { 122 | HAS_STARS : StarsColorMap 123 | HAS_OBJECT0 : Object0ColorMap 124 | HAS_OBJECT1 : Object1ColorMap 125 | HAS_OBJECT2 : Object2ColorMap 126 | HAS_OBJECT3 : Object3ColorMap 127 | HAS_OBJECT4 : Object4ColorMap 128 | HAS_OBJECT5 : Object5ColorMap 129 | HAS_CLOUDS0 : Clouds0AlphaMap 130 | HAS_CLOUDS1 : Clouds1AlphaMap 131 | HAS_CLOUDS2 : Clouds2AlphaMap 132 | HAS_CLOUDS3 : Clouds3AlphaMap 133 | HAS_CLOUDS4 : Clouds4AlphaMap 134 | HAS_CLOUDS5 : Clouds5AlphaMap 135 | HAS_HAZE : HazeAlphaMap 136 | } 137 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome66/dome66.frag 138 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome66/dome66.vert 139 | WorldParameters { 140 | WorldViewProjectionMatrix 141 | } 142 | } 143 | 144 | Technique Glow { 145 | Defines { 146 | HAS_OBJECT0 : Object0ColorMap 147 | HAS_OBJECT1 : Object1ColorMap 148 | HAS_OBJECT2 : Object2ColorMap 149 | HAS_OBJECT3 : Object3ColorMap 150 | HAS_OBJECT4 : Object4ColorMap 151 | HAS_OBJECT5 : Object5ColorMap 152 | HAS_CLOUDS0 : Clouds0AlphaMap 153 | HAS_CLOUDS1 : Clouds1AlphaMap 154 | HAS_CLOUDS2 : Clouds2AlphaMap 155 | HAS_CLOUDS3 : Clouds3AlphaMap 156 | HAS_CLOUDS4 : Clouds4AlphaMap 157 | HAS_CLOUDS5 : Clouds5AlphaMap 158 | HAS_HAZE : HazeAlphaMap 159 | } 160 | FragmentShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome66/dome66glow.frag 161 | VertexShader GLSL300 GLSL150 GLSL100: Shaders/skies/dome66/dome66.vert 162 | WorldParameters { 163 | WorldViewProjectionMatrix 164 | } 165 | } 166 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome02/dome02.frag: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome02.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_HAZE 39 | uniform sampler2D m_HazeAlphaMap; 40 | uniform vec4 m_HazeColor; 41 | #endif 42 | 43 | #ifdef HAS_CLOUDS0 44 | uniform sampler2D m_Clouds0AlphaMap; 45 | uniform vec4 m_Clouds0Color; 46 | varying vec2 clouds0Coord; 47 | #endif 48 | 49 | #ifdef HAS_CLOUDS1 50 | uniform sampler2D m_Clouds1AlphaMap; 51 | uniform vec4 m_Clouds1Color; 52 | varying vec2 clouds1Coord; 53 | #endif 54 | 55 | vec4 mixColors(vec4 color0, vec4 color1) { 56 | vec4 result; 57 | float a0 = color0.a * (1.0 - color1.a); 58 | result.a = a0 + color1.a; 59 | if (result.a > 0.0) { 60 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 61 | } else { 62 | result.rgb = vec3(0.0); 63 | } 64 | return result; 65 | } 66 | 67 | void main() { 68 | #ifdef HAS_STARS 69 | vec4 stars = texture2D(m_StarsColorMap, skyTexCoord); 70 | #else 71 | vec4 stars = vec4(0.0); 72 | #endif 73 | vec4 color = stars; 74 | 75 | vec4 clear = m_ClearColor; 76 | #ifdef HAS_HAZE 77 | vec4 haze = m_HazeColor; 78 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 79 | clear = mixColors(clear, haze); 80 | #endif 81 | color = mixColors(color, clear); 82 | 83 | #ifdef HAS_CLOUDS0 84 | vec4 clouds0 = m_Clouds0Color; 85 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 86 | color = mixColors(color, clouds0); 87 | #endif 88 | 89 | #ifdef HAS_CLOUDS1 90 | vec4 clouds1 = m_Clouds1Color; 91 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 92 | color = mixColors(color, clouds1); 93 | #endif 94 | 95 | gl_FragColor = color; 96 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome02/dome02.vert: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome02.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_CLOUDS0 38 | uniform float m_Clouds0Scale; 39 | uniform vec2 m_Clouds0Offset; 40 | varying vec2 clouds0Coord; 41 | #endif 42 | 43 | #ifdef HAS_CLOUDS1 44 | uniform float m_Clouds1Scale; 45 | uniform vec2 m_Clouds1Offset; 46 | varying vec2 clouds1Coord; 47 | #endif 48 | 49 | void main(){ 50 | skyTexCoord = inTexCoord; 51 | /* 52 | * The following cloud texture coordinate calculations must be kept 53 | * consistent with those in SkyMaterial.getTransparency(int,Vector2f) . 54 | */ 55 | #ifdef HAS_CLOUDS0 56 | clouds0Coord = inTexCoord * m_Clouds0Scale + m_Clouds0Offset; 57 | #endif 58 | #ifdef HAS_CLOUDS1 59 | clouds1Coord = inTexCoord * m_Clouds1Scale + m_Clouds1Offset; 60 | #endif 61 | 62 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1); 63 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome02/dome02glow.frag: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome02.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_HAZE 35 | uniform sampler2D m_HazeAlphaMap; 36 | uniform vec4 m_HazeGlow; 37 | #endif 38 | 39 | #ifdef HAS_CLOUDS0 40 | uniform sampler2D m_Clouds0AlphaMap; 41 | uniform vec4 m_Clouds0Glow; 42 | varying vec2 clouds0Coord; 43 | #endif 44 | 45 | #ifdef HAS_CLOUDS1 46 | uniform sampler2D m_Clouds1AlphaMap; 47 | uniform vec4 m_Clouds1Glow; 48 | varying vec2 clouds1Coord; 49 | #endif 50 | 51 | #ifdef HAS_CLOUDS2 52 | uniform sampler2D m_Clouds2AlphaMap; 53 | uniform vec4 m_Clouds2Glow; 54 | varying vec2 clouds2Coord; 55 | #endif 56 | 57 | vec4 mixColors(vec4 color0, vec4 color1) { 58 | vec4 result; 59 | float a0 = color0.a * (1.0 - color1.a); 60 | result.a = a0 + color1.a; 61 | if (result.a > 0.0) { 62 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 63 | } else { 64 | result.rgb = vec3(0.0); 65 | } 66 | return result; 67 | } 68 | 69 | void main() { 70 | vec4 color = vec4(0.0); 71 | 72 | vec4 clear = m_ClearGlow; 73 | #ifdef HAS_HAZE 74 | vec4 haze = m_HazeGlow; 75 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 76 | clear = mixColors(clear, haze); 77 | #endif 78 | color = mixColors(color, clear); 79 | 80 | #ifdef HAS_CLOUDS0 81 | vec4 clouds0 = m_Clouds0Glow; 82 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 83 | color = mixColors(color, clouds0); 84 | #endif 85 | 86 | #ifdef HAS_CLOUDS1 87 | vec4 clouds1 = m_Clouds1Glow; 88 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 89 | color = mixColors(color, clouds1); 90 | #endif 91 | 92 | gl_FragColor = color; 93 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome06/dome06.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 dome06.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_HAZE 39 | uniform sampler2D m_HazeAlphaMap; 40 | uniform vec4 m_HazeColor; 41 | #endif 42 | 43 | #ifdef HAS_CLOUDS0 44 | uniform sampler2D m_Clouds0AlphaMap; 45 | uniform vec4 m_Clouds0Color; 46 | varying vec2 clouds0Coord; 47 | #endif 48 | 49 | #ifdef HAS_CLOUDS1 50 | uniform sampler2D m_Clouds1AlphaMap; 51 | uniform vec4 m_Clouds1Color; 52 | varying vec2 clouds1Coord; 53 | #endif 54 | 55 | #ifdef HAS_CLOUDS2 56 | uniform sampler2D m_Clouds2AlphaMap; 57 | uniform vec4 m_Clouds2Color; 58 | varying vec2 clouds2Coord; 59 | #endif 60 | 61 | #ifdef HAS_CLOUDS3 62 | uniform sampler2D m_Clouds3AlphaMap; 63 | uniform vec4 m_Clouds3Color; 64 | varying vec2 clouds3Coord; 65 | #endif 66 | 67 | #ifdef HAS_CLOUDS4 68 | uniform sampler2D m_Clouds4AlphaMap; 69 | uniform vec4 m_Clouds4Color; 70 | varying vec2 clouds4Coord; 71 | #endif 72 | 73 | #ifdef HAS_CLOUDS5 74 | uniform sampler2D m_Clouds5AlphaMap; 75 | uniform vec4 m_Clouds5Color; 76 | varying vec2 clouds5Coord; 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 | vec4 color = stars; 98 | 99 | vec4 clear = m_ClearColor; 100 | #ifdef HAS_HAZE 101 | vec4 haze = m_HazeColor; 102 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 103 | clear = mixColors(clear, haze); 104 | #endif 105 | color = mixColors(color, clear); 106 | 107 | #ifdef HAS_CLOUDS0 108 | vec4 clouds0 = m_Clouds0Color; 109 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 110 | color = mixColors(color, clouds0); 111 | #endif 112 | 113 | #ifdef HAS_CLOUDS1 114 | vec4 clouds1 = m_Clouds1Color; 115 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 116 | color = mixColors(color, clouds1); 117 | #endif 118 | 119 | #ifdef HAS_CLOUDS2 120 | vec4 clouds2 = m_Clouds2Color; 121 | clouds2.a *= texture2D(m_Clouds2AlphaMap, clouds2Coord).r; 122 | color = mixColors(color, clouds2); 123 | #endif 124 | 125 | #ifdef HAS_CLOUDS3 126 | vec4 clouds3 = m_Clouds3Color; 127 | clouds3.a *= texture2D(m_Clouds3AlphaMap, clouds3Coord).r; 128 | color = mixColors(color, clouds3); 129 | #endif 130 | 131 | #ifdef HAS_CLOUDS4 132 | vec4 clouds4 = m_Clouds4Color; 133 | clouds4.a *= texture2D(m_Clouds4AlphaMap, clouds4Coord).r; 134 | color = mixColors(color, clouds4); 135 | #endif 136 | 137 | #ifdef HAS_CLOUDS5 138 | vec4 clouds5 = m_Clouds5Color; 139 | clouds5.a *= texture2D(m_Clouds5AlphaMap, clouds5Coord).r; 140 | color = mixColors(color, clouds5); 141 | #endif 142 | 143 | gl_FragColor = color; 144 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome06/dome06.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 dome06.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_CLOUDS0 38 | uniform float m_Clouds0Scale; 39 | uniform vec2 m_Clouds0Offset; 40 | varying vec2 clouds0Coord; 41 | #endif 42 | 43 | #ifdef HAS_CLOUDS1 44 | uniform float m_Clouds1Scale; 45 | uniform vec2 m_Clouds1Offset; 46 | varying vec2 clouds1Coord; 47 | #endif 48 | 49 | #ifdef HAS_CLOUDS2 50 | uniform float m_Clouds2Scale; 51 | uniform vec2 m_Clouds2Offset; 52 | varying vec2 clouds2Coord; 53 | #endif 54 | 55 | #ifdef HAS_CLOUDS3 56 | uniform float m_Clouds3Scale; 57 | uniform vec2 m_Clouds3Offset; 58 | varying vec2 clouds3Coord; 59 | #endif 60 | 61 | #ifdef HAS_CLOUDS4 62 | uniform float m_Clouds4Scale; 63 | uniform vec2 m_Clouds4Offset; 64 | varying vec2 clouds4Coord; 65 | #endif 66 | 67 | #ifdef HAS_CLOUDS5 68 | uniform float m_Clouds5Scale; 69 | uniform vec2 m_Clouds5Offset; 70 | varying vec2 clouds5Coord; 71 | #endif 72 | 73 | void main(){ 74 | skyTexCoord = inTexCoord; 75 | /* 76 | * The following cloud texture coordinate calculations must be kept 77 | * consistent with those in SkyMaterial.getTransparency(int,Vector2f) . 78 | */ 79 | #ifdef HAS_CLOUDS0 80 | clouds0Coord = inTexCoord * m_Clouds0Scale + m_Clouds0Offset; 81 | #endif 82 | #ifdef HAS_CLOUDS1 83 | clouds1Coord = inTexCoord * m_Clouds1Scale + m_Clouds1Offset; 84 | #endif 85 | #ifdef HAS_CLOUDS2 86 | clouds2Coord = inTexCoord * m_Clouds2Scale + m_Clouds2Offset; 87 | #endif 88 | #ifdef HAS_CLOUDS3 89 | clouds3Coord = inTexCoord * m_Clouds3Scale + m_Clouds3Offset; 90 | #endif 91 | #ifdef HAS_CLOUDS4 92 | clouds4Coord = inTexCoord * m_Clouds4Scale + m_Clouds4Offset; 93 | #endif 94 | #ifdef HAS_CLOUDS5 95 | clouds5Coord = inTexCoord * m_Clouds5Scale + m_Clouds5Offset; 96 | #endif 97 | 98 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1); 99 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome06/dome06glow.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 dome06.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_HAZE 35 | uniform sampler2D m_HazeAlphaMap; 36 | uniform vec4 m_HazeGlow; 37 | #endif 38 | 39 | #ifdef HAS_CLOUDS0 40 | uniform sampler2D m_Clouds0AlphaMap; 41 | uniform vec4 m_Clouds0Glow; 42 | varying vec2 clouds0Coord; 43 | #endif 44 | 45 | #ifdef HAS_CLOUDS1 46 | uniform sampler2D m_Clouds1AlphaMap; 47 | uniform vec4 m_Clouds1Glow; 48 | varying vec2 clouds1Coord; 49 | #endif 50 | 51 | #ifdef HAS_CLOUDS2 52 | uniform sampler2D m_Clouds2AlphaMap; 53 | uniform vec4 m_Clouds2Glow; 54 | varying vec2 clouds2Coord; 55 | #endif 56 | 57 | #ifdef HAS_CLOUDS3 58 | uniform sampler2D m_Clouds3AlphaMap; 59 | uniform vec4 m_Clouds3Glow; 60 | varying vec2 clouds3Coord; 61 | #endif 62 | 63 | #ifdef HAS_CLOUDS4 64 | uniform sampler2D m_Clouds4AlphaMap; 65 | uniform vec4 m_Clouds4Glow; 66 | varying vec2 clouds4Coord; 67 | #endif 68 | 69 | #ifdef HAS_CLOUDS5 70 | uniform sampler2D m_Clouds5AlphaMap; 71 | uniform vec4 m_Clouds5Glow; 72 | varying vec2 clouds5Coord; 73 | #endif 74 | 75 | vec4 mixColors(vec4 color0, vec4 color1) { 76 | vec4 result; 77 | float a0 = color0.a * (1.0 - color1.a); 78 | result.a = a0 + color1.a; 79 | if (result.a > 0.0) { 80 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 81 | } else { 82 | result.rgb = vec3(0.0); 83 | } 84 | return result; 85 | } 86 | 87 | void main() { 88 | vec4 color = vec4(0.0); 89 | 90 | vec4 clear = m_ClearGlow; 91 | #ifdef HAS_HAZE 92 | vec4 haze = m_HazeGlow; 93 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 94 | clear = mixColors(clear, haze); 95 | #endif 96 | color = mixColors(color, clear); 97 | 98 | #ifdef HAS_CLOUDS0 99 | vec4 clouds0 = m_Clouds0Glow; 100 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 101 | color = mixColors(color, clouds0); 102 | #endif 103 | 104 | #ifdef HAS_CLOUDS1 105 | vec4 clouds1 = m_Clouds1Glow; 106 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 107 | color = mixColors(color, clouds1); 108 | #endif 109 | 110 | #ifdef HAS_CLOUDS2 111 | vec4 clouds2 = m_Clouds2Glow; 112 | clouds2.a *= texture2D(m_Clouds2AlphaMap, clouds2Coord).r; 113 | color = mixColors(color, clouds2); 114 | #endif 115 | 116 | #ifdef HAS_CLOUDS3 117 | vec4 clouds3 = m_Clouds3Glow; 118 | clouds3.a *= texture2D(m_Clouds3AlphaMap, clouds3Coord).r; 119 | color = mixColors(color, clouds3); 120 | #endif 121 | 122 | #ifdef HAS_CLOUDS4 123 | vec4 clouds4 = m_Clouds4Glow; 124 | clouds4.a *= texture2D(m_Clouds4AlphaMap, clouds4Coord).r; 125 | color = mixColors(color, clouds4); 126 | #endif 127 | 128 | #ifdef HAS_CLOUDS5 129 | vec4 clouds5 = m_Clouds5Glow; 130 | clouds5.a *= texture2D(m_Clouds5AlphaMap, clouds5Coord).r; 131 | color = mixColors(color, clouds5); 132 | #endif 133 | 134 | gl_FragColor = color; 135 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome20/dome20.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 dome20.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_HAZE 51 | uniform sampler2D m_HazeAlphaMap; 52 | uniform vec4 m_HazeColor; 53 | #endif 54 | 55 | vec4 mixColors(vec4 color0, vec4 color1) { 56 | vec4 result; 57 | float a0 = color0.a * (1.0 - color1.a); 58 | result.a = a0 + color1.a; 59 | if (result.a > 0.0) { 60 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 61 | } else { 62 | result.rgb = vec3(0.0); 63 | } 64 | return result; 65 | } 66 | 67 | void main() { 68 | #ifdef HAS_STARS 69 | vec4 stars = texture2D(m_StarsColorMap, skyTexCoord); 70 | #else 71 | vec4 stars = vec4(0.0); 72 | #endif 73 | 74 | vec4 objects = vec4(0.0); 75 | 76 | #ifdef HAS_OBJECT0 77 | if (floor(object0Coord.s) == 0.0 && 78 | floor(object0Coord.t) == 0.0) { 79 | objects = m_Object0Color; 80 | objects *= texture2D(m_Object0ColorMap, object0Coord); 81 | } 82 | #endif 83 | 84 | #ifdef HAS_OBJECT1 85 | if (floor(object1Coord.s) == 0.0 && 86 | floor(object1Coord.t) == 0.0) { 87 | vec4 object1 = m_Object1Color; 88 | object1 *= texture2D(m_Object1ColorMap, object1Coord); 89 | objects = mixColors(objects, object1); 90 | } 91 | #endif 92 | 93 | vec4 color = mixColors(stars, objects); 94 | 95 | vec4 clear = m_ClearColor; 96 | #ifdef HAS_HAZE 97 | vec4 haze = m_HazeColor; 98 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 99 | clear = mixColors(clear, haze); 100 | #endif 101 | color = mixColors(color, clear); 102 | // Bright parts of objects shine through the clear areas. 103 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a; 104 | 105 | gl_FragColor = color; 106 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome20/dome20.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 dome20.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 | void main(){ 54 | skyTexCoord = inTexCoord; 55 | #ifdef HAS_OBJECT0 56 | object0Offset = inTexCoord - m_Object0Center; 57 | object0Coord.x = dot(m_Object0TransformU, object0Offset); 58 | object0Coord.y = dot(m_Object0TransformV, object0Offset); 59 | object0Coord += m_TopCoord; 60 | #endif 61 | #ifdef HAS_OBJECT1 62 | object1Offset = inTexCoord - m_Object1Center; 63 | object1Coord.x = dot(m_Object1TransformU, object1Offset); 64 | object1Coord.y = dot(m_Object1TransformV, object1Offset); 65 | object1Coord += m_TopCoord; 66 | #endif 67 | 68 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1); 69 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome20/dome20glow.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 dome20.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_HAZE 47 | uniform sampler2D m_HazeAlphaMap; 48 | uniform vec4 m_HazeGlow; 49 | #endif 50 | 51 | vec4 mixColors(vec4 color0, vec4 color1) { 52 | vec4 result; 53 | float a0 = color0.a * (1.0 - color1.a); 54 | result.a = a0 + color1.a; 55 | if (result.a > 0.0) { 56 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 57 | } else { 58 | result.rgb = vec3(0.0); 59 | } 60 | return result; 61 | } 62 | 63 | void main() { 64 | vec4 stars = vec4(0.0); 65 | 66 | vec4 objects = vec4(0.0); 67 | 68 | #ifdef HAS_OBJECT0 69 | if (floor(object0Coord.s) == 0.0 && 70 | floor(object0Coord.t) == 0.0) { 71 | objects = m_Object0Glow; 72 | objects *= texture2D(m_Object0ColorMap, object0Coord); 73 | } 74 | #endif 75 | 76 | #ifdef HAS_OBJECT1 77 | if (floor(object1Coord.s) == 0.0 && 78 | floor(object1Coord.t) == 0.0) { 79 | vec4 object1 = m_Object1Glow; 80 | object1 *= texture2D(m_Object1ColorMap, object1Coord); 81 | objects = mixColors(objects, object1); 82 | } 83 | #endif 84 | 85 | vec4 color = mixColors(stars, objects); 86 | 87 | vec4 clear = m_ClearGlow; 88 | #ifdef HAS_HAZE 89 | vec4 haze = m_HazeGlow; 90 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 91 | clear = mixColors(clear, haze); 92 | #endif 93 | color = mixColors(color, clear); 94 | // Bright parts of objects shine through the clear areas. 95 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a; 96 | 97 | gl_FragColor = color; 98 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome22/dome22.frag: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome22.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_HAZE 51 | uniform sampler2D m_HazeAlphaMap; 52 | uniform vec4 m_HazeColor; 53 | #endif 54 | 55 | #ifdef HAS_CLOUDS0 56 | uniform sampler2D m_Clouds0AlphaMap; 57 | uniform vec4 m_Clouds0Color; 58 | varying vec2 clouds0Coord; 59 | #endif 60 | 61 | #ifdef HAS_CLOUDS1 62 | uniform sampler2D m_Clouds1AlphaMap; 63 | uniform vec4 m_Clouds1Color; 64 | varying vec2 clouds1Coord; 65 | #endif 66 | 67 | vec4 mixColors(vec4 color0, vec4 color1) { 68 | vec4 result; 69 | float a0 = color0.a * (1.0 - color1.a); 70 | result.a = a0 + color1.a; 71 | if (result.a > 0.0) { 72 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 73 | } else { 74 | result.rgb = vec3(0.0); 75 | } 76 | return result; 77 | } 78 | 79 | void main() { 80 | #ifdef HAS_STARS 81 | vec4 stars = texture2D(m_StarsColorMap, skyTexCoord); 82 | #else 83 | vec4 stars = vec4(0.0); 84 | #endif 85 | 86 | vec4 objects = vec4(0.0); 87 | 88 | #ifdef HAS_OBJECT0 89 | if (floor(object0Coord.s) == 0.0 && 90 | floor(object0Coord.t) == 0.0) { 91 | objects = m_Object0Color; 92 | objects *= texture2D(m_Object0ColorMap, object0Coord); 93 | } 94 | #endif 95 | 96 | #ifdef HAS_OBJECT1 97 | if (floor(object1Coord.s) == 0.0 && 98 | floor(object1Coord.t) == 0.0) { 99 | vec4 object1 = m_Object1Color; 100 | object1 *= texture2D(m_Object1ColorMap, object1Coord); 101 | objects = mixColors(objects, object1); 102 | } 103 | #endif 104 | 105 | vec4 color = mixColors(stars, objects); 106 | 107 | vec4 clear = m_ClearColor; 108 | #ifdef HAS_HAZE 109 | vec4 haze = m_HazeColor; 110 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 111 | clear = mixColors(clear, haze); 112 | #endif 113 | color = mixColors(color, clear); 114 | // Bright parts of objects shine through the clear areas. 115 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a; 116 | 117 | #ifdef HAS_CLOUDS0 118 | vec4 clouds0 = m_Clouds0Color; 119 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 120 | color = mixColors(color, clouds0); 121 | #endif 122 | 123 | #ifdef HAS_CLOUDS1 124 | vec4 clouds1 = m_Clouds1Color; 125 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 126 | color = mixColors(color, clouds1); 127 | #endif 128 | 129 | gl_FragColor = color; 130 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome22/dome22.vert: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome22.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_CLOUDS0 54 | uniform float m_Clouds0Scale; 55 | uniform vec2 m_Clouds0Offset; 56 | varying vec2 clouds0Coord; 57 | #endif 58 | 59 | #ifdef HAS_CLOUDS1 60 | uniform float m_Clouds1Scale; 61 | uniform vec2 m_Clouds1Offset; 62 | varying vec2 clouds1Coord; 63 | #endif 64 | 65 | void main(){ 66 | skyTexCoord = inTexCoord; 67 | /* 68 | * The following cloud texture coordinate calculations must be kept 69 | * consistent with those in SkyMaterial.getTransparency(int,Vector2f) . 70 | */ 71 | #ifdef HAS_CLOUDS0 72 | clouds0Coord = inTexCoord * m_Clouds0Scale + m_Clouds0Offset; 73 | #endif 74 | #ifdef HAS_CLOUDS1 75 | clouds1Coord = inTexCoord * m_Clouds1Scale + m_Clouds1Offset; 76 | #endif 77 | 78 | #ifdef HAS_OBJECT0 79 | object0Offset = inTexCoord - m_Object0Center; 80 | object0Coord.x = dot(m_Object0TransformU, object0Offset); 81 | object0Coord.y = dot(m_Object0TransformV, object0Offset); 82 | object0Coord += m_TopCoord; 83 | #endif 84 | 85 | #ifdef HAS_OBJECT1 86 | object1Offset = inTexCoord - m_Object1Center; 87 | object1Coord.x = dot(m_Object1TransformU, object1Offset); 88 | object1Coord.y = dot(m_Object1TransformV, object1Offset); 89 | object1Coord += m_TopCoord; 90 | #endif 91 | 92 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1); 93 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome22/dome22glow.frag: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-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 dome22.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_HAZE 47 | uniform sampler2D m_HazeAlphaMap; 48 | uniform vec4 m_HazeGlow; 49 | #endif 50 | 51 | #ifdef HAS_CLOUDS0 52 | uniform sampler2D m_Clouds0AlphaMap; 53 | uniform vec4 m_Clouds0Glow; 54 | varying vec2 clouds0Coord; 55 | #endif 56 | 57 | #ifdef HAS_CLOUDS1 58 | uniform sampler2D m_Clouds1AlphaMap; 59 | uniform vec4 m_Clouds1Glow; 60 | varying vec2 clouds1Coord; 61 | #endif 62 | 63 | vec4 mixColors(vec4 color0, vec4 color1) { 64 | vec4 result; 65 | float a0 = color0.a * (1.0 - color1.a); 66 | result.a = a0 + color1.a; 67 | if (result.a > 0.0) { 68 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 69 | } else { 70 | result.rgb = vec3(0.0); 71 | } 72 | return result; 73 | } 74 | 75 | void main() { 76 | vec4 stars = vec4(0.0); 77 | 78 | vec4 objects = vec4(0.0); 79 | 80 | #ifdef HAS_OBJECT0 81 | if (floor(object0Coord.s) == 0.0 && 82 | floor(object0Coord.t) == 0.0) { 83 | objects = m_Object0Glow; 84 | objects *= texture2D(m_Object0ColorMap, object0Coord); 85 | } 86 | #endif 87 | 88 | #ifdef HAS_OBJECT1 89 | if (floor(object1Coord.s) == 0.0 && 90 | floor(object1Coord.t) == 0.0) { 91 | vec4 object1 = m_Object1Glow; 92 | object1 *= texture2D(m_Object1ColorMap, object1Coord); 93 | objects = mixColors(objects, object1); 94 | } 95 | #endif 96 | 97 | vec4 color = mixColors(stars, objects); 98 | 99 | vec4 clear = m_ClearGlow; 100 | #ifdef HAS_HAZE 101 | vec4 haze = m_HazeGlow; 102 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 103 | clear = mixColors(clear, haze); 104 | #endif 105 | color = mixColors(color, clear); 106 | // Bright parts of objects shine through the clear areas. 107 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a; 108 | 109 | #ifdef HAS_CLOUDS0 110 | vec4 clouds0 = m_Clouds0Glow; 111 | clouds0.a *= texture2D(m_Clouds0AlphaMap, clouds0Coord).r; 112 | color = mixColors(color, clouds0); 113 | #endif 114 | 115 | #ifdef HAS_CLOUDS1 116 | vec4 clouds1 = m_Clouds1Glow; 117 | clouds1.a *= texture2D(m_Clouds1AlphaMap, clouds1Coord).r; 118 | color = mixColors(color, clouds1); 119 | #endif 120 | 121 | gl_FragColor = color; 122 | } -------------------------------------------------------------------------------- /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/src/main/resources/Shaders/skies/dome60/dome60.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 dome60.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 | void main(){ 86 | skyTexCoord = inTexCoord; 87 | #ifdef HAS_OBJECT0 88 | object0Offset = inTexCoord - m_Object0Center; 89 | object0Coord.x = dot(m_Object0TransformU, object0Offset); 90 | object0Coord.y = dot(m_Object0TransformV, object0Offset); 91 | object0Coord += m_TopCoord; 92 | #endif 93 | #ifdef HAS_OBJECT1 94 | object1Offset = inTexCoord - m_Object1Center; 95 | object1Coord.x = dot(m_Object1TransformU, object1Offset); 96 | object1Coord.y = dot(m_Object1TransformV, object1Offset); 97 | object1Coord += m_TopCoord; 98 | #endif 99 | #ifdef HAS_OBJECT2 100 | object2Offset = inTexCoord - m_Object2Center; 101 | object2Coord.x = dot(m_Object2TransformU, object2Offset); 102 | object2Coord.y = dot(m_Object2TransformV, object2Offset); 103 | object2Coord += m_TopCoord; 104 | #endif 105 | #ifdef HAS_OBJECT3 106 | object3Offset = inTexCoord - m_Object3Center; 107 | object3Coord.x = dot(m_Object3TransformU, object3Offset); 108 | object3Coord.y = dot(m_Object3TransformV, object3Offset); 109 | object3Coord += m_TopCoord; 110 | #endif 111 | #ifdef HAS_OBJECT4 112 | object4Offset = inTexCoord - m_Object4Center; 113 | object4Coord.x = dot(m_Object4TransformU, object4Offset); 114 | object4Coord.y = dot(m_Object4TransformV, object4Offset); 115 | object4Coord += m_TopCoord; 116 | #endif 117 | #ifdef HAS_OBJECT5 118 | object5Offset = inTexCoord - m_Object5Center; 119 | object5Coord.x = dot(m_Object5TransformU, object5Offset); 120 | object5Coord.y = dot(m_Object5TransformV, object5Offset); 121 | object5Coord += m_TopCoord; 122 | #endif 123 | 124 | gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1); 125 | } -------------------------------------------------------------------------------- /SkyLibrary/src/main/resources/Shaders/skies/dome60/dome60glow.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 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 | vec4 mixColors(vec4 color0, vec4 color1) { 76 | vec4 result; 77 | float a0 = color0.a * (1.0 - color1.a); 78 | result.a = a0 + color1.a; 79 | if (result.a > 0.0) { 80 | result.rgb = (a0 * color0.rgb + color1.a * color1.rgb)/result.a; 81 | } else { 82 | result.rgb = vec3(0.0); 83 | } 84 | return result; 85 | } 86 | 87 | void main() { 88 | vec4 stars = vec4(0.0); 89 | 90 | vec4 objects = vec4(0.0); 91 | 92 | #ifdef HAS_OBJECT0 93 | if (floor(object0Coord.s) == 0.0 && 94 | floor(object0Coord.t) == 0.0) { 95 | objects = m_Object0Glow; 96 | objects *= texture2D(m_Object0ColorMap, object0Coord); 97 | } 98 | #endif 99 | 100 | #ifdef HAS_OBJECT1 101 | if (floor(object1Coord.s) == 0.0 && 102 | floor(object1Coord.t) == 0.0) { 103 | vec4 object1 = m_Object1Glow; 104 | object1 *= texture2D(m_Object1ColorMap, object1Coord); 105 | objects = mixColors(objects, object1); 106 | } 107 | #endif 108 | 109 | #ifdef HAS_OBJECT2 110 | if (floor(object2Coord.s) == 0.0 && 111 | floor(object2Coord.t) == 0.0) { 112 | vec4 object2 = m_Object2Glow; 113 | object2 *= texture2D(m_Object2ColorMap, object2Coord); 114 | objects = mixColors(objects, object2); 115 | } 116 | #endif 117 | 118 | #ifdef HAS_OBJECT3 119 | if (floor(object3Coord.s) == 0.0 && 120 | floor(object3Coord.t) == 0.0) { 121 | vec4 object3 = m_Object3Glow; 122 | object3 *= texture2D(m_Object3ColorMap, object3Coord); 123 | objects = mixColors(objects, object3); 124 | } 125 | #endif 126 | 127 | #ifdef HAS_OBJECT4 128 | if (floor(object4Coord.s) == 0.0 && 129 | floor(object4Coord.t) == 0.0) { 130 | vec4 object4 = m_Object4Glow; 131 | object4 *= texture2D(m_Object4ColorMap, object4Coord); 132 | objects = mixColors(objects, object4); 133 | } 134 | #endif 135 | 136 | #ifdef HAS_OBJECT5 137 | if (floor(object5Coord.s) == 0.0 && 138 | floor(object5Coord.t) == 0.0) { 139 | vec4 object5 = m_Object5Glow; 140 | object5 *= texture2D(m_Object5ColorMap, object5Coord); 141 | objects = mixColors(objects, object5); 142 | } 143 | #endif 144 | 145 | vec4 color = mixColors(stars, objects); 146 | 147 | vec4 clear = m_ClearGlow; 148 | #ifdef HAS_HAZE 149 | vec4 haze = m_HazeGlow; 150 | haze.a *= texture2D(m_HazeAlphaMap, skyTexCoord).r; 151 | clear = mixColors(clear, haze); 152 | #endif 153 | color = mixColors(color, clear); 154 | // Bright parts of objects shine through the clear areas. 155 | color.rgb += objects.rgb * objects.a * (1.0 - clear.rgb) * clear.a; 156 | 157 | gl_FragColor = color; 158 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /SkyLibrary/src/test/java/jme3utilities/sky/test/TestClone.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2025 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.asset.AssetManager; 29 | import com.jme3.asset.DesktopAssetManager; 30 | import com.jme3.asset.plugins.ClasspathLocator; 31 | import com.jme3.export.binary.BinaryExporter; 32 | import com.jme3.material.plugins.J3MLoader; 33 | import com.jme3.renderer.Camera; 34 | import com.jme3.texture.plugins.AWTLoader; 35 | import jme3utilities.Heart; 36 | import jme3utilities.sky.LunarPhase; 37 | import jme3utilities.sky.SkyControl; 38 | import jme3utilities.sky.StarsOption; 39 | import org.junit.Assert; 40 | import org.junit.Test; 41 | 42 | /** 43 | * Test cloning/saving/loading of various objects. 44 | * 45 | * @author Stephen Gold sgold@sonic.net 46 | */ 47 | public class TestClone { 48 | // ************************************************************************* 49 | // fields 50 | 51 | /** 52 | * AssetManager for {@code BinaryExporter.saveAndLoad()} 53 | */ 54 | final private static AssetManager assetManager = new DesktopAssetManager(); 55 | // ************************************************************************* 56 | // new methods exposed 57 | 58 | /** 59 | * Test cloning/saving/loading a {@code SkyControl} object. 60 | */ 61 | @Test 62 | public void testCloneSky() { 63 | assetManager.registerLoader(J3MLoader.class, "j3m", "j3md"); 64 | assetManager.registerLoader(AWTLoader.class, "jpg", "png"); 65 | assetManager.registerLocator(null, ClasspathLocator.class); 66 | 67 | Camera camera = new Camera(640, 480); 68 | float cloudFlattening = 0.1f; 69 | boolean bottomDome = false; 70 | SkyControl s = new SkyControl(assetManager, camera, cloudFlattening, 71 | StarsOption.Cube, bottomDome); 72 | s.setPhase(LunarPhase.WAXING_CRESCENT); 73 | 74 | SkyControl sClone = Heart.deepCopy(s); 75 | Assert.assertEquals(LunarPhase.WAXING_CRESCENT, sClone.getPhase()); 76 | 77 | SkyControl sCopy = BinaryExporter.saveAndLoad(assetManager, s); 78 | Assert.assertEquals(LunarPhase.WAXING_CRESCENT, sCopy.getPhase()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /SkyLibrary/src/test/java/jme3utilities/sky/test/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 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 | /** 27 | * Automated tests for the jme3utilities.sky package. 28 | */ 29 | package jme3utilities.sky.test; 30 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Gradle script to build the SkyControl project 2 | 3 | plugins { 4 | id 'base' // to add a "clean" task to the root project 5 | } 6 | 7 | ext { 8 | jmeTarget = '' // distinguish non-JME libraries built for specific JME releases 9 | skySnapshot = '-SNAPSHOT' // for development builds 10 | //skySnapshot = '' // for release builds 11 | skycontrolVersion = '1.1.1' + jmeTarget + skySnapshot 12 | } 13 | 14 | subprojects { 15 | apply from: rootProject.file('common.gradle') 16 | } 17 | 18 | configurations.configureEach { 19 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' // to disable caching of snapshots 20 | } 21 | 22 | tasks.register('AppChooser') { 23 | dependsOn ':SkyExamples:AppChooser' 24 | description = 'Runs the example apps.' 25 | } 26 | 27 | tasks.register('checkstyle') { 28 | dependsOn ':SkyAssets:checkstyleMain', ':SkyExamples:checkstyleMain', \ 29 | ':SkyLibrary:checkstyleMain', ':SkyLibrary:checkstyleTest' 30 | description = 'Checks the style of all Java sourcecode.' 31 | } 32 | 33 | // Register publishing tasks: 34 | 35 | tasks.register('install') { 36 | dependsOn ':SkyLibrary:install' 37 | description = 'Installs Maven artifacts to the local repository.' 38 | } 39 | tasks.register('release') { 40 | dependsOn ':SkyLibrary:release' 41 | description = 'Stages Maven artifacts to Sonatype OSSRH.' 42 | } 43 | -------------------------------------------------------------------------------- /common.gradle: -------------------------------------------------------------------------------- 1 | // Gradle settings and tasks common to all SkyControl subprojects 2 | 3 | apply plugin: 'checkstyle' // to analyze Java sourcecode for style violations 4 | apply plugin: 'java' // to compile and test Java projects 5 | 6 | java { 7 | sourceCompatibility = JavaVersion.VERSION_1_8 8 | targetCompatibility = JavaVersion.VERSION_1_8 9 | } 10 | 11 | checkstyle { 12 | toolVersion = libs.versions.checkstyle.get() 13 | } 14 | 15 | tasks.withType(JavaCompile).configureEach { // Java compile-time options: 16 | options.compilerArgs << '-Xdiags:verbose' 17 | if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_20)) { 18 | // Suppress warnings that source value 8 is obsolete. 19 | options.compilerArgs << '-Xlint:-options' 20 | } 21 | options.compilerArgs << '-Xlint:unchecked' 22 | options.deprecation = true // to provide detailed deprecation warnings 23 | options.encoding = 'UTF-8' 24 | if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_1_10)) { 25 | options.release = 8 26 | } 27 | } 28 | 29 | Boolean enableNativeAccess = JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) 30 | 31 | tasks.withType(JavaExec).configureEach { // Java runtime options: 32 | classpath sourceSets.main.runtimeClasspath 33 | enableAssertions = true 34 | if (enableNativeAccess) { 35 | jvmArgs '--enable-native-access=ALL-UNNAMED' // suppress System::load() warning 36 | } 37 | //jvmArgs '-verbose:gc' 38 | //jvmArgs '-Xms512m', '-Xmx512m' // to enlarge the Java heap 39 | //jvmArgs '-XX:+UseG1GC', '-XX:MaxGCPauseMillis=10' 40 | } 41 | -------------------------------------------------------------------------------- /config/checkstyle/java-header: -------------------------------------------------------------------------------- 1 | /* 2 | [Copyright information goes here.] 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 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | ## catalog of libraries and plugins used to build and run the SkyControl project 2 | 3 | [versions] 4 | 5 | checkstyle = "9.3" 6 | jme = "3.8.1-stable" 7 | 8 | [libraries] 9 | 10 | acorus = "com.github.stephengold:Acorus:2.0.2" 11 | commons-exec = "org.apache.commons:commons-exec:1.4.0" 12 | heart = "com.github.stephengold:Heart:9.2.0" 13 | jcommander = "org.jcommander:jcommander:1.85" 14 | 15 | jme3-awt-dialogs = { module = "org.jmonkeyengine:jme3-awt-dialogs", version.ref = "jme" } 16 | jme3-core = { module = "org.jmonkeyengine:jme3-core", version.ref = "jme" } 17 | jme3-desktop = { module = "org.jmonkeyengine:jme3-desktop", version.ref = "jme" } 18 | jme3-effects = { module = "org.jmonkeyengine:jme3-effects", version.ref = "jme" } 19 | jme3-jogg = { module = "org.jmonkeyengine:jme3-jogg", version.ref = "jme" } 20 | jme3-lwjgl3 = { module = "org.jmonkeyengine:jme3-lwjgl3", version.ref = "jme" } 21 | jme3-plugins = { module = "org.jmonkeyengine:jme3-plugins", version.ref = "jme" } 22 | jme3-terrain = { module = "org.jmonkeyengine:jme3-terrain", version.ref = "jme" } 23 | jme3-testdata = { module = "org.jmonkeyengine:jme3-testdata", version.ref = "jme" } 24 | 25 | jme3-utilities-nifty = "com.github.stephengold:jme3-utilities-nifty:0.9.37" 26 | junit4 = "junit:junit:4.13.2" 27 | nifty-style-black = "com.github.nifty-gui:nifty-style-black:1.4.3" 28 | 29 | [bundles] 30 | 31 | [plugins] 32 | 33 | download = { id = "de.undercouch.download", version = "5.6.0" } 34 | validate-poms = { id = "io.freefair.maven-central.validate-poms", version = "8.13.1" } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephengold/SkyControl/12292ac2c43bc078772bac1edc70d079884c25e4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH= 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | // global build settings for the SkyControl project 2 | 3 | dependencyResolutionManagement { 4 | repositories { 5 | //mavenLocal() // to find libraries installed locally 6 | mavenCentral() // to find libraries released to the Maven Central repository 7 | //maven { url = 'https://s01.oss.sonatype.org/content/groups/staging' } // to find libraries staged but not yet released 8 | //maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots' } // to find public snapshots of libraries 9 | } 10 | } 11 | 12 | rootProject.name = 'SkyControl' 13 | 14 | /* 15 | * Enumerate subdirectories in the project's root directory that contain a 16 | * "build.gradle" file. Any subdirectory that contains a "build.gradle" file is 17 | * automatically included as a subproject. 18 | */ 19 | def subDirs = rootDir.listFiles( 20 | new FileFilter() { 21 | boolean accept(File file) { 22 | return file.isDirectory() && new File(file, 'build.gradle').isFile() 23 | } 24 | } 25 | ) 26 | 27 | subDirs.each { File sub -> 28 | include sub.name 29 | } 30 | --------------------------------------------------------------------------------