#####################################################
#                                                   #
#   HEADER                                          #
#                                                   #
#####################################################

header {
	title: AMATATA
	width: 1280
	height: 720	
	music: halaproxy2010.ogg
	bpm: 140.0
}

#####################################################
#                                                   #
#    OBJECTS                                        #
#                                                   #
#####################################################

textures {
	*glowX {
		width: 320
		height: 180
		wrap: clamp
	}
	*glow {
		width: 320
		height: 180
		wrap: clamp
	}
}

objects {
	cam: camera {
	}
	env: enviroment {
		lighting: 0
	}
	srcImg1: image fist.jpg {
		stretch: yes
	}
	srcImg2: image noise.jpg {
		blend: blend::screen
		stretch: yes
	}
	srcImg3: image title.jpg {
		blend: blend::alpha
		stretch: yes
	}
	lines2d: Lines/lines2D
	imgFeedback: image *glow {
		stretch: yes
		blend: blend::screen
		col.a: 0.6
		zoom: 0.01
		shader: tv.shader
	}
	imgGlowX: image *buf {
		stretch: 1
		shader: blurx.shader
		shader0.blur: 10
		shader0.pixel: 0.0015625
	}		
	imgGlowY: image *glowX {
		stretch: 1
		shader: blury.shader
		shader0.blur: 10
		shader0.pixel: 0.0027778
	}		
	imgGlow: image *glow {
		stretch: yes
		blend: blend::screen
	}
	imgOut: image *mix {
		shader: tv.shader
	}
}

#####################################################
#                                                   #
#    RENDER PASSES                                  #
#                                                   #
#####################################################

textures {
}

renderPasses {
	src {
		objects: srcImg1, srcImg2, srcImg3
		output: *src
	}
	main {
		objects: lines2d, imgFeedback
		output: *buf
	}
	glowx {
		objects: imgGlowX
		output: *glowX
	}
	glowy {
		objects: imgGlowY
		output: *glow
	}
	mix {
		objects: imgGlow, lines2d
		output: *mix
	}
	out {
		objects: imgOut
	}
}

#####################################################
#                                                   #
#    SCRIPT                                         #
#                                                   #
#####################################################

script {
	@0.0 enable lines2d, cam, env, imgGlowX, imgGlowY, imgGlow, imgFeedback, imgOut, srcImg1, srcImg2, srcImg3
	
	@0.0 lines2d.foo = 0 to 5 in @32.0
	@32.0 lines2d.foo = 10 to 0 in @32.0
	@80.0 lines2d.foo = 0 to 1 in @16.0
	
	@0.0 lines2d.zoom = -1 to 1 in @96.0
	
	@0.0 lines2d.mix = eval( " 0.5 + sin( time * time * 0.0000000001 ) * 0.6" ) for @4.0
	@4.0 loop @2.0 6 times {
		@0.0 lines2d.mix = rand(-0.25 to 0.25)
		@1.3.9 lines2d.mix = rand(-1 to 1) for @0.0.1
	}
	@16.0 loop @1.0 16 times {
		@0.0 lines2d.mix = rand(-0.5 to 0.5)
		@0.3.9 lines2d.mix = rand(-1 to 1) for @0.0.1
	}
	@32.0 loop @2.0 8 times {
		@0.0 lines2d.mix = rand(-0.75 to 0.75)
		@1.3.9 lines2d.mix = rand(-1 to 1) for @0.0.1
	}
	@48.0 loop @1.0 16 times {
		@0.0 lines2d.mix = rand(-1 to 1)
		@0.3.9 lines2d.mix = rand(-1 to 1) for @0.0.1
	}
	@64.0 loop @0.2 64 times {
		@0.0 lines2d.mix = rand(-1 to 1)
	}
	
	
	@0.0 imgOut.shader0.rgbfuck = rand( 0 to 25 ) for @96.0
	@0.0 imgFeedback.shader0.rgbfuck = rand( 0 to 1 ) for @96.0
	
	@0.0 srcImg2.col.r = eval( " 0.8 + sin ( time * 0.001 ) * 0.2" ) for @96.0
	@0.0 srcImg2.col.g = eval( " 0.8 + sin ( time * 0.0012 ) * 0.2" ) for @96.0
	@0.0 srcImg2.col.b = eval( " 0.8 + sin ( time * 0.0013 ) * 0.2" ) for @96.0
	@0.0 srcImg2.col.a = eval( " 0.05 + sin ( time * 0.0014 ) * 0.05" ) for @96.0
	@0.0 srcImg2.offset.x = rand( 0 to 1 ) for @96.0
	
	0.0 srcImg3.col.r = 0 to 1 in 1.0
	0.0 srcImg3.col.g = 0 to 1 in 2.0
	0.0 srcImg3.col.b = 0 to 1 in 3.0
	5.0 srcImg3.col.a = 1 to 0 in 1.0

	@32.0 srcImg3.col.a = 0 to 1 in @64.0
	@32.0 srcImg3.col.r = 1 to 0 in @62.0
	@32.0 srcImg3.col.g = 1 to 0 in @60.0
	@32.0 srcImg3.col.b = 1 to 0 in @58.0
	
	@96.0 srcImg1.col.a = 0
	@96.0 srcImg2.col.a = 0
	@96.0 srcImg3.col.a = 0
		
	@100.0 end
}
