POV-Ray : Newsgroups : povray.text.scene-files : Clouds again... In plain text for... Server Time
31 Oct 2024 16:16:52 EDT (-0400)
  Clouds again... In plain text for... (Message 1 to 1 of 1)  
From: Ken
Subject: Clouds again... In plain text for...
Date: 13 Sep 1999 10:27:38
Message: <37DD0971.FCD524EF@pacbell.net>
//============================================================
//
// Cloud2.pov
//
// A scene showing cloud built from concentric spheres.
// Cloud texture is purely ambient and shows a light
// source highlight. 
//
//   By Michael Andrews, 10/9/99
//
//============================================================

//=========================================
// macro mAlign
// Adapted from Giles Trans' Maketree.pov
//-----------------------------------------
// returns a matrix operation that aligns an object or texture along P2-P1
// the object is translated to P1
// translate to P2-P1 if you want the object to be on P2
#macro mAlign(P1,P2)
	#local yV1=vnormalize(P2-P1);
	#local xV1=vnormalize(vcross(yV1,z));
	#local zV1=vcross(xV1,yV1);
	matrix <xV1.x,xV1.y,xV1.z,yV1.x,yV1.y,yV1.z,zV1.x,zV1.y,zV1.z,P1.x,P1.y,P1.z>
#end   
//-----------------------------------------
// end of mAlign macro
//=========================================

#include "colors.inc"

global_settings { assumed_gamma 1.0 max_trace_level 100 }
                       
// Light constants.                       
#declare lightDir = vnormalize(<-0.5,2.1,2>);
#declare lightLen = 1.5e6;
#declare lightRad = lightLen*sin(radians(0.25));
#declare lightCol = <1,.97,.95>;

// Camera constants.
#declare camPos = <0.0, .15, -.75>; 
#declare camLookAt = <0,7,20>;
#declare camAngle = 90;

camera {
	up <0, 1, 0>
	right <4/3, 0, 0>
	location  camPos
	direction <0.0, 0.0, 1>
	angle     camAngle
	look_at   camLookAt
}

light_source {
	0*x
	colour rgb lightCol
	translate lightDir*lightLen
	parallel
	point_at 0
	media_attenuation on
}

// Fake an atmospheric light blur.
union {
	sphere { 0, 1 pigment { rgb lightCol } finish { ambient 1 diffuse 0 } }
	disc { 0, y, 1 pigment { spherical poly_wave 3 colour_map {[0 rgbt 1][1 rgb
lightCol]} } finish { ambient 1 diffuse 0 } scale 15 }
	no_shadow
	scale lightRad
	mAlign(lightLen*lightDir, camPos)
}

// 	Standard constants.
#declare baseRad = 6371.0;
#declare grndRad = baseRad;

#declare atmDisp = 15;
#declare atmCol = <1/atmDisp, 1/sqrt(atmDisp), 1>;

// Fade out the horizon to minimize artifacts.
fog {
	fog_type 2
	colour rgb (0.4+atmCol)*0.5
	distance 30
	fog_alt 6
}

fog {
	fog_type 2
	colour rgb (1-atmCol)*0.5
	distance 500
	fog_alt 15
}

background { rgb atmCol }

// Start of cloud definition.
#declare cloudDepth = 1;
#declare cloudBase  = baseRad+2;
#declare cloudTop   = cloudBase + cloudDepth;

#declare baseVal = cloudBase/cloudTop;
#declare topVal = 1;
#declare midVal = 0.25*(baseVal*3+topVal);

// Reduce cloud at top and base.
#declare cloudFn1 = function {
	pigment {
		spherical frequency -1
		colour_map {
			[baseVal rgb 0]
			[midVal rgb 1]
			[topVal rgb 0]
		}
	}
}

// Ridged fractal cloud density (could probably use granite or bozo or ...).
#declare cMax = 1+0.5+0.25+0.125+0.0625;		
#declare icMax = 1/cMax;		

