Are multiple, layered, transparent skies possible with the default sky factory?

I’d like to layer multiple skies by using transparency in the sky textures. Unfortunately I’m not up to speed on how the pipeline works and I haven’t figured out by myself how to do this.

What I want to achieve is to have multiple, layered skies (basically just multiple spheres, like an onion), with alpha in the textures being considered and the further away skies being visible. Additionally I’d like to fade single sky layers by making them more transparent.

Is that possible with the default sky system or do I have to role my own?

1 Like

Hello @RobertZenz, it is possible to create several sky maps. Basically, a sky is just a box geometry with queue bucket set to SKY. What have you tried yet?

For the fade in effect you might have to write your own control I think.

I’ve created multiple skies through the SkyFactory and assigned the inner-most a texture which has an alpha channel/transparent parts but the transparent parts just render as black.

I tried to change some of the properties of the sky spatial (changing the bucket, setting the material to transparent, …) but that either changed nothing or the sky did not render at all.

Alright, did you try to create 2 (or more) materials, one for the transparent sky and another one for the “back” sky. I am not sure which parameters you can set in the sky material definition, but have a look if you can set blend mode to alpha.

In the case really nothing works, I would create the sky boxes in blender or in code and use the unshaded material definition.

We’d have to know exactly what you changed about the material.

For example, did you set the blend mode to alpha? That’s really the only thing that will matter other than controlling the rendering order.

For example, did you set the blend mode to alpha? That’s really the
only thing that will matter other than controlling the rendering order.

Ah, thank you, that one actually slipped through my tests.

Spatial skySpatial = SkyFactory.createSky(....);
((Geometry)skySpatial).getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

That makes sure that the alpha of the image is correctly rendered, with the skies behind it being visible. Now there are only two questions left, if I can set arbitrary transparency on a layer and for some reason the radius of the sky does not define the draw order, the creation order does…or at least that’s what my quick test showed.

Thanks so far, I’ll try some more things tomorrow.

1 Like

I’ve actually figured the ordering out. You have to attach the sky spatials to a node, and the one that is going to be rendered in front is the first in the list. The radius of the sky isn’t considered when being rendered. Like this:

Spatial skyline = SkyFactory.createSky(...);
Spatial clouds = SkyFactory.createSky(...);
Spatial background = SkyFactory.createSky(...);

Node skies = new Node();
skies.attachChild(skyline);
skies.attachChild(clouds);
skies.attachChild(background);

Which yields the list:

0: skyline
1: clouds
2. background

With the skyline and the clouds being drawn in front of the background.

What I could not find is how to make it transparent as a whole. I tried setting a different material (like to Unshaded) but without any success, it would not render correctly at all when changed. Does somebody know how I could make the complete sky transparent (as in half transparent)?

Also, I’m seeing a graphical glitch when I set the BlendMode to Alpha (kinda hard to see because of the colors):

That’s visible when I look up, I can also see some downward. Yes, the background color is set to pink.

Maybe by changing the texture? It might become difficult if you want to have a smooth transition, though.

Just in case somebody else wonders, it was the obvious answer, the textures were broken. They had a line of two near transparent pixels at the corner which yielded these black lines.

Additionally for the transparency, I ended up writing my own shader implementation which allows me to combine a color with the set texture, including transparency. This implementation will be open source and available in the next iteration of Quadracoatl.

1 Like

As promised, the source for my solution is available in the Quadracoatl repository, you’re looking for the Sky shaders.

There isn’t much to see, though, all I basically did was blending the in the fragment shader.

2 Likes