User:Le Forgeron/patterns

From POV-Wiki
Jump to navigation Jump to search

proximity pattern

#declare test_object = 
  julia_fractal {
    <0.1,0.8,-0.1,0.002> quaternion sqr
    max_iteration 8
    precision 1000
    scale 60 translate y*60 rotate y*45
}

object {  test_object
  texture {
    proximity { test_object } radius 10
    texture_map {
      [ 0.0 pigment { rgb <0,169,224>/255 } ]
      [ 0.2 pigment { rgb <50,52,144>/255 } ]
      [ 0.4 pigment { rgb <234,22,136>/255 } ]
      [ 0.6 pigment { rgb <235,46,46>/255 } ]
      [ 0.8 pigment { rgb <253,233,45>/255 } ]
      [ 1.0 pigment { rgb <0,158,84>/255 } ]
    }
  }
}

LeForgeronProximity.png

proximity { Object_Description } [ PATTERN_MODIFIER | radius Radius_of_Sampling ]...

The default radius of sampling is 1.0. A weighted sampling is performed inside the sphere around the intersection, returning a value between 0.0 (all insideness tests failed) and 1.0 (all tests succeed). Usual value (for flat surface) would be around 0.5, edge of box dropping to 0.25 and corners of box to 0.125 (1/8 of the sphere).

patterns with list of objects

binary { OBJECT_LIST } [ PATTERN_MODIFIERS ]

proportion { OBJECT_LIST } [ PATTERN_MODIFIERS ]

OBJECT_LIST = Object_Description [ OBJECT_LIST ]

LeForgeronProportionAndBinary.png

proportion pattern

For a list of N objects, perform an insideness test for each of them and compute a number k/N, where k is the number of success for insideness test.

binary pattern

Take into account the position of the object in the list to weight it.

As for proportion, it use insideness testing. but the contribution of the k-th object is 1/(2^k).

The value is 1 if all tests succeed, and has a lower limit of 1/(2^N) (which tends to 0 very rapidly).

Patterns like crackle

voronoi

voronoi pattern with points specified in the SDL (no randomness).

Syntax is :

voronoi { <pt1>,<pt2>, .... <ptN> }

<ptX> is a 3D vector

Number of points must be at least 2, but the number does not have to be provided.

For N points, returns in the range 0 to 1 the value k/(N-1) where k is ordinal of the first point with the smallest distance (first := 0, last := N-1 )

  • first point, because any <ptX> could be a duplicate value of a previous one in the list.

LeForgeronVoronoi.png

#version 3.7;
global_settings{ assumed_gamma 1.0 }

#declare seeds=seed(33);
#include "colors.inc"
background { Aquamarine }

#declare Tex= texture { voronoi { 
#for(zx,-15,15,7.5)
#for(zy,-15,15,7.5)
#for(zz,-15,15,7.5)
#if (rand(seeds)<0.15)
	<zx, zy, zz >,
#end
#end
#end
#end
}
texture_map{
	[0.0 pigment { color Blue } ]
		[0.3 pigment { color Cyan } ]
		[0.5 pigment { color Green } ]
		[0.7 pigment { color Yellow } ]
		[1.0 pigment { color Red } ]
}
} 

difference { superellipsoid { <0.025,0.025> scale 10 } 
box { <-3,-3,-11>,<3,3,11>  rotate -10*z}
box { <-11,-4,-4>,<11,4,4>  rotate -20*x}
box { <-5,-11,-5>,<5,11,5> rotate 30*y}

texture { Tex scale 6/11}
}
camera { location 50*y+060*x-100*z direction z up y right image_width/image_height*x look_at <0,0,0> angle 20 }


light_source { <-4,8,-2>*100, 1 area_light 40*x,40*z, 7,7 circular orient }
light_source { <4,8,-2>*100, 3/4 area_light 40*x,40*z, 7,7 circular orient }
light_source { <4,80,-2>*100, 1/2 area_light 40*x,40*z, 7,7 circular orient }

masonry

masonry pattern with points & map value specified in the SDL (no randomness): think crackle pattern, with seam, under absolut control of the SDL

Syntax is:

masonry <3D-vector> { <4D-pt1>,<4D-pt2>,...<4D-ptN> }
3D-vector.x
width of the seam (in absolut pov unit) between any adjacent cells
3D-vector.y
value of map at the very center of the seam
3D-vector.z
value of map at the transition between a cell and the seam
linear interpolation along the seam does happen
Each 4D-pt vector
the 3D point, seed of the voronoi cell, expanded with the value on the map to be return for the whole cell.

if two adjacent cells have the same value, the seam between them is removed, allowing to make concave cell.

LeForgeronMasonry.png

#version 3.7;
global_settings{ assumed_gamma 1.0 }

#declare seeds=seed(33);
#include "colors.inc"
background { Aquamarine }

#declare Tex= texture { masonry <0.2,1,0.99> { 
#for(zx,-15,15,1)
#for(zy,-15,15,1)
#for(zz,-15,15,1)
#if (rand(seeds)< 0.01250)
	<zx, zy, zz ,(rand(seeds)*0.98)>,
#end
#end
#end
#end
}
texture_map{
	[0.0 pigment { color Blue } ]
		[0.3 pigment { color Cyan } ]
		[0.5 pigment { color Green } ]
		[0.7 pigment { color Yellow } ]
		[0.99 pigment { color Magenta } ]
		[0.990 pigment { color White } ]
		[0.994 pigment { color White } ]
		[0.998 pigment { color Red } ]
		[1.0 pigment { color Red } ]
}
} 

difference { superellipsoid { <0.025,0.025> scale 10 } 
box { <-3,-3,-11>,<3,3,11>  rotate -10*z}
box { <-11,-4,-4>,<11,4,4>  rotate -20*x}
box { <-5,-11,-5>,<5,11,5> rotate 30*y}

texture { Tex scale 6/11}
}
camera { location 50*y+060*x-100*z direction z up y right image_width/image_height*x look_at <0,0,0> angle 20 }


light_source { <-4,8,-2>*100, 1 area_light 40*x,40*z, 7,7 circular orient }
light_source { <4,8,-2>*100, 3/4 area_light 40*x,40*z, 7,7 circular orient }
light_source { <4,80,-2>*100, 1/2 area_light 40*x,40*z, 7,7 circular orient }


LeForgeronMasonry2.png

#version 3.7;
global_settings{ assumed_gamma 1.0 }

#declare seeds=seed(33);
#include "colors.inc"
background { Aquamarine }
camera { location 50*y+060*x-100*z
direction z
up y
right image_width/image_height*x
look_at <0,0,0>
angle 20
}


light_source { <-4,8,-2>*100, 1 
area_light 40*x,40*z, 7,7 circular orient
}
light_source { <4,8,-2>*100, 3/4 
area_light 40*x,40*z, 7,7 circular orient 
}
light_source { <4,80,-2>*100, 1/2 
area_light 40*x,40*z, 7,7 circular orient 
}

#declare Tex=
 texture {
masonry <0.05,1,0.999> { 
#for(ty,-10,10,1)
#local k=rand(seeds)*0.98;
#local k2=rand(seeds)*0.98;
#local k3=rand(seeds)*0.98;
#for(tx,0,359,7.5)
#local zy=ty;
#local zx= 4.5*cos(radians(tx+7.5*ty))-12;
#local zz= 4.5*sin(radians(tx+7.5*ty));

#local ax= 4.5*cos(radians(tx+7.5*ty))+7;
#local ay= 4.5*sin(radians(tx+7.5*ty));
#local az= ty;
#local bx= 3.5*cos(radians(tx+7.5+7.5*ty))+7;
#local by= 3.5*sin(radians(tx+7.5+7.5*ty));
#local bz= ty;
#if (0=mod(tx,15))
#local k=rand(seeds)*0.98;
#local k2=rand(seeds)*0.98;
#local k3=rand(seeds)*0.98;
#end
<zx, zy, zz ,k>,
<-zx,zy,zz,k2>,
//#if (abs(ty)>=3)
<ax,ay,az,k3>,
<bx,by,bz,k>,
//#end
#end
#end
}
texture_map{
[0.0 pigment { color Red } ]
[0.99 pigment { color IndianRed } ]
[0.990 pigment { color White } ]
[0.994 pigment { color White } ]
[0.999 pigment { color Black } ]
[1.0 pigment { color White } ]
}
} 
difference{
union {
cylinder { <-12,-10,0>,<-12,10,0>,5}
cylinder { <12,-10,0>,<12,10,0>,5}
cylinder { <7,0,-10>,<7,0,10>,5}
}
cylinder { <-12,-11,0>,<-12,11,0>,3}
cylinder { <12,-11,0>,<12,11,0>,3}
cylinder { <7,0,-11>,<7,0,11>,3}
texture { Tex }
}