blobt
5 years ago
7 changed files with 105 additions and 36 deletions
-
BIN.vs/shader3/v14/.suo
-
40main.cpp
-
28res/shader/edge_detect.fs
-
29res/shader/sharpen.fs
-
28res/shader/smooth.fs
-
8shader3.vcxproj
-
8shader3.vcxproj.filters
@ -0,0 +1,28 @@ |
|||
|
|||
varying vec2 V_Texcoord; |
|||
|
|||
uniform sampler2D U_MainTexture; |
|||
|
|||
void main() |
|||
{ |
|||
//1 2 1 |
|||
//2 4 2 |
|||
//1 2 1 |
|||
vec4 color = vec4(0.0); |
|||
int coreSize = 3; |
|||
float texelOffset = 1/150.0; |
|||
float kernel[9]; |
|||
|
|||
kernel[6]=0;kernel[7]=1;kernel[8]=0; |
|||
kernel[3]=1;kernel[4]=-4;kernel[5]=1; |
|||
kernel[0]=0;kernel[1]=1;kernel[2]=0; |
|||
|
|||
int index = 0; |
|||
for(int y=0; y<coreSize; y++){ |
|||
for(int x=0; x<coreSize; x++){ |
|||
vec4 currentColor = texture2D(U_MainTexture, V_Texcoord+vec2((-1+x)*texelOffset, (-1+y)*texelOffset)); |
|||
color += currentColor*kernel[index++]; |
|||
} |
|||
} |
|||
gl_FragColor=4.0*color+texture2D(U_MainTexture,V_Texcoord); |
|||
} |
@ -0,0 +1,29 @@ |
|||
|
|||
varying vec2 V_Texcoord; |
|||
|
|||
uniform sampler2D U_MainTexture; |
|||
|
|||
void main() |
|||
{ |
|||
//1 2 1 |
|||
//2 4 2 |
|||
//1 2 1 |
|||
vec4 color = vec4(0.0); |
|||
int coreSize = 3; |
|||
float texelOffset = 1/100.0; |
|||
float kernel[9]; |
|||
|
|||
kernel[6]=0;kernel[7]=-1;kernel[8]=0; |
|||
kernel[3]=-1;kernel[4]=4;kernel[5]=-1; |
|||
kernel[0]=0;kernel[1]=-1;kernel[2]=0; |
|||
|
|||
int index = 0; |
|||
for(int y=0; y<coreSize; y++){ |
|||
for(int x=0; x<coreSize; x++){ |
|||
vec4 currentColor = texture2D(U_MainTexture, V_Texcoord+vec2((-1+x)*texelOffset, (-1+y)*texelOffset)); |
|||
color += currentColor*kernel[index++]; |
|||
} |
|||
} |
|||
|
|||
gl_FragColor = 1.2*color+texture2D(U_MainTexture,V_Texcoord); |
|||
} |
@ -0,0 +1,28 @@ |
|||
|
|||
varying vec2 V_Texcoord; |
|||
|
|||
uniform sampler2D U_MainTexture; |
|||
|
|||
void main() |
|||
{ |
|||
|
|||
vec4 color = vec4(0.0); |
|||
int coreSize = 3; |
|||
float texelOffset = 1/150.0; |
|||
float kernel[9]; |
|||
|
|||
kernel[6]=1;kernel[7]=2;kernel[8]=1; |
|||
kernel[3]=1;kernel[4]=4;kernel[5]=1; |
|||
kernel[0]=1;kernel[1]=2;kernel[2]=1; |
|||
|
|||
int index = 0; |
|||
for(int y=0; y<coreSize; y++){ |
|||
for(int x=0; x<coreSize; x++){ |
|||
vec4 currentColor = texture2D(U_MainTexture, V_Texcoord+vec2((-1+x)*texelOffset, (-1+y)*texelOffset)); |
|||
color += currentColor*kernel[index++]; |
|||
} |
|||
} |
|||
|
|||
color/=9; |
|||
gl_FragColor = color; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue