New SkyControl releases

so, how to solve your problem in the result?

Are you asking me? Or Thoced?

sorry, I asked @thoced :slight_smile:

1 Like

Hello,

Using the update of Skycontrol 0.9.12

2 Likes

Version 0.9.13 of SkyControl is now ready. The old SkyControl constructor is now deprecated, as promised.

7 Likes

Sorry for bumping this thread

@sgold any way I can use SkyControl with PBRLighting ?

1 Like

Sorry, SkyControl is not compatible with PBR—or even with gamma correction.

SkyControl has been in a holding pattern for over a year now. I haven’t even rebuilt the library for JME v3.2.3 yet!

By the way, the current release is v0.9.17 .

1 Like

I was able to make it work in my PBR scene using the solution provided here:

I am updating FilterColor with AmbientColor value getting from SkyControl.

Here is my code in case anyone interested

    /**
     * Wrapper state for SkyControl
     *
     * @author Ali-RS
     */
    public class SkyState extends BaseAppState {

        private TimeOfDay timeOfDay;
        private SkyControl sc;
        
        private final Vector4f pbrAmbient = new Vector4f(1, 1, 1, 1);
        private final MatParamOverride overrideFilterColor = new MatParamOverride(VarType.Vector4, "FilterColor", pbrAmbient);;

        public SkyState() {
        }

        public TimeOfDay getTimeOfDay() {
            return timeOfDay;
        }

        public SkyControl getSkyControl() {
            return sc;
        }

        @Override
        protected void initialize(Application app) {
            this.timeOfDay = new TimeOfDay(9);
            app.getStateManager().attach(timeOfDay);
            
            LightingState lightingState = getState(LightingState.class, true);

            sc = new SkyControl(app.getAssetManager(), app.getCamera(), 0.7f, StarsOption.Cube, true);
            Node rootNode = ((SimpleApplication) app).getRootNode();
            rootNode.addControl(sc);
            
            sc.setSunStyle("Textures/skies/suns/hazy-disc.png");
            sc.setCloudiness(1f);
            sc.setCloudsYOffset(0f);
            //sc.getSunAndStars().setObserverLatitude(0.2f);
            //sc.getUpdater().setMainMultiplier(2f);

            sc.getUpdater().setAmbientLight(lightingState.getAmbientLight());
            //sc.getUpdater().setMainLight(lightingState.getSun());

            String Clouds_L = "Textures/skies/Clouds_L.png";
            sc.getCloudLayer(0).setTexture(Clouds_L, 1f);
            sc.getCloudLayer(1).setTexture(Clouds_L, 1.5f);

            sc.setLunarDiameter(FastMath.DEG_TO_RAD * 8);
            sc.setSolarDiameter(FastMath.DEG_TO_RAD * 7);
            
            sc.setPhase(LunarPhase.FULL);

            int numSamples = app.getContext().getSettings().getSamples();
            BloomFilter bloom = Misc.getFpp(app.getViewPort(), app.getAssetManager(), numSamples)
                    .getFilter(BloomFilter.class);
            if (bloom != null) {
                sc.getUpdater().addBloomFilter(bloom);
            }
        }

        @Override
        protected void cleanup(Application app) {
            app.getStateManager().detach(timeOfDay);
            sc.getSpatial().removeControl(sc);
            timeOfDay = null;
            sc = null;
        }

        @Override
        protected void onEnable() {
            sc.setEnabled(true);
            sc.getSpatial().addMatParamOverride(overrideFilterColor);
        }

        @Override
        protected void onDisable() {
            sc.setEnabled(false);
            sc.getSpatial().removeMatParamOverride(overrideFilterColor);
        }

        @Override
        public void update(float tpf) {
            sc.getSunAndStars().setHour(timeOfDay.hour());
            ColorRGBA color = sc.getUpdater().getAmbientLight().getColor();
            pbrAmbient.set(color.r, color.g, color.b, color.a);
        }
    }
