function render(elapsed){
	var light_sliders = new Vec3f(light_slider_x.value / 5 - 5,
			light_slider_y.value / 5 - 5, light_slider_z.value / 5 - 5);
	if (!light.pos.equal(light_sliders)){
		light.pos = light_sliders;
		raytrace = buildSceneShader();
		sample_pass = 0;
	}
	var target = sample_pass % 2 == 0 ? 0 : 1;
	var prev_tex = (target + 1) % 2;

	gl.useProgram(raytrace);
	var rays = perspectiveCamera(eye_pos, new Vec3f(0, 0, 0), new Vec3f(0, 1, 0), 60.0, WIDTH / HEIGHT);
	for (var i = 0; i < 4; ++i){
		var vals = rays[i].flatten();
		gl.uniform3fv(ray_unifs[i], rays[i].flatten());
	}

	gl.bindTexture(gl.TEXTURE_2D, textures[prev_tex]);
	gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffers[target]);
	gl.uniform1f(sample_unif, sample_pass);
	gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);

	gl.bindFramebuffer(gl.FRAMEBUFFER, null);
	gl.bindTexture(gl.TEXTURE_2D, textures[target]);
	gl.useProgram(textured_quad);
	gl.clearColor(0.0, 0.0, 0.0, 1.0);
	gl.clear(gl.COLOR_BUFFER_BIT);
	gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);

	++sample_pass;
}
// elapsed contains the time elapsed in seconds
elapsed contains the time elapsed in seconds
elapsed contains the time elapsed in seconds
function render(elapsed){
	var light_sliders = new Vec3f(light_slider_x.value / 5 - 5,
			light_slider_y.value / 5 - 5, light_slider_z.value / 5 - 5);
	if (!light.pos.equal(light_sliders)){
		light.pos = light_sliders;
		raytrace = buildSceneShader();
		sample_pass = 0;
	}
	var target = sample_pass % 2 == 0 ? 0 : 1;
	var prev_tex = (target + 1) % 2;
	gl.useProgram(raytrace);
	var rays = perspectiveCamera(eye_pos, new Vec3f(0, 0, 0), new Vec3f(0, 1, 0), 60.0, WIDTH / HEIGHT);
	for (var i = 0; i < 4; ++i){
		var vals = rays[i].flatten();
		gl.uniform3fv(ray_unifs[i], rays[i].flatten());
	}
	gl.bindTexture(gl.TEXTURE_2D, textures[prev_tex]);
	gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffers[target]);
	gl.uniform1f(sample_unif, sample_pass);
	gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
	gl.bindFramebuffer(gl.FRAMEBUFFER, null);
	gl.bindTexture(gl.TEXTURE_2D, textures[target]);
	gl.useProgram(textured_quad);
	gl.clearColor(0.0, 0.0, 0.0, 1.0);
	gl.clear(gl.COLOR_BUFFER_BIT);
	gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
	++sample_pass;
}
function render ( elapsed ) { var light_sliders = new Vec3f ( light_slider_x . value / 5 - 5 , light_slider_y . value / 5 - 5 , light_slider_z . value / 5 - 5 ) ; if ( ! light . pos . equal ( light_sliders ) ) { light . pos = light_sliders ; raytrace = buildSceneShader ( ) ; sample_pass = 0 ; } var target = sample_pass % 2 == 0 ? 0 : 1 ; var prev_tex = ( target + 1 ) % 2 ; gl . useProgram ( raytrace ) ; var rays = perspectiveCamera ( eye_pos , new Vec3f ( 0 , 0 , 0 ) , new Vec3f ( 0 , 1 , 0 ) , 60.0 , WIDTH / HEIGHT ) ; for ( var i = 0 ; i < 4 ; ++ i ) { var vals = rays [ i ] . flatten ( ) ; gl . uniform3fv ( ray_unifs [ i ] , rays [ i ] . flatten ( ) ) ; } gl . bindTexture ( gl . TEXTURE_2D , textures [ prev_tex ] ) ; gl . bindFramebuffer ( gl . FRAMEBUFFER , framebuffers [ target ] ) ; gl . uniform1f ( sample_unif , sample_pass ) ; gl . drawArrays ( gl . TRIANGLE_STRIP , 0 , 4 ) ; gl . bindFramebuffer ( gl . FRAMEBUFFER , null ) ; gl . bindTexture ( gl . TEXTURE_2D , textures [ target ] ) ; gl . useProgram ( textured_quad ) ; gl . clearColor ( 0.0 , 0.0 , 0.0 , 1.0 ) ; gl . clear ( gl . COLOR_BUFFER_BIT ) ; gl . drawArrays ( gl . TRIANGLE_STRIP , 0 , 4 ) ; ++ sample_pass ; }
elapsed contains the time elapsed in seconds
elapsed contains the time elapsed in seconds