POV-Ray : Newsgroups : povray.text.scene-files : Clouds code : Clouds code Server Time
4 Jul 2024 03:48:49 EDT (-0400)
  Clouds code  
From: Gilles Tran
Date: 8 Apr 2002 07:44:21
Message: <3cb18295$1@news.povray.org>
// Test for fast clouds
// Gilles Tran 8/4/2002 (www.oyonale.com)
// Feel free to use, modify etc.
#version 3.5;
#include "colors.inc"
global_settings{max_trace_level 50}

light_source {
    -z*10000
    White*2
    rotate x*60
    rotate y*90
}
camera {
  location  <0.0, 0, -60>
  direction z*8
  right     image_width/image_height*x
  look_at   y*3+z*10
}
#declare SkyBlue=rgb <135,142,238>/255;
//#declare SkyBlue=rgb <135,172,238>/255;

#macro colCloud(Color,P,S,T)
    rgbf <pow(Color.x,P)*S,pow(Color.y,P)*S,pow(Color.z,P)*S,T>
#end

#declare colCloud1=colCloud(SkyBlue,0.3,0.6,0.8); // shadow
#declare colCloud2=colCloud(SkyBlue,0.3,0.8,0.5);
#declare colCloud3=colCloud(SkyBlue,0.2,1,0.3);
#declare colCloud4=colCloud(SkyBlue,0.1,1.2,0.1); // white

#declare colBack=Clear;
// the clouds pigment
// because it's based on the cylindrical pattern, translating the pattern
along the z axis changes the shape of the cloud
#macro mPigCloud(S1,S2) // S1 and S2 are the cloud length and height
    #local Turb=0.35+rand(rd)*0.2;
    #local Lambda=3+rand(rd);
    pigment{
        pigment_pattern{
            cylindrical
            scale <S1,1,S2>
            warp{turbulence Turb lambda Lambda}
            rotate -x*90
        }
        pigment_map{
            [0.4 color colBack]
            [0.5
                pigment_pattern{
                    function{min(1,max(0,y))}
                    warp{turbulence Turb lambda Lambda}
                    rotate -z*20 // tilts the higlights to the right
                }
                pigment_map{
                    [0

                        pigment_pattern{
                            cylindrical
                            scale <S1,1,S2>
                            warp{turbulence Turb lambda Lambda}
                            rotate x*-90
                        }
                        pigment_map{
                            [0 color Clear]
                            [0.7 colCloud1]
                            [1 color colCloud2]
                        }

                    ]
                    [0.7 colCloud4]
                }
            ]
        }
    }
    finish{ambient 1 diffuse 0}

#end
#declare i=0;
#declare rd=seed(1);
#declare NZ=6;
#declare LZ=6;
#declare Nuage0=union{ // basic cloud square
    triangle{0,y,x+y}
    triangle{0,x,x+y}
    hollow
    translate -x*0.5-y*.5
    scale 5
    no_shadow
}
union{
    #while (i<10)
        #debug concat(str(i,0,0),"\n")
        #declare j=0;
        #declare zC=i*40;
        #while (j<NZ)
            #declare Nuage=union{ // 3 subclouds
                object{Nuage0
texture{mPigCloud(2+rand(rd),0.5+rand(rd))translate z*100*rand(rd)}
                    #declare SN1=0.4+rand(rd)*0.4;
                    scale SN1

                }

                object{Nuage0
texture{mPigCloud(2+rand(rd),0.5+rand(rd))translate z*100*rand(rd)}
                    #declare SN2=0.4+rand(rd);
                    scale SN2
                    translate <2*rand(rd),0,-2>
                }

                object{Nuage0
texture{mPigCloud(2+rand(rd),0.5+rand(rd))translate z*100*rand(rd)}
                    #declare SN3=0.4+rand(rd);
                    scale SN3
                    translate <-2*rand(rd),0,-1>
                }
            }
            union{
                object{Nuage clipped_by{plane{y,0 inverse}}}
                object{Nuage clipped_by{plane{y,0}} scale <1,0.5,1>} //
makes the bottom flatter
                scale (1+rand(rd))
                translate
<-LZ+(j/(NZ-1))*(2*LZ)+(0.5-rand(rd))*5,0,zC+rand(rd)+(0.5-rand(rd))*i*60>
            }
            #declare j=j+1;
        #end
        #declare i=i+1;
        #declare NZ=NZ+i*2;
        #declare LZ=LZ+4*i;
    #end
    translate y*4
}


sky_sphere{
    pigment{
        gradient y
        poly_wave 0.1
        color_map{
            [0 color SkyBlue*2]
            [1 color SkyBlue*0.3]
        }
    }
    rotate x*2
}

fog{colCloud(SkyBlue,0.3,1,0) fog_type 2 distance 400 fog_alt 8}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.