1 Like

I’ve decided to dust off SkyControl and work on it some more. In preparation, I’ve split it off into its own GitHub repository: GitHub - stephengold/SkyControl: A sky simulation library for jMonkeyEngine (code has New BSD license)

7 Likes

@sgold If you are working on SkyControl: two changes that I would like to see made:

  1. Fix the issue where SkyControl crashes on Android, because Android does not like GLSL110. The fix seems to be to change it to GLSL100. There is a thread in the forums about this issue.
  2. Make the direction of north/south configurable, instead of it being hardcoded that positive x is north. There is a thread I raised on the forums about that too. Perhaps allow 4 different options (e.g. positive x is either north, east, south or west)
1 Like

Please provide a link to the forum thread.

1 Like

I was inactive for most of 2015. I don’t recall seeing that thread before and was unaware of the Android issue until you mentioned it. I’m very grateful to you for pointing it out.

I’ve updated all the material definitions to specify GLSL100 instead of GLSL110. I’ve tested it on my desktop. If someone with an Android development environment would test the change there and report back, I’d be grateful.

And then I’ll address the coordinate-system issue.

1 Like

I tested my app with the current master branch and the issues I had with version 0.9.26 on Android are fixed.

2 Likes

Thanks for the quick turnaround on my request for Android testing.

I have a hunch that if I simply made the “north” axis configurable, someone else would request that the “up” axis be made configurable as well. So I took your suggestion a step further and made the world coordinate system fully configurable.

The following public methods have been added to the SunAndStars class:

    /**
     * Convert horizonal coordinates to world coordinates.
     *
     * @param northing the northward component
     * @param height the upward component
     * @param easting the eastward component
     * @param storeResult storage for the result (modified if not null)
     * @return a vector in world coordinates (either storeResult or a new
     * vector)
     */
    Vector3f convertToWorld(float northing, float height, float easting,
            Vector3f storeResult);

    /**
     * Convert the specified rotation from horizontal coordinates to world
     * coordinates.
     *
     * @param rotation (not null, modified)
     */
    void convertToWorld(Quaternion rotation);

    /**
     * Determine the direction to the east horizon.
     *
     * @param storeResult storage for the result (modified if not null)
     * @return a unit vector in world coordinates (either storeResult or a new
     * vector)
     */
    Vector3f eastDirection(Vector3f storeResult);

    /**
     * Determine the direction to the north horizon.
     *
     * @param storeResult storage for the result (modified if not null)
     * @return a direction vector in world coordinates (either storeResult or a
     * new vector)
     */
    Vector3f northDirection(Vector3f storeResult);

    /**
     * Redefine the world coordinate system relative to the horizon.
     *
     * @param north the desired north direction (in world coordinates, not null,
     * length>0, unaffected, default=(1,0,0))
     * @param up the desired up direction (in world coordinates, not null,
     * length>0, orthogonal to north, unaffected, default=(0,1,0))
     */
    void setAxes(Vector3f north, Vector3f up);

    /**
     * Determine the direction to the zenith.
     *
     * @param storeResult storage for the result (modified if not null)
     * @return a unit vector in world coordinates (either storeResult or a new
     * vector)
     */
    Vector3f upDirection(Vector3f storeResult);

Please let me know whether (or not) the latest changes meet your needs.

2 Likes

Excellent.

I added this line

skyControl.getSunAndStars().setAxes(new Vector3f(0,0,-1),new Vector3f(0,1,0));

to make positive x == East.

Thank you very much for making these changes.

1 Like

This is good news! I’m using it in my product and think it is an important component for JME. Thanks!

1 Like

Just updated to newest - I think the configurable coordinate systems will come in handy!

1 Like

SkyControl v0.9.28 has been released, with all the latest changes:

4 Likes

Well, that was short-lived… time to bump the SkyControl dependency version again. :rofl:

1 Like