
import defaultRenderPass from '../defaultRenderPass.js';
import sampler2D from '../sampler2D.js';
import shader from '../shader.js';

class convolution extends defaultRenderPass {

	prepare() {
		
		var randomTexure = kepler.resources.getTexture("rotrandom.png");
		var randomSampler = new sampler2D();
		randomSampler.addTexture(randomTexure);
		
		this.shader = new shader();
		this.shader.createFromFile("shaders/convolution.shader");

		this.shader.setUniform("random", randomSampler );
		
	}
	
	setDirection( direction ) {
		
		if(direction == "Horizontal") {
			
			this.shader.setUniform("imageIncrement", [1 / this.width, 0] );
			
		} else {
			
			this.shader.setUniform("imageIncrement", [0, 1 / this.height] );
			
		}
		
	}

}

export {convolution as default};