Implement Bitmap 'blur'
I was a bit confused at first because I thought Enterbrain had actually implemented a full Gaussian blur, but nope, just dumb averaging.
This commit is contained in:
		
							parent
							
								
									20ec560145
								
							
						
					
					
						commit
						a54acce6b7
					
				
					 10 changed files with 149 additions and 1 deletions
				
			
		
							
								
								
									
										16
									
								
								shader/blur.frag
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								shader/blur.frag
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
 | 
			
		||||
uniform sampler2D texture;
 | 
			
		||||
 | 
			
		||||
varying vec2 v_texCoord;
 | 
			
		||||
varying vec2 v_blurCoord[2];
 | 
			
		||||
 | 
			
		||||
void main()
 | 
			
		||||
{
 | 
			
		||||
	vec4 frag = vec4(0, 0, 0, 0);
 | 
			
		||||
 | 
			
		||||
	frag += texture2D(texture, v_texCoord);
 | 
			
		||||
	frag += texture2D(texture, v_blurCoord[0]);
 | 
			
		||||
	frag += texture2D(texture, v_blurCoord[1]);
 | 
			
		||||
 | 
			
		||||
	gl_FragColor = frag / 3.0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								shader/blurH.vert
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								shader/blurH.vert
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
 | 
			
		||||
uniform mat4 projMat;
 | 
			
		||||
 | 
			
		||||
uniform vec2 texSizeInv;
 | 
			
		||||
 | 
			
		||||
attribute vec2 position;
 | 
			
		||||
attribute vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
varying vec2 v_texCoord;
 | 
			
		||||
varying vec2 v_blurCoord[2];
 | 
			
		||||
 | 
			
		||||
void main()
 | 
			
		||||
{
 | 
			
		||||
	gl_Position = projMat * vec4(position, 0, 1);
 | 
			
		||||
 | 
			
		||||
	v_texCoord = texCoord * texSizeInv;
 | 
			
		||||
	v_blurCoord[0] = vec2(texCoord.x-1, texCoord.y) * texSizeInv;
 | 
			
		||||
	v_blurCoord[1] = vec2(texCoord.x+1, texCoord.y) * texSizeInv;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								shader/blurV.vert
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								shader/blurV.vert
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
 | 
			
		||||
uniform mat4 projMat;
 | 
			
		||||
 | 
			
		||||
uniform vec2 texSizeInv;
 | 
			
		||||
 | 
			
		||||
attribute vec2 position;
 | 
			
		||||
attribute vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
varying vec2 v_texCoord;
 | 
			
		||||
varying vec2 v_blurCoord[2];
 | 
			
		||||
 | 
			
		||||
void main()
 | 
			
		||||
{
 | 
			
		||||
	gl_Position = projMat * vec4(position, 0, 1);
 | 
			
		||||
 | 
			
		||||
	v_texCoord = texCoord * texSizeInv;
 | 
			
		||||
	v_blurCoord[0] = vec2(texCoord.x, texCoord.y-1) * texSizeInv;
 | 
			
		||||
	v_blurCoord[1] = vec2(texCoord.x, texCoord.y+1) * texSizeInv;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue