1 Shader "Custom/cornerCustom" {
4 _MainTex ("Texture Image", 2D) = "white" {}
5 _TexSizeX ("Texture Width", Float) = 0.0
6 _TexSizeY ("Texture Height", Float) = 0.0
14 uniform sampler2D _MainTex;
15 varying vec4 textureCoordinates;
16 uniform float _TexSizeX;
17 uniform float _TexSizeY;
23 textureCoordinates = gl_MultiTexCoord0;
24 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
32 vec4 x0 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(-1.0/_TexSizeX, 0.0));
33 vec4 x1 = texture2D(_MainTex, vec2(textureCoordinates) + vec2( 1.0/_TexSizeX, 0.0));
35 vec4 gx = (x1 - x0) / 2.0;
36 float gradX = (gx.r + gx.g + gx.b) / 3.0;
38 vec4 y0 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(0.0, -1.0/_TexSizeY));
39 vec4 y1 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(0.0, 1.0/_TexSizeY));
41 vec4 gy = (y1 - y0) / 2.0;
42 float gradY = (gy.r + gy.g + gy.b) / 3.0;
44 float magnitude = (length(vec2(gradX,gradY)) / sqrt(2.0));
46 gl_FragColor = vec4(magnitude,magnitude,magnitude, 1.0);