You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
615 B

  1. varying vec2 V_Texcoord;
  2. uniform sampler2D U_MainTexture;
  3. void main()
  4. {
  5. //1 2 1
  6. //2 4 2
  7. //1 2 1
  8. vec4 color = vec4(0.0);
  9. int coreSize = 3;
  10. float texelOffset = 1/100.0;
  11. float kernel[9];
  12. kernel[6]=0;kernel[7]=-1;kernel[8]=0;
  13. kernel[3]=-1;kernel[4]=4;kernel[5]=-1;
  14. kernel[0]=0;kernel[1]=-1;kernel[2]=0;
  15. int index = 0;
  16. for(int y=0; y<coreSize; y++){
  17. for(int x=0; x<coreSize; x++){
  18. vec4 currentColor = texture2D(U_MainTexture, V_Texcoord+vec2((-1+x)*texelOffset, (-1+y)*texelOffset));
  19. color += currentColor*kernel[index++];
  20. }
  21. }
  22. gl_FragColor = 1.2*color+texture2D(U_MainTexture,V_Texcoord);
  23. }