New SkyControl releases


#21

with all option enabled, I get 11 fps. only sky 40 fps. disable sky too (all chkbox disabled) still 40 fps??
could it be the stars texture?

oracle java version 1.8.0_66, will try update it thx

EDIT: I disabled the fps limiter of course


#22

privative nvidia drivers or nouveau?


#23

was priv nvidia’s version 340.76,
just updated to 340.101.
updated also to oracle java 1.8.0_121.

as usually updates scare me, this one dropped the fps from 11 to 8 (with all enabled) and from 40 to 30 (with all disabled or just sky enabled) :slight_smile: needed a hard reboot to fix (shutdown) :slight_smile:

changing stars to 4m, 16m, nebula made fps drop from 30 to 15 and would not up to 30 again (only after restart app).

while running it, I see the 28 java threads it creates, and 2 of them (the main and a sub-thread uses 100% (each) of 2 of my quad core cpu)

I will try to profile it


#24

In order to really limit the fps see app.setSettings (best before starting it) and its related setFramerate


#25

Now we’re getting somewhere. (I don’t know where, but we’re moving.)

As I mentioned on Saturday, TestSkyControl is more of a show-off demo than a speed test. Even with no boxes checked, it’s still doing a lot of (mostly useless) work. So I wrote this little speed test, and I’d like you to try running it. (Feel free to try different settings in the startup dialog.)

package jme3utilities.sky.test;
import com.jme3.app.SimpleApplication;
import com.jme3.math.Quaternion;
import jme3utilities.sky.SkyControl;
public class SpeedTest extends SimpleApplication {
    public static void main(String[] args) {
        SpeedTest app = new SpeedTest();
        app.start();
    }
    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(false);  
        cam.setRotation(new Quaternion(-0.144939f, -0.708461f, -0.152420f, 0.673679f));
        SkyControl sc = new SkyControl(assetManager, cam, 0.9f, true, true);
        sc.setCloudiness(0.5f);
        rootNode.addControl(sc);
        sc.setEnabled(true);
    }
}

#26

perfect! 1000+ fps :smiley:

but… the SkyControlTest has the capability of providing weather changing features, coloring everything etc, what is quite cool and is what I want.

So I guess this simple test is really limited right?

btw, I was profiling with NetBeans the SkyControlTest running from Eclipse and found something interesting:

So basically, while everything was sluggish on my machine at 30 fps, the used heap was constantly increasing, suddenly the heap size is increased and the used is cleaned (gc I guess), and that constant increasing could be the cause of the slugshiness right?

here a bit more:

PS.: I dont use nifty, dunno if there could have anything related?


#27

I haven’t used SkyControl, but I can say that the memory use increasing isn’t what’s causing your problem. The blue memory represents the amount of the heap that’s used. It will grow as heap space is allocated to your program (new objects are created), and then the sharp drop you see there is the GC reclaiming memory that’s no longer in use. The used memory slope is actually increasing extremely gradually - most Java applications under load will probably see a much higher rate of heap space being used. In addition, Java is extremely fast at creating new objects (20 ns for the fast code path, if I remember correctly, and that’s a several year old number), usually significantly faster than a C/C++ malloc/new. You’ll really only see performance issues if you’re creating and throwing away so many objects in such a tight loop that the GC keeps having to kick in. If that was going on in your program, you’d see that blue line skyrocketing - and even if the GC was frequently running, I’d be a bit surprised if it created noticeable pauses for anything except real-time applications (many games probably don’t even come close to this sort of real-time performance requirement - 60 FPS probably means lots of CPU downtime).

In short, the memory use you’re seeing there is really quite stable. Your performance issue lies elsewhere… what you have there is a jog in the park for Java.


#28

I think you’ve ruled out SkyControl itself as the cause of your sluggishness. The speed test includes cloud motion, but not lighting adjustments. I suggest you add the features you need one at a time. Hopefully none of them will cause major sluggishness, but if they do at least we’ll know the cause.

One performance concern I have is GlobeRenderer, which TestSkyControl uses to provide customized phases of the moon. I believe it updates even when the moon doesn’t change, and it does an off-screen render, which might be a performance hit for some graphic cards. I’ll see if I can optimize it. Meanwhile, if you don’t need it, use the moon presets instead.

Low memory could cause performance issues. Hard to be sure without more data.

I can’t rule it out. You can toggle the Nifty display in TestSkyControl (by pressing the “H” key) and see what happens to your FPS.


#29

I will need some time to figure out how to add each feature, I need to browse more your code to understand where it is all setup.

btw,
. I wonder if it would not be too much trouble to create the jars separated by compatible licenses?
. So the content of the BSD jar would not be mixed with the CC-By-SA one, preventing the 2nd to spread on the 1st and defeating its pourpose (whenever we plug it into a project expecting it to be BSD, the CC-By-SA would spread all over)
. Then, projects based on BSD/Apache and CC0/CC-By would not use the CC-By-SA jar, but instead each user would be required to provide an alternative replacement with matching identifiers/paths/filenames to fill each gap it would leave out.
. tho “strict” BSD users could still temporarily use the CC-By-SA jar as a quick start and for tests, but (I at least would) not redistribute it.


#30

Each library/artifact should use a single license. My bad. In the next release, I’ll clean this up.


#31

If you can spare a few minutes, please run the following speed test (which includes a GlobeRenderer) and tell me how the FPS compares to the little speed test on your system:

package jme3utilities.sky.test;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Quaternion;
import com.jme3.texture.Image;
import com.jme3.texture.Texture;
import jme3utilities.MyAsset;
import jme3utilities.sky.GlobeRenderer;
import jme3utilities.sky.SkyControl;
public class SpeedTest extends SimpleApplication {
    public static void main(String[] args) {
        SpeedTest app = new SpeedTest();
        app.start();
    }
    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(false);  
        cam.setRotation(new Quaternion(-0.144939f, -0.708461f, -0.152420f, 0.673679f));
        SkyControl sc = new SkyControl(assetManager, cam, 0.9f, true, true);
        sc.setCloudiness(0.5f);
        rootNode.addControl(sc);
        
        Texture moonTexture = MyAsset.loadTexture(assetManager,
                "Textures/skies/moon/clementine.png");
        Material moonMaterial = MyAsset.createShadedMaterial(assetManager,
                moonTexture);
        GlobeRenderer moonRenderer = new GlobeRenderer(moonMaterial,
                Image.Format.Luminance8Alpha8, 12, 24, 512);
        stateManager.attach(moonRenderer);
        moonRenderer.setEnabled(true);
        sc.setMoonRenderer(moonRenderer);
        sc.setPhase(3.2f, -0.22f);
        
        sc.setEnabled(true);
    }
}

#32

cool thx!

the fps is still amazing with the new test, 750+
I will try some tweaks on the TestSkyControl, I think I am understanding it better now, thx!

I wonder if there are textures being applied/modified dynamically? I think my gfx card may have some problem with that, not sure tho, this is just a wild guess…


#33

With GlobeRenderer, the moon’s texture should be re-generated on every update. So if dynamically modified textures were a problem for your gfx card, you should’ve seen it in the speed test you just ran.


#34

I tried to profile with jrat, and deeply expanded the tree at netbeans profiler, but I am “still clueless” (renderer… shaders? thats too broad).

I dont know what to disable (without breaking things) on the TestSkyControl to pin point the sluggishness culprit.
If you would like me to try new tests just say so.

And if the SpeedTest already gives us access to all the cool SkyControl (solely) features (not terrain and shadows, unless you have cloud’s shadow on the terrain?) that we are able to dynamically tweak at TestSkyControl, the SpeedTest code will suffice for sure!

So, may be, the slugshness will only happen at TestSkyControl, but not when using all features from the SkyControl.
And if that is a problem with my old gpu or something else (old) here, or something other then the SkyControl solely, may be it will not be that useful to tweak a Test if the real thing is working well :).

So basically, the SpeedTest can also be a simple generic (and still fully featured) quick start, for anyone willing to use this lib, I guess! :slight_smile:


#35

doing some tests in full screen (with SpeedTest),

it seems that the moon is glued into the sky (moves together with the stars), is that right?
if so, do you think it could be detached and spin (around earth) independetly? so we could also one day have an eclipse! :smiley:
it would be cool to let it spin around itself also, but then it would have to become a sphere I guess, no idea if that would be realistic anyway (but would be fun to make it spin fast :))

the cloud layers, I didnt find a method to add layers, or is it automatic? and they move on the same direction or independently of each other?

also, does it has sunshafts? it is/would be a kind of shader right?


#36

The moon’s position (relative to the sun) can be set using SkyControl.setPhase(float, float)
For instance setPhase(FastMath.PI, 0f) gives you a full moon (opposite the sun), setPhase(1f, 0f) gives you a waxing crescent moon, and setPhase(0f, 0f) gives you a solar eclipse. (But note that eclipses aren’t realistic in SkyControl. See issues #4 and #5.)

The sun’s position relative to the stars is set using SunAndStars.setSolarLongitude() methods. You access the SunAndStars object using SkyControl.getSunAndStars()

To see the far side of the moon (which in real life is never seen from Earth) you can rotate it on its axis using GlobeRenderer.setSpinRate(float).

Cloud layers move independently, though there is a master rate setting in SkyControlCore which affects them all. There is a CloudLayer object corresponding to each of the 6 layers, which provides access to opacity, texture, and motion. You can access any layer using SkyControlCore.getCloudLayer(int).

SkyControl doesn’t currently implement sunbeams, no.


#37

I tried this code:

  for(int i=0;i<6;i++){
  	CloudLayer cl = sc.getCloudLayer(i);
  	cl.setOpacity(1f);
  }
	sc.getCloudLayer(0).setColor(new ColorRGBA(1,0,0,1)); //r
	sc.getCloudLayer(1).setColor(new ColorRGBA(0,1,0,1)); //g
	sc.getCloudLayer(2).setColor(new ColorRGBA(0,0,1,1)); //b
	sc.getCloudLayer(5).setColor(new ColorRGBA(0,1,1,1)); //c
	sc.getCloudLayer(4).setColor(new ColorRGBA(1,0,1,1)); //m
	sc.getCloudLayer(3).setColor(new ColorRGBA(1,1,0,1)); //y

    sc.setEnabled(true);

mainly as a test to be able to distinguish between clouds,
but I am only being able to visually distinguish two cloud layers,
and both are white,
did I do something wrong?

btw, the fast spinning moon is quite cool and looks great hehe!


#38

If you only see two cloud layers, it’s likely the other four have clear textures. Inside the loop add cl.setTexture(“Textures/skies/clouds/fbm.png”, 1f);

To distinguish layers, you may also want to give each one a different motion using cl.setMotion()

PS: The clouds are white because SkyControl overrides your color settings.


#39

I was watching the real sky and saw a cool thing that could be added, would be the middle to far horizon clouds’ sides vertical visible mass volume.

I am not sure but I think that would require a few more layers?
or could reuse the current ones?
or would be necessary to become volumetric/geometry clouds?
nah, I dont really know how that could be implemented…

that document 241770.pdf at New SkyControl releases
shows quite shy far clouds, and I mean this I just found on google (see the lower/far ones, how huge they look): :slight_smile:


#40

You can achieve this effect with SkyControl – as long as you don’t allow the clouds to move! :slight_smile:

As you probably realize, clouds in SkyControl are 2-D with one color per layer – more like a thin haze than the puffy clouds in the photo you referenced. A 2-D texture for puffy clouds that looks good on the horizon will look very strange if/when it passes overhead.

Perhaps the links shamanDevel posted will give me ideas for implementing 3-D clouds with shading.

Release 0.9.2 is nearly ready, but it won’t include 3-D clouds.