-
-
Save AaronMeyers/6ffafda801d886475c64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision highp float; | |
varying vec2 texCoordVarying; | |
uniform sampler2D tex0; | |
uniform vec2 texCoordScale; | |
uniform vec2 texStep; | |
uniform float texStepScale; | |
void main() { | |
vec2 uv = texCoordVarying * texCoordScale; | |
vec2 stepSize = texStep * texStepScale; | |
float center = texture2D( tex0, uv ).r; | |
float topLeft = texture2D( tex0, uv + vec2( -1.0, -1.0 ) * stepSize ).r; | |
float left = texture2D( tex0, uv + vec2( -1.0, 0.0 ) * stepSize ).r; | |
float bottomLeft = texture2D( tex0, uv + vec2( -1.0, 1.0 ) * stepSize ).r; | |
float top = texture2D( tex0, uv + vec2( 0.0, -1.0 ) * stepSize ).r; | |
float bottom = texture2D( tex0, uv + vec2( 0.0, 1.0 ) * stepSize ).r; | |
float topRight = texture2D( tex0, uv + vec2( 1.0, -1.0 ) * stepSize ).r; | |
float right = texture2D( tex0, uv + vec2( 1.0, 0.0 ) * stepSize ).r; | |
float bottomRight = texture2D( tex0, uv + vec2( 1.0, 1.0 ) * stepSize ).r; | |
float dX = topRight + 2.0 * right + bottomRight - topLeft - 2.0 * left - bottomLeft; | |
float dY = bottomLeft + 2.0 * bottom + bottomRight - topLeft - 2.0 * top - topRight; | |
vec3 N = normalize( vec3( dX, dY, 0.01 ) ); | |
N *= 0.5; | |
N += 0.5; | |
gl_FragColor.rgb = N; | |
gl_FragColor.a = 1.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment