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