' '

Difficulty

3

Prerequisites

patterns/lambda

The goal of this extension is to replicate these results (a spiral pattern) without help. You can try to solve this extension partially for partial rewards.

1. Spiral Thickness

The thickness of the spiraling arm must be settable.

var t = Animations.animate(0.1, 0.4, seconds(3))[now]
spiral([ "thickness": t ])

2. Arm Count

We should be able to choose the number of arms.

spiral([ "thickness": 0.1, "arms": arms ])
arms Result

1

arms1

2

arms2

3

arms3

4

arms4

3. Spacing

The spacing between arms must be a parameter too.

spiral([ "thickness": 0.1, "spacing": spacing ])

4. Evaluation

Render the following scene:

def scene_at(now)
{
	var camera = Cameras.perspective( [ "eye": pos(0,0,10),
	                                    "look_at": pos(0,0,0) ] )

	var white = Materials.uniform( [ "ambient": Colors.white() ] )
	var black = Materials.uniform( [ "ambient": Colors.black() ] )

	var t = Animations.animate(0.1, 0.4, seconds(3))[now]
	var pattern = Patterns.spiral(["thickness": t])
	var mat = Materials.from_pattern(pattern, white, black)

	var root = decorate(mat, xy_plane())

	var lights = [ Lights.omnidirectional( pos(5,5,5), Colors.white() ) ]

	create_scene(camera, root, lights)
}

var raytracer = Raytracers.v1()

var renderer = Renderers.standard( [ "width": 500,
                                     "height": 500,
                                     "sampler": Samplers.single(),
                                     "ray_tracer": raytracer ] )

pipeline( scene_animation(scene_at, seconds(5)),
          [ Pipeline.animation(30),
            Pipeline.renderer(renderer),
            Pipeline.wif(),
            Pipeline.base64(),
            Pipeline.stdout() ] )

Render the following scene:

def scene_at(now)
{
	var camera = Cameras.perspective( [ "eye": pos(0,0,10),
	                                    "look_at": pos(0,0,0) ] )

	var white = Materials.uniform( [ "ambient": Colors.white() ] )
	var black = Materials.uniform( [ "ambient": Colors.black() ] )

	var t = Animations.animate(0.1, 0.4, seconds(3))[now]
	var pattern = Patterns.spiral(["thickness": t, "arms": 5])
	var mat = Materials.from_pattern(pattern, white, black)

	var root = decorate(mat, xy_plane())

	var lights = [ Lights.omnidirectional( pos(5,5,5), Colors.white() ) ]

	create_scene(camera, root, lights)
}

var raytracer = Raytracers.v1()

var renderer = Renderers.standard( [ "width": 500,
                                     "height": 500,
                                     "sampler": Samplers.single(),
                                     "ray_tracer": raytracer ] )

pipeline( scene_animation(scene_at, seconds(3)),
          [ Pipeline.animation(30),
            Pipeline.renderer(renderer),
            Pipeline.wif(),
            Pipeline.base64(),
            Pipeline.stdout() ] )

Render the following scene:

def scene_at(now)
{
	var camera = Cameras.perspective( [ "eye": pos(0,0,10),
	                                    "look_at": pos(0,0,0) ] )

	var white = Materials.uniform( [ "ambient": Colors.white() ] )
	var black = Materials.uniform( [ "ambient": Colors.black() ] )

	var s = Animations.animate(1, 5, seconds(3))[now]
	var pattern = Patterns.spiral(["thickness": 0.1, "spacing": s])
	var mat = Materials.from_pattern(pattern, white, black)

	var root = decorate(mat, xy_plane())

	var lights = [ Lights.omnidirectional( pos(5,5,5), Colors.white() ) ]

	create_scene(camera, root, lights)
}

var raytracer = Raytracers.v1()

var renderer = Renderers.standard( [ "width": 500,
                                     "height": 500,
                                     "sampler": Samplers.single(),
                                     "ray_tracer": raytracer ] )

pipeline( scene_animation(scene_at, seconds(3)),
          [ Pipeline.animation(30),
            Pipeline.renderer(renderer),
            Pipeline.wif(),
            Pipeline.base64(),
            Pipeline.stdout() ] )