POV-Ray : Newsgroups : povray.beta-test : Cached Macros! : Re: Cached Macros! Server Time
27 Apr 2024 10:01:04 EDT (-0400)
  Re: Cached Macros!  
From: Yvo Smellenbergh
Date: 22 Jul 2016 05:20:37
Message: <5791e565@news.povray.org>
On 2016-07-19 23:16:48 +0000, clipka said:

> Ok, folks -- I've just submitted an update to the macro caching
> mechanism. The 64k (Windows) / 0.5k (Linux) buffer is now bypassed,
> further increasing the parsing speed of Thomas' demo scene on my machine
> from 60 to 50 seconds.
> 
> Please test intensively.

And on Macintosh:

- 3.7.0    
allInside: 32,957 sec 
allOutside: 96,369 sec  
rodOutsideRandInside:  481,025 sec  !! (8minutes)

- av155
allInside: 37,021 sec
allOutside:  36,480 sec
rodOutsideRandInside: 36,869 sec



Files used:

// Persistence of Vision Ray Tracer Scene Description File
// File: Clipka_cached macros_test.pov
// Vers: 3.7.1 Cached Macros version
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//

#version 3.7;

#include "colors.inc"
#declare allInside = 1;
#declare allOutside = 2;
#declare rodOutsideRandInside = 3;
#declare MacroType = allInside;

#if ( (MacroType = allInside) | (MacroType = rodOutsideRandInside))
	 #debug "\nRand inside"
	#macro VRand_In_Box(Mn, Mx, RS) (< rand(RS), rand(RS), 
rand(RS)>*(Mx-Mn) + Mn) #end
	#macro RRand(Min, Max, RS) (rand(RS)*(Max-Min) + Min) #end
	#macro VRand_In_Obj(Obj, RS)
    		#local Mn = min_extent(Obj);
   		 #local Mx = max_extent(Obj);
    		#local Pt = VRand_In_Box(Mn, Mx, RS);
    		#local J = 0;
   		 #while(inside(Obj, Pt) = 0 & J < 1000)
        		#local Pt = VRand_In_Box(Mn, Mx, RS);
        		#local J = J + 1;
    		#end
    	(Pt)
	#end
#end //if (MacroType = allInside || MacroType = rodOutsideRandInside)

#if (MacroType = allInside )
	 #debug "\nRod inside"
	#macro Rods()
	#ifndef(Box)	
		#declare Box =
		box {
  			<-10, 0, -10>,<10, 0.2, 10>
  			translate 10*y
		}
		#declare Rand = seed(1101);
	#end //#ifndef(Box)

	#declare Norm  = <0, 0, 0>;
	#declare Start = VRand_In_Obj(Box, Rand);
	#declare Pos   = trace (Surface, Start, -y, Norm);   

	#declare Cyl =
	cylinder {
 		 0, <0,1,0>, 0.05
 		 scale <1, RRand(0.5, 1.5, Rand), 1>
  		translate Pos
  		pigment {srgb <RRand(0.1, 0.9, Rand), RRand(0.1, 0.9, Rand), 
RRand(0.1, 0.9, Rand)>}
	}
	#end //	#macro Rods()
#end //#if (MacroType = allInside || MacroType = allOutside)

#if (MacroType = allOutside   | MacroType = rodOutsideRandInside)
	#include "rods.inc"
#end

global_settings {
  assumed_gamma 1.0
}

// ----------------------------------------

camera {
  location  <0.0, 5, -40.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 srgb <0.6,0.7,1.0>*1.3]
      [0.7 srgb <0.0,0.1,0.8>*1.3]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-3, 3, -3>*1000
}

// ----------------------------------------

#declare Surface =
plane {
  y, 0
  pigment { color srgb <0.7, 0.5, 0.3> }
}

object {Surface}



#declare I=0;

#for (I, 0, 1000000)
Rods()
object {Cyl}

#if (mod(I,10000) = 0)    
  #debug concat("\nRods: ", str(I,4,0)) 
#end 
#end



----------------------------------------------------------------------------------------------------------------------


//File: rods.inc

#if (MacroType = allOutside)
	 #debug "\nRand outside"

	#macro VRand_In_Box(Mn, Mx, RS) (< rand(RS), rand(RS), 
rand(RS)>*(Mx-Mn) + Mn) #end
	#macro RRand(Min, Max, RS) (rand(RS)*(Max-Min) + Min) #end
	#macro VRand_In_Obj(Obj, RS)
	    #local Mn = min_extent(Obj);
	    #local Mx = max_extent(Obj);
	    #local Pt = VRand_In_Box(Mn, Mx, RS);
	    #local J = 0;
	    #while(inside(Obj, Pt) = 0 & J < 1000)
	        #local Pt = VRand_In_Box(Mn, Mx, RS);
	        #local J = J + 1;
	    #end
	    (Pt)
	#end //#macro VRand_In_Obj(Obj, RS)
#end //#if (MacroType = allOutside)

#if (MacroType = allOutside | (MacroType = rodOutsideRandInside))
	 #debug "\nRod outside"
	#macro Rods()
		#ifndef(Box)
		#declare Box =
		box {
		  <-10, 0, -10>,<10, 0.2, 10>
		  translate 10*y
		}
		#declare Rand = seed(1101);
		#end
		
		#declare Norm  = <0, 0, 0>;
		#declare Start = VRand_In_Obj(Box, Rand);
		#declare Pos   = trace (Surface, Start, -y, Norm);   
		
		#declare Cyl =
		cylinder {
		  0, <0,1,0>, 0.05
		  scale <1, RRand(0.5, 1.5, Rand), 1>
		  translate Pos
		  pigment {srgb <RRand(0.1, 0.9, Rand), RRand(0.1, 0.9, Rand), 
RRand(0.1, 0.9, Rand)>}
		}
	#end	
#end
-- 
-------------------------------------------------------------------------------------------


POV-Ray 3.7 unofficial: http://megapov.inetart.net/povrayunofficial_mac/
UberPOV Mac: http://megapov.inetart.net/uberpov_mac/index.html#Mac
MegaPOV: http://megapov.inetart.net
E-mail: yvo(DOT)s(AT)gmx.net


Post a reply to this message


Attachments:
Download 'iso-8859-1' (17 KB)

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