/**********************************************************************************/ // Persistence of Vision Ray Tracer Scene Description File // File name : Iso-HF_test2.pov // Version : 3.6 / MegaPOV 1.21 // Description : A general code to illustrate the principle of the conversion HF <-> ISO // Date : 1 March 2006 / November 2006 // Author : Bruno Cabasson for the first macro; adapted by TdG for the second // E-mail : p.b.i. // Copyright (C) 2006. All rights reserved. /**********************************************************************************/ #include "colors.inc" #include "functions.inc" global_settings { assumed_gamma 1.0 //number_of_waves 1 } // ---------------------------------------- camera { location <0.0, 10, -30.0> direction 1.5*z right x*image_width/image_height look_at <0.0, 0.0, 0.0> } background {Gray10} light_source { <0, 0, 0> // light's position (translated below) color rgb <1, 1, 1> // light's color translate <-30, 30, -30>*100 } light_source { <0, 0, 0> // light's position (translated below) color rgb <1, 1, 1>*0.3 // light's color translate <30, 30, -30>*100 shadowless } //------------------------------------------------------------------------------------------------------------------------- //this macro scales the terrain forms along with the terrain size #macro IsoHF1(fn_Terrain,TERRAIN_SIZE_X,TERRAIN_SIZE_Z,TERRAIN_HEIGHT,RES) #declare ISO_Terrain = isosurface { function {y - TERRAIN_HEIGHT*fn_Terrain(x/TERRAIN_SIZE_X, 0, z/TERRAIN_SIZE_Z)} max_gradient 4 contained_by {box {<-TERRAIN_SIZE_X, 0, -TERRAIN_SIZE_Z>, }} } #declare HF_Terrain = height_field { function RES, RES {fn_Terrain ((x-0.5)*2, 0, -(y-0.5)*2)} smooth translate -x/2 -z/2 scale <2*TERRAIN_SIZE_X, TERRAIN_HEIGHT, 2*TERRAIN_SIZE_Z> } #end //------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------- //this macro leaves the terrain forms of the same size while scaling the terrain size #macro IsoHF2(fn_Terrain,TERRAIN_SIZE_X,TERRAIN_SIZE_Z,TERRAIN_HEIGHT,RES) #declare ISO_Terrain = isosurface { function {y - TERRAIN_HEIGHT*fn_Terrain(x, 0, z)} max_gradient 4 contained_by {box {<-TERRAIN_SIZE_X, -TERRAIN_HEIGHT, -TERRAIN_SIZE_Z>, }} } #declare HF_Terrain = height_field { function RES, RES {fn_Terrain ((x-0.5)*(TERRAIN_SIZE_X*2), 0, -(y-0.5)*(TERRAIN_SIZE_Z*2))} smooth translate -x/2 -z/2 scale <2*TERRAIN_SIZE_X, TERRAIN_HEIGHT, 2*TERRAIN_SIZE_Z> } #end //------------------------------------------------------------------------------------------------------------------------- #declare f_ripple = function {cos(sqrt(x*x+z*z))} #declare f_ripple_02 = function { pigment { ripples sine_wave color_map { [0. rgb 1] [0.5 rgb 0] //[1.0 rgb 1] } frequency 1.000 turbulence <0.300, 0.200, 0.300> octaves 10 lambda 1.000 scale <0.3000, 0.01000, 0.5000>*5 //translate 1000*x } } #declare Ripples=function {pattern {ripples frequency 1 warp {turbulence 0.5 octaves 1 omega 0.1 lambda 1} scale <1,0.1,1> translate <0, 0, 1000>}} #declare Waves=function {pattern {waves frequency 2 warp {turbulence 0.5 octaves 1 omega 0.1 lambda 1} scale 1.5 }} #declare fn_Terrain = function (x, y, z) { //Waves (x/5, 0, z/5) f_ripple_02 (x, 0, z).grey //f_wrinkles (x, 0, z)/1 //- Ripples (x/2, 0, z/5) //f_ripple(x,0,z) } // Or whatever in x-z plane. For functions in x-y plane (wood): f_wood(x, z, 0) IsoHF2(fn_Terrain,100,100,1,1000) // Superimpose the 2 versions to check they are close one to another object {ISO_Terrain pigment {Red transmit 0.5}} object {HF_Terrain pigment {Green transmit 0.5}}