#declare cloudFn3 = function {
	(abs(4*noise3d(x,y,z)-2)
		+0.5*abs(4*noise3d(x*3,y*3,z*3)-2)
		+0.25*abs(4*noise3d(x*9,y*9,z*9)-2)
		+0.125*abs(4*noise3d(x*27,y*27,z*27)-2)
		+0.0625*abs(4*noise3d(x*81,y*81,z*81)-2)
		-cMax
	)*icMax+0.5
}

// Put the cloud functions together.
#declare S = cloudTop/(5*cloudDepth);

#declare cloudFn = function {
	max(0,min(1,1-sqr(1-cloudFn1(x,y,z))+cloudFn3(x*S,y*S,z*S)-1))
}

// Produce a sort of shadowing function by a few point samples toward the light.
#declare sDel = 0.1*cloudDepth/cloudTop;
#declare LDX = sDel*lightDir.x;
#declare LDY = sDel*lightDir.y;
#declare LDZ = sDel*lightDir.z;

#declare cloudDel = function { 
	cloudFn(x,y,z)-
	max(
		cloudFn(x+LDX,y+LDY,z+LDZ),
		max(
			cloudFn(x+2*LDX,y+2*LDY,z+2*LDZ),
			max(
				cloudFn(x+3*LDX,y+3*LDY,z+3*LDZ),
				cloudFn(x+4*LDX,y+4*LDY,z+4*LDZ)
			)
		)
	)
}

// Cloud colours. Need tweaking.
#declare cCol1 = colour rgb 0.2*(2*lightCol*(1-0.1*atmCol)+atmCol) filter 0.8;
#declare cCol2 = colour rgb 0.2*(3*lightCol*(1-0.1*atmCol)+atmCol) filter 0.7;
#declare cCol3 = colour rgb 0.2*(5*lightCol*(1-0.1*atmCol)+atmCol) filter 0.6;
#declare cCol4 = colour rgb 0.2*(8*lightCol*(1-0.1*atmCol)+atmCol) filter 0.5;

// Pigment to fake a sun highlight for camera.
#declare sunPig = pigment { cylindrical poly_wave 3 scale 2
mAlign(camPos,camPos+lightDir) translate baseRad*y scale 1/cloudTop }

// Build a set of concentric spheres with the cloud function pigment.
#declare mSamples = 60;

union { 
	#declare sCnt = 0; #while ( sCnt < mSamples )
		#declare fCnt = sCnt/(mSamples-1);
		sphere { 0, fCnt+(1-fCnt)*(cloudBase/cloudTop) }
	#declare sCnt = sCnt + 1; #end
	pigment {
		function { cloudFn(x,y,z) }
		pigment_map {
			[0.0 colour rgbf 1]
			[0.5
				function { max(0,min(1,cloudDel(x,y,z)*5+0.5)) }
				pigment_map {
					[0   sunPig colour_map {[0 cCol1][1 cCol2]} ]
					[0.4 sunPig colour_map {[0 cCol2][1 cCol3]} ]
					[1   sunPig colour_map {[0 cCol3][1 cCol4]} ]
				}
			]
		}
	}
	finish { ambient 1 diffuse 0 }
	hollow
	scale cloudTop
	translate -baseRad*y
}
	
// Water from prevoius lake scene.
sphere { 0, grndRad
   texture {
      pigment {
         color rgb <80,90,94>/255.0
      }
      finish {
         diffuse 0.2
         ambient 0.05*<80,90,94>/94
         reflection_max 1.0*<80,90,94>/94
         reflection_min 0.4*<80,90,94>/94
         reflection_exponent 0.5
         specular 0.3
         roughness 0.001
         brilliance 0.01
         metallic 0.5
      }
      normal{
         bozo
         normal_map {
            [ 0.00 waves   0.050 translate -0.5 rotate -132 scale 1000*baseRad
frequency  500*baseRad]
            [ 0.70 ripples 0.025 translate -0.5 rotate  213 scale 1000*baseRad
frequency 1000*baseRad]
            [ 0.85 waves   0.015 translate -0.5 rotate  23  scale 1000*baseRad
frequency 1000*baseRad]
            [ 1.00 ripples 0.005 translate -0.5 rotate  73  scale 1000*baseRad
frequency 2000*baseRad]
         }
         scale 1/100
         scale 1/50
         warp { turbulence 1/5 octaves 2 lambda 5 omega 1/5 }
         warp { turbulence -1/5 octaves 2 lambda 5 omega 1/5 }
         scale 50
      }
   }
   translate -baseRad*y
}

