Created
October 12, 2015 20:42
-
-
Save xoppa/33589b7d5805205f8f08 to your computer and use it in GitHub Desktop.
very basic outline shader
This file contains hidden or 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
#ifdef GL_ES | |
#define LOWP lowp | |
precision mediump float; | |
#else | |
#define LOWP | |
#endif | |
const float offset = 1.0 / 128.0; | |
varying vec2 v_texCoords; | |
uniform sampler2D u_texture; | |
void main() | |
{ | |
vec4 col = texture2D(u_texture, v_texCoords); | |
if (col.a > 0.5) | |
gl_FragColor = col; | |
else { | |
float a = texture2D(u_texture, vec2(v_texCoords.x + offset, v_texCoords.y)).a + | |
texture2D(u_texture, vec2(v_texCoords.x, v_texCoords.y - offset)).a + | |
texture2D(u_texture, vec2(v_texCoords.x - offset, v_texCoords.y)).a + | |
texture2D(u_texture, vec2(v_texCoords.x, v_texCoords.y + offset)).a; | |
if (col.a < 1.0 && a > 0.0) | |
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.8); | |
else | |
gl_FragColor = col; | |
} | |
} |
This file contains hidden or 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
attribute vec4 a_position; | |
attribute vec2 a_texCoord0; | |
uniform mat4 u_projTrans; | |
varying vec2 v_texCoords; | |
void main() | |
{ | |
v_texCoords = a_texCoord0; | |
gl_Position = u_projTrans * a_position; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I adapted it to gamemaker :D