Skip to content
Jérôme Grimbert edited this page Jun 9, 2014 · 2 revisions

Hgpovray


Pattern

Natural

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.

Masonry pattern

#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 }

Voronoi

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

Syntax is :

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

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 could be a duplicate value of a previous one in the list.

Voronoi pattern

#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 }

With object

Proximity

#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 } ]
    }
  }
}

Proximity

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).

With objects

Proportion and Binary

binary { OBJECT_LIST } [ PATTERN_MODIFIERS ]
proportion { OBJECT_LIST } [ PATTERN_MODIFIERS ]
OBJECT_LIST = Object_Description [ OBJECT_LIST ]

Binary

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).

Proportion

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.

Clone this wiki locally