 		return OutputVertex(v: position, t: input.t, n: input.n, others: [])
 	}
 	
-	override func fragmentShader(_ p: InputFragment)-> Color{
-		let tex = textures["texture"]!
-		return (0,128,0)//tex[p.0, p.1].rgb
+	override func fragmentShader(_ input: InputFragment)-> Color {
+		return (textures["texture"]!)[input.t.0, input.t.1].rgb
 	}
 	
 }
+
+class NormalVisualizationProgram: Program {
+	
+	override func vertexShader(_ input: InputVertex) -> OutputVertex {
+		let position = matrices["mvp"]! * (input.v.0, input.v.1, input.v.2, 1.0)
+		return OutputVertex(v: position, t: input.t, n: input.n, others: [])
+	}
+	
+	override func fragmentShader(_ input: InputFragment)-> Color {
+		let col = normalized(input.n)*Scalar(0.5)+(0.5,0.5,0.5)
+		return (UInt8(255.0 * col.0), UInt8(255.0 * col.1), UInt8(255.0 * col.2))
+	}
+	
+}
+
+

		return OutputVertex(v: position, t: input.t, n: input.n, others: [])
	}
	
	override func fragmentShader(_ input: InputFragment)-> Color{
		//let col = normalized(input.n)*Scalar(0.5)+(0.5,0.5,0.5)
		//return (UInt8(255.0 * col.0), UInt8(255.0 * col.1), UInt8(255.0 * col.2))
		return (textures["texture"]!)[input.t.0, input.t.1].rgb
	}
	

	fileprivate var scalars: [String : Scalar] = [:]
	
	
	func vertexShader(_ input: InputVertex) -> OutputVertex { fatalError("Must Override") }
	
	func fragmentShader(_ input: InputFragment) -> Color? { fatalError("Must Override") }
	
	func register(name: String, value: Texture) { textures[name] = value }
	
