Created
March 16, 2014 13:36
-
-
Save paulhoux/9583347 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
#version 150 | |
uniform sampler2D uTexture; | |
in VertexData { | |
vec3 baricentric; | |
vec4 color; | |
vec2 texcoord; | |
} vVertexIn; | |
out vec4 oColor; | |
float edgeFactor() | |
{ | |
vec3 d = fwidth( vVertexIn.baricentric ); | |
vec3 a3 = smoothstep( vec3(0.0), d * 1.5, vVertexIn.baricentric ); | |
return min(min(a3.x, a3.y), a3.z); | |
} | |
void main(void) { | |
// determine frag distance to closest edge | |
float fEdgeIntensity = 1.0 - edgeFactor(); | |
// blend between edge color and face color | |
vec4 vFaceColor = texture( uTexture, vVertexIn.texcoord ) * vVertexIn.color; vFaceColor.a = 0.85; | |
vec4 vEdgeColor = vec4(1.0, 1.0, 1.0, 0.85); | |
oColor = mix(vFaceColor, vEdgeColor, fEdgeIntensity); | |
} |
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
#version 150 | |
layout (triangles) in; | |
layout (triangle_strip, max_vertices = 3) out; | |
in VertexData { | |
vec4 color; | |
vec2 texcoord; | |
} vVertexIn[]; | |
out VertexData { | |
vec3 baricentric; | |
vec4 color; | |
vec2 texcoord; | |
} vVertexOut; | |
void main(void) | |
{ | |
vVertexOut.baricentric = vec3(1, 0, 0); | |
vVertexOut.color = vVertexIn[0].color; | |
vVertexOut.texcoord = vVertexIn[0].texcoord; | |
gl_Position = gl_in[0].gl_Position; | |
EmitVertex(); | |
vVertexOut.baricentric = vec3(0, 1, 0); | |
vVertexOut.color = vVertexIn[1].color; | |
vVertexOut.texcoord = vVertexIn[1].texcoord; | |
gl_Position = gl_in[1].gl_Position; | |
EmitVertex(); | |
vVertexOut.baricentric = vec3(0, 0, 1); | |
vVertexOut.color = vVertexIn[2].color; | |
vVertexOut.texcoord = vVertexIn[2].texcoord; | |
gl_Position = gl_in[2].gl_Position; | |
EmitVertex(); | |
EndPrimitive(); | |
} |
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
#version 150 | |
uniform mat4 ciModelViewProjection; | |
in vec4 ciPosition; | |
in vec4 ciColor; | |
in vec2 ciTexCoord0 | |
out VertexData { | |
vec4 color; | |
vec2 texcoord; | |
} vVertexOut; | |
void main(void) { | |
vVertexOut.color = ciColor; | |
vVertexOut.texcoord = ciTexCoord0; | |
gl_Position = ciModelViewProjection * ciPosition; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment