1// This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
2// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a
3// letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
4
5// Persistence of Vision Ray Tracer Scene Description File
6// File: gamma_showcase.pov
7// Vers: 3.7
8// Desc: Gamma Handling Test Scene - An arrangement of spheres on a marble plane
9// Date: 2010-12-21
10// Auth: Christoph Lipka
11//
12
13// +w640 +h480 +a0.3 +am1 +fN -d File_Gamma=sRGB Output_File_Name=gamma_showcase.png
14// +w640 +h480 +a0.3 +am1 +fN -d File_Gamma=1.0  Output_File_Name=gamma_showcase_linear.png
15// +w320 +h240 +a0.3 +am1 +fN -d File_Gamma=sRGB Output_File_Name=gamma_showcase_ref0.png Declare=Stripes=off
16// +w320 +h240 +a0.3 +am1 +fN -d File_Gamma=sRGB Output_File_Name=gamma_showcase_ref1.png Declare=Stripes=off Declare=Gamma=1.2
17// +w320 +h240 +a0.3 +am1 +fN -d File_Gamma=sRGB Output_File_Name=gamma_showcase_ref2.png Declare=Stripes=off Declare=Gamma=0.8
18// +w640 +h480 +a0.3 +am1 -f +d
19
20#version 3.7;
21
22#include "colors.inc"
23#include "stones.inc"
24
25#ifndef (Stripes)
26  #declare Stripes = on;
27#end
28#ifndef (Gamma)
29  #declare Gamma   = 1.0;
30#end
31
32global_settings {
33  max_trace_level 5
34  assumed_gamma 1.0
35  radiosity {
36    pretrace_start 0.08
37    pretrace_end   0.01
38    count 35
39    nearest_count 5
40    error_bound 1.8
41    recursion_limit 2
42    low_error_factor .5
43    gray_threshold 0.0
44    minimum_reuse 0.015
45    brightness 1
46    adc_bailout 0.01/2
47  }
48}
49
50#default {
51  texture {
52    pigment {rgb 1}
53    finish {
54      ambient 0.0
55      diffuse 0.6
56      specular 0.6 roughness 0.001
57      reflection { 0.0 1.0 fresnel on }
58      conserve_energy
59    }
60  }
61}
62
63// ----------------------------------------
64
65#local TestRed   = rgb <0.5,0.1,0.1>;
66#local TestGreen = rgb <0.1,0.5,0.1>;
67#local TestBlue  = rgb <0.1,0.1,0.5>;
68
69#local CameraFocus = <0,0.5,0>;
70#local CameraDist  = 8;
71#local CameraDepth = 1.8;
72#local CameraTilt  = 20;
73
74camera {
75  location  <0,0,0>
76  direction z*CameraDepth
77  right     x*image_width/image_height
78  up        y
79  translate <0,0,-CameraDist>
80  rotate    x*CameraTilt
81  translate CameraFocus
82}
83
84#macro LightSource(Pos,Color)
85  light_source {
86    Pos
87    color Color
88    spotlight
89    point_at <0,0,0>
90    radius  175/vlength(Pos)
91    falloff 200/vlength(Pos)
92    area_light x*vlength(Pos)/10, y*vlength(Pos)/10, 9,9 adaptive 1 jitter circular orient
93  }
94
95#end
96
97LightSource(<-500,500,-500>,TestRed   + <0.2,0.2,0.2>)
98LightSource(<   0,500,-500>,TestGreen + <0.2,0.2,0.2>)
99LightSource(< 500,500,-500>,TestBlue  + <0.2,0.2,0.2>)
100
101// ----------------------------------------
102
103#macro DarkStripeBW(TargetBrightness)
104  #if (TargetBrightness < 0.5)
105    (0.0)
106  #else
107    (TargetBrightness*2 - 1.0)
108  #end
109#end
110
111#macro BrightStripeBW(TargetBrightness)
112  #if (TargetBrightness < 0.5)
113    (TargetBrightness*2)
114  #else
115    (1.0)
116  #end
117#end
118
119#macro DarkStripeRGB(TargetColor)
120  <DarkStripeBW(TargetColor.red),DarkStripeBW(TargetColor.green),DarkStripeBW(TargetColor.blue)>
121#end
122
123#macro BrightStripeRGB(TargetColor)
124  <BrightStripeBW(TargetColor.red),BrightStripeBW(TargetColor.green),BrightStripeBW(TargetColor.blue)>
125#end
126
127#macro StripedPigment(TargetColor)
128  #if (Stripes)
129    function { abs(mod(abs(image_height*CameraDepth*y/z+0.5),2.0)-1.0) }
130    color_map {
131      [0.5 color rgb DarkStripeRGB(TargetColor) ]
132      [0.5 color rgb BrightStripeRGB(TargetColor) ]
133    }
134    translate <0,0,-CameraDist>
135    rotate x*CameraTilt
136    translate CameraFocus
137  #else
138    color TargetColor
139  #end
140#end
141
142
143plane {
144  y, 0
145  texture { T_Stone11 }
146  interior { ior 1.5 }
147}
148
149#macro GammaAdjust(C,G)
150  #local C2 = color rgbft <pow(C.red,G),pow(C.green,G),pow(C.blue,G),pow(C.filter,G),pow(C.transmit,G)>;
151  (C2)
152#end
153
154#macro TestSphere(Pos,Radius,TargetColor,Split)
155  sphere {
156    Pos + y*Radius, Radius
157    texture { pigment { color GammaAdjust(TargetColor,Gamma) } }
158    interior { ior 1.5 }
159  }
160  #if (Split)
161    sphere {
162      Pos + y*Radius + x*0.001, Radius
163      texture { pigment { StripedPigment(TargetColor) } }
164      interior { ior 1.5 }
165    }
166  #end
167#end
168
169TestSphere(<-2,0,1>, 1, TestRed,   true)
170TestSphere(< 0,0,1>, 1, TestGreen, true)
171TestSphere(< 2,0,1>, 1, TestBlue,  true)
172
173#local Steps = 6;
174#for(I,0,1,1/Steps)
175  #if (I < 0.5)
176    #local Color2 = TestRed;
177  #else
178    #local Color2 = TestBlue;
179  #end
180  #local P = abs(I-0.5)*2;
181  TestSphere(<I*4-2,0,-0.5>, 2/Steps, (1-P)*TestGreen + P*Color2, true)
182#end
183
184#local Steps = 8;
185#for(I,0,1,1/Steps)
186  TestSphere(<I*4-2,0,-1.5>, 2/Steps, rgb I, true)
187  TestSphere(<I*4-2,0,-2.0>, 2/Steps, GammaAdjust(rgb I, 2.2*Gamma), false)
188#end
189