GLSL clouds from Shadertoy

Hi there!

I’m learning GLSL, and of course GLSL in Touchdesigner.
I’m learning by porting shaders from Shadertoy, and it’s very interesting!
I managed to port some of them, but I’m stuck with this one…

So I’m trying to port these (beautiful) Clouds:
shadertoy.com/view/XslGRr

Here is where I’m stuck:
GLSL-clouds.toe (5.47 KB)

I managed to make it work, but I have some weird results. The clouds are compressed and there are circle artifacts.I think the problem comes from a resolution ratio somewhere, but I can’t understand where my error is. Any idea?

Thanks for your help!

Hi Kefon,

I’m seeing the same behavior, and am interested in this same shadertoy so I started to dive in.

Replacing the noise with Perlin instead of random, and playing with all of the noise parameters helps dial in the cloud aesthetic a bit more. Bumping up the number of MARCH steps around lines 92-95 helps too. However, I see at least two major issues that I can’t nail down. It seems like there’s no(or too little) smoothing in between the voxels, so the clouds are quantized to a 3d grid, and then second is the circle artifacts that seem to be pixel / viewport based. They could be two aspects of the same problem. I found that if you rotate the scene to the side, you see slices of clouds, when in the original the noise is truly 3d volumetric - so I think something’s happening where the 3rd dimension of the noise isn’t being respected? Let us know if you figure it out!

Thanks for the reply, glad to know I’m not the only one struggling with this shader :wink:
I have the same problem of slices of clouds instead of volumetric + circle artifacts.
Yes for me the problem might comes from resolution / viewport, bur for now no luck…

Hi there, I’m still struggling with the cloud shaders…
Still no luck with the one from iq, so I decided to try another one:

shadertoy.com/view/lssGRX

When I port it to Touchdesigner, this time no circle artifacts, but I have the same problem that display “slices” of clouds instead of truly 3d volumetric… (see attached file). Any idea on how to solve this?

GLSL-clouds.toe (5.61 KB)

I see the artifacts too but don’t know what’s causing them. I saw this comment on shadertoy. It would replace the noise function and then you don’t need a texture. It fixed it for me.

[code]// Shader - Shadertoy BETA
float iqhash( float n )
{
return fract(sin(n)*43758.5453);
}

float noise( vec3 x )
{
// The noise function returns a value in the range -1.0f → 1.0f
vec3 p = floor(x);
vec3 f = fract(x);

f       = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0 + 113.0*p.z;
return mix(mix(mix( iqhash(n+0.0  ), iqhash(n+1.0  ),f.x),
               mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),
           mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),
               mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);

}[/code]

Pretty interesting! Thanks for the answer, with your noise function there is no more “slices of clouds”. But with it my framerate falls from 60fps to 20fps… Is that the case for you also?

It goes from 60 to 50ish for me.