After testing my theory, I started coding a new sceneobject. The new sceneobject started with the cloudLayer code as a base, then heavily modified. I added new functions to stack layers of cloud textures, add space between them, modulate the exposure of the layers to create depth, and modulate the shape of the volume. The shader code remains unchanged so far.

I ran into a problem though. The volumes aren't being shaded correctly. This image shows what I mean:Compared to the image above, this one looks very different even though it's largely the same thing.

This image shows a custom texture being used which I made to exaggerate the incorrect shading. The dark layers are supposed to be rendering before the lighter layers, but they aren't. I haven't modified the shader yet or any of the code that calculates normals, but it looks like a problem with the normals facing the wrong way. Even after trying to invert normals here and there, nothing seems to fix it.

I'd really like to get past this bug so that I can add more features, finish up the code, and possibly put it on github for the next release. If anyone wants to help out or has any idea on what could be causing the bug, let me know. In the mean time, I can answer any questions. Thanks!

Thanks for the suggestion and the link! I already have a function that controls the shape of the volume based on how many layers it has. I turned it off to exaggerate the bug that's happening. As for the render binning, I'll definitely look into it later. It sounds promising.

Happy to help. I know we talked about the possibility of adding shadow to the cloud layer and make it occlude the god ray shader. I did some digging up and found that in order to do that, one must render the cloud layer to a frame buffer and use that frame buffer for the shadow and god ray.

I think it would be cool to influence the material properties like colour and opacity. As you're using the same map for all layers it looks like "extruded shapes" if you know what I mean. Gradually changing colour and transparency could perhaps reduce that a bit.

I have this loop generating the geometry for the layers in the cloud volume (same general code that exists in the _initBuffers() function in the cloudLayer object). The LAYER_COUNT variable was set to 20, so I was creating a stack of 20 curved planes and then storing them in the vertexBufferHandle array mVB. Each layer had a different height based on the starting height defined in the world editor, which is represented by the mHeight variable. The spacing between each layer was defined by mSpacing, which was also set in the world editor. So the loop goes: create layer 1 > stretch layer vertically by mHeight+mSpacing amount > create layer 2 > stretch layer vertically by mHeight+mSpacing+mSpacing amount > create layer 3 > stretch layer vertically by mHeight+mSpacing+mSpacing+mSpacing amount > etc.

The problem was that I was starting from the bottom of the stack, and generating layers up to the top of the stack. This is a problem because of the way that the mHeight variable actually affects the geometry. It doesn't actually set a new height for the layer(ie, new coordinates), it just scales the layer upward. I made this image to represent what the stacked layers would look like with the above code:

The numbers represent the order in which the layers were being created. If the red layer was created first, then each subsequent layer was actually being created and scaled through all preceding layers. After applying textures to each layer, this gave the whole volume the same type of look that happens on a model with inverted normals. This is the effect that I mean:

The polys seem to render facing inwards instead of outwards.

After realizing that this was the problem, it only took me a couple seconds to fix the loop to start from the top instead of the bottom. The code now looks like this:

And a visual representation of the layer generation order now:(Once again, the numbers in the image only represent the order in which the layer is being generated.)

This way, I'm actually generating the 20th layer at the top, then working my way down the stack.

That pretty much sums it up! With that out of the way, I'm now focusing on how I want to give the clouds variable shape and the best way to allow the user to control the shape through the world editor. I'll post some screenshots or a video of that in a few days to get some input from anyone who wants throw ideas around.