// Land from previous lake scene.
#declare turbVal = 1/4;
#declare landLevel = 0.92;
height_field {
	pattern 400,400 {
		hf_gray_16
		average
		pigment_map
		{
			[1 
				cylindrical cubic_wave
				scale 0.5 translate <0.5,0,0.5>
				scale 10
				warp { turbulence 0.25 octaves 3 lambda 5 omega 1/5 }
				warp { turbulence 0.25 octaves 3 lambda 5 omega 1/5 }
				scale 1/10
		       	colour_map { [0 rgb 0][0.4 rgb 1] }
			]
			[1 
				cylindrical cubic_wave
				scale 0.5 translate <0.5,0,0.5>
				scale 10
				warp { turbulence 0.25 octaves 3 lambda 5 omega 1/5 }
				warp { turbulence 0.25 octaves 3 lambda 5 omega 1/5 }
				scale 1/10
				pigment_map {
					[0.41 rgb 0]
					[0.75
						planar cubic_wave
				       	scale 2 translate -y
				       	warp { turbulence turbVal octaves 3 lambda 3 omega 1/sqrt(3) }
				       	warp { turbulence turbVal octaves 3 lambda 3 omega 1/sqrt(3) }
				       	warp { turbulence turbVal octaves 3 lambda 3 omega 1/sqrt(3) }
				       	warp { turbulence turbVal octaves 3 lambda 3 omega 1/sqrt(3) }
				       	colour_map { [0.15 rgb 0.05][0.85 rgb 1] }
		    		   	scale 1/6
		    		]
		    	}
    		]
    	}
    }
    smooth
	texture {
		slope y
		texture_map {
			[landLevel-0.05
				pigment { 
					spotted frequency 4
					colour_map{
						[0.0 colour DarkBrown]
						[0.2 colour Gold]
						[0.2 colour Tan]
						[0.5 colour DarkBrown*0.7]
						[1.0 colour DarkBrown*1.2]
					}
					scale <4,20,4>
					warp { turbulence 1 }
					scale <10, 0.1, 10>
					rotate 23
					scale 10/(<20,2,20>*2)
				}
				normal { granite 0.05 scale 0.15 }
				finish {
					diffuse 0.4 specular 0.3 ambient 0.1*DarkBrown
					brilliance 1 roughness 0.5 metallic 
					reflection_max 0.4*DarkBrown reflection_min 0.1*DarkBrown
				}
			]
			[landLevel
				pigment { colour DarkBrown*0.5 }
				normal { granite 0.2 scale 0.5 }
				finish {
					diffuse 0.4 specular 0.2 ambient 0.05*DarkBrown 
					brilliance 0.1 roughness 0.1 metallic 
					reflection_max 0.25*DarkBrown reflection_min 0.05*DarkBrown
				}
			]
			[landLevel
				pigment { colour ForestGreen }
				normal { granite 0.1 scale 0.25 }
				finish {
					diffuse 0.7 specular 0 ambient 0.2*ForestGreen 
					reflection_max 0.6*ForestGreen reflection_min 0.2*ForestGreen
				}
			]
		}
	}
    translate -0.5
    scale <20,2,20>*2
    translate sqrt(grndRad*grndRad-20*2*0.4*20*2*0.4)*y
	rotate x*degrees(atan2(20*2*0.5,grndRad))
	translate -baseRad*y
}

-- 
Ken Tyler

See my 850+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

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