Hmm, I suppose it would be best to find out first is someone haven’t already done it before & talk with core devs regarding contributions.
Also, if your goal is volumetric clouds, will not offscreen Framebuffer + Texture fullfill your needs? That’s what I do in SevenSky volumetric clouds implementation and it requires GL 2 only I think.
I am sure I could achieve a similar look as the project I linked without a compute, but I doubt I would get the same frame rate if I use a fragment shader.
I don’t know much about the compute shader work already done… I know folks have managed to use it before but I don’t know how much tweaking that they had to do to the engine.
@The_Leo I am checking out SevenSky now. I see your fragment shader CloudVolume.frag. Is that what you are referencing? I don’t see an example of volume clouds, just 2d clouds.
@The_Leo ah ok. Excellent! I am trying to mimic the lighting from this talk. I think will need to introduce the 3 phase light scattering that is discussed around 16:35
Isn’t this one implemented in CloudPost.frag, lines 707-709 ?
700: for(int i = 0; i < steps; i++) {
701: //float v = cnoise(p * 0.1)*wmap(p);
702: //float density = noisee(p);//map2(p);
703: float density = Density(p);
704: //vec3 Light = Sunlight(p);
705:
706: if(density > 0.0){
707: float extinCoeff = ExtinctionFactor*density;
708: float T = exp(-extinCoeff*add);
709: vec3 Light = Sunlight(p)*(phase*(1.0-exp(-extinCoeff*add*2.0)));
I’ll tell you the similarities/difference between the implementation in the video you posted and SevenSky implementation:
The implementation in video:
uses 2 noise textures to create cloud shape
uses top down weather map
uses at most 120 samples, switches from cheap sampling to expensive sampling when cloud is found
for each expensive sample in cloud does another 6 density samples towards the sun
thus theoretical worst case would be 120+120*6 = 840 samples per ray
SevenSky implementation:
uses 1 noise texture to create cloud shape, second one is commented out (CloudPost.frag, line 419)
uses top down weather map
uses at most 16 samples
does not sample towards the sun, but for additional detail you can do this, check CloudPost.frag, line 478, where integration towards sun is commented out
Not exactly. Looks like you have scattering phase, but the light model in that video has beer lambert (Out Scattering) and In scattering to give those dark edges. There are also some other techniques, but the three main ones are those.
The project I linked has a very good example this and I borrowed heavily from it to modeify CloudPost.frag to create more realistic looking clouds. I adjusted line 709 to calculate the light using all three functions.
I did not add any other texture samples, just light calculations. As you can see, the edges are not blended well with the background. I changed the blend mode of cloudPost material to alphaAdditive and the result is more pleasing:
I think there is still a good amount of progress to be made, but I have happy with the results so far. If you would like to integrate what I have done into sevenSky, I would be happy to share.
The first image has two cloud layers, and the high clouds are not blending at all with the volume clouds. I’m still experimenting with premultiplied blend mode.
The second image is closer, but I agree, something isn’t quite right.
Looks like this sky system is using full screen quad. I am not sure why the sky system is using an inverted projection matrix. I will have to dig into SevenSky
To me, it still feels like we are looking at the tops of the clouds and not the bottoms:
Or here, maybe this is clearer. If you saw this next pic on its own without context, would you think we were flying above the clouds or standing on the ground below them?
It’s looking really good. I wrote a patch that roughly implemented compute shaders in jme. Would you be interested in that? It was a really long time ago but I think it would still work…