1// This work is licensed under the Creative Commons Attribution 3.0 Unported License.
2// To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/
3// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View,
4// California, 94041, USA.
5//
6// Persistence Of Vision Ray Tracer ('POV-Ray') sample file.
7//
8// Aoi pattern example aoi.pov.
9//
10// +w800 +h800 +am2 +r4 +a0.1
11
12#version 3.8;
13global_settings { assumed_gamma 1 }
14#declare Black = srgb <0,0,0>;
15background { color Black }
16#declare CameraPerspective = camera {
17    perspective
18    location <2.7,2.7,-2.701>
19    sky <0,1,0>
20    angle 35
21    right x*(image_width/image_height)
22    look_at <0,0,0>
23}
24// orthographic so camera rays parallel +y toward x,z plane.
25#declare CameraOrthoY = camera {
26    orthographic
27    location <0,2,0>
28    direction <0,-1,0>
29    right 2.1*x*max(1,image_width/image_height)
30    up 2.1*<0,0,max(1,image_height/image_width)>
31}
32
33// First object a sphere at origin
34#declare Sphere00 = sphere { <0,0,0>, 0.5 }
35#declare Red = srgb <1,0,0>;
36#declare Azure = srgb <0,0.498,1>;
37// Azure in map to show values not seen with aoi pattern.
38#declare ColorMapSphere = color_map {
39 // blend_mode 2 blend_gamma 0.5 // Uncomment one of these for
40    blend_mode 2 blend_gamma 2.5 // fun with new 3.8 color_map
41 // blend_mode 2 blend_gamma 5.5 // blend_mode, blend_gamma.
42    [ 0 Azure ]
43    [ 0.49 Azure ]
44    [ 0.5 Black ]
45    [ 0.75 Red ]
46    [ 1 Black ]
47}
48#declare PigmentSphere = pigment {
49    aoi
50    color_map { ColorMapSphere }
51}
52#declare FinishEmission1 = finish {
53    ambient srgb <0,0,0>
54    diffuse 0
55    emission srgb <1,1,1>
56}
57#declare TextureSphere = texture {
58    pigment { PigmentSphere }
59    finish { FinishEmission1 }
60}
61#declare ObjectSphere = object {
62    Sphere00
63    texture { TextureSphere }
64}
65
66// Second object is a tiling pattern based isosurface.
67// Tiling normalization scalings are documented in tiling.pov example scene.
68#declare VarTiling21_NrmScale = <1/(1+sqrt(3)),1,1/(1+sqrt(3))>;
69#include "functions.inc"
70#declare FnTiling = function {
71    pattern {
72        tiling 21 sine_wave frequency 1/sqrt(2)
73        scale VarTiling21_NrmScale*0.5
74    }
75}
76#declare FnDisplaceYbyTiling = function (x,y,z) {
77    y+(FnTiling(x,y,z)*0.1)
78}
79#declare IsosurfaceTiling = isosurface {
80    function { FnDisplaceYbyTiling(x,y,z) }
81    contained_by { box { <-1,-0.2,-1>,<1,0.02,1> } }
82    threshold 0
83    accuracy 0.0005
84    max_gradient 1.1
85    max_trace 1
86}
87// Azure in map to show values not seen with aoi pattern.
88#declare ColorMapIsosurfaceTiling = color_map {
89    [ 0 Azure ]
90    [ 0.49 Azure ]
91    [ 0.5 Red ]
92    [ 1 Black ]
93}
94#declare PigmentIsosurfaceTiling = pigment {
95    aoi
96    color_map { ColorMapIsosurfaceTiling }
97}
98#declare TextureIsosurfaceTiling = texture {
99    pigment { PigmentIsosurfaceTiling }
100    finish { FinishEmission1 }
101}
102#declare ObjectIsosurfaceTiling = object {
103    IsosurfaceTiling
104    texture { TextureIsosurfaceTiling }
105}
106
107//---
108camera { CameraOrthoY }
109object { ObjectSphere }
110object { ObjectIsosurfaceTiling }
111
112// Use CameraPerspective over CameraOrthoY to better see shapes.
113// Note. Maximum gradient warning with CameraPerspective is expected.
114// camera { CameraPerspective }
115
116