Generated Clouds

Hi guys!



I try to generate a clouds texture with a Perlin Noise. I used HeightGenerator for it:


   private Texture generateClouds(int width, int height) {
      BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
      WaterHeightGenerator gen = new WaterHeightGenerator();
      
      for (int y = 0; y < height; y++) {
         for (int x = 0; x < width; x++) {
            double hval = gen.getHeight(x, y, 1);
            buf.setRGB(x, y, (int) (hval*255*255*255));
         }
      }
      
        ImageGraphics graphics = ImageGraphics.createInstance( width, height, 1 );
      graphics.drawImage(buf, 0, 0, null);
       
        Texture texture = new Texture();
        texture.setFilter( Texture.FM_LINEAR );
        texture.setWrap( Texture.MM_LINEAR );
        texture.setImage( graphics.getImage() );
//        texture.setTextureId(0);
       
      return texture;
   }



I don't know if this is correct. When I set the texture on a skybox like this, it all comes up black:


      Texture generatedClouds = generateClouds(128, 128);
      sky.setTexture(Skybox.UP, generatedClouds);



What am I missing?  :? I just try to generate a grayscale noise image. After that I want to add it layered to a large texture that is then projected on a plane above my terrain, maybe with the edges moved down to have a real sky effect.

What I'm heading for is a procedural sky with generated clouds on it. I read about the theory here:

I added the SkyDome and a FogState now and I wondered if it is possible to render a texture on it. I’d love to have some rendered clouds on it. Any ideas or code available?



This is what I got until now:





By shintostar at 2007-07-31

You can just apply a texture to the SkyDome and it will automatically blend in with its color because SkyDome uses the colorbuffer.


TextureState ts = renderer.createTextureState();
ts.setTexture(clouds)
skydome.setRenderState(ts);
skydome.updateRenderState();

Great! I'll try it. Thanks a lot. :slight_smile: Now my only problem is to generate a cloud texture…

I added a static texture now and this is what it looks like:







I love it! :slight_smile:

desertrunner said:

I love it! :)


Me too, looks good.

Looks like something I could use for the background of my SkySphere…

Although it will prolly not be clouds but other, space related textures

Hm, I recognized that the far clipping pane cuts my terrain on the horizon. I tried to set the fog density to 1f, but I only apply the fog to the terrain and the water, so that has no effect on the clipping effect of the terrain. I wondered if there is the chance to avoid that "cutting away".



I read about adding mountains to the horizon so a User can't see the clipping. Don't know if this is the only option, but I thought more like the fog is blending out the far edge and after the fog reaches full density, the clipping could take place. Hm, was that clear enough? :?

Having it on the water and terrain should be exactly right… Try using a fog color that very closely matches the average sky color, and set the start and end value up so that they either straddle or end at your far plane (eg:  if your far plane was 1000, start and end could be something like 500, 1250)  Also, try using linear density.


But the SkyDome is behind the Fog then too, isn't it? Or can I use the ZBuffer to always draw the SkyDome without affecting him with the FogState? Hm, I have to try that later… thanks for your hints.