1 Shader "Custom/dFdyCustom" {
4 _MainTex ("Texture Image", 2D) = "white" {}
5 _TexSizeY ("Texture Height", Float) = 0.0
13 uniform sampler2D _MainTex;
14 uniform float _TexSizeY;
16 varying vec4 textureCoordinates;
22 textureCoordinates = gl_MultiTexCoord0;
23 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
30 vec4 c0 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(0.0, -1.0/_TexSizeY));
31 vec4 c1 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(0.0, 1.0/_TexSizeY));
33 vec4 g = (c1 - c0) / 2.0;
35 float gradient = (g.r + g.g + g.b) / 3.0;
37 gradient = (gradient + 1.0) / 2.0;
39 gl_FragColor = vec4(gradient, gradient, gradient, 1.0);