1 Shader "Custom/dFdxCustom" {
4 _MainTex ("Texture Image", 2D) = "white" {}
5 _TexSizeX ("Texture Width", Float) = 0.0
13 uniform sampler2D _MainTex;
14 uniform float _TexSizeX;
16 varying vec4 textureCoordinates;
22 textureCoordinates = gl_MultiTexCoord0;
23 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
30 vec4 c0 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(-1.0/_TexSizeX, 0.0));
31 vec4 c1 = texture2D(_MainTex, vec2(textureCoordinates) + vec2(1.0/_TexSizeX, 0.0));
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);