require "Vector"
local V = Vector
+require "Colours"
+local C = Colours
+
local function make_phong_texture(lights, mapped_pigment, amb, diff, spec, shiny)
local normalize = V.normalize
end
end
+local function make_rainbow_pigment(scale)
+ return function (x,y)
+
+ local Ired = math.sin(x/math.pi/scale)^2 * math.sin(y/math.pi/scale)^2
+ local Igreen = math.cos(x/math.pi/scale)^2 * math.sin(y/math.pi/scale)^2
+ local Iblue = math.sin(x/math.pi/scale)^2 * math.cos(y/math.pi/scale)^2
+
+ return C.red*Ired + C.green*Igreen + C.blue*Iblue
+ end
+end
+
+
-- Mapping functions
-- These functions define mappings from 3D world coordinates to 2D
make_solid_pigment = make_solid_pigment,
make_checkered_pigment = make_checkered_pigment,
make_image_pigment = make_image_pigment,
+ make_rainbow_pigment = make_rainbow_pigment,
make_mandelbrot_pigment = make_mandelbrot_pigment,
map_rectangular = map_rectangular,
map_spherical = map_spherical