Created
March 16, 2014 13:27
-
-
Save paulhoux/9583212 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 { | |
noperspective vec3 distance; | |
vec4 color; | |
vec2 texcoord; | |
} vVertexIn; | |
out vec4 oColor; | |
void main(void) { | |
// determine frag distance to closest edge | |
float fNearest = min(min(vVertexIn.distance[0],vVertexIn.distance[1]),vVertexIn.distance[2]); | |
float fEdgeIntensity = exp2(-1.0*fNearest*fNearest); | |
// 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; | |
uniform vec2 uViewportSize; | |
in VertexData { | |
vec4 color; | |
vec2 texcoord; | |
} vVertexIn[]; | |
out VertexData { | |
noperspective vec3 distance; | |
vec4 color; | |
vec2 texcoord; | |
} vVertexOut; | |
void main(void) | |
{ | |
// taken from 'Single-Pass Wireframe Rendering' | |
vec2 p0 = uViewportSize * gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w; | |
vec2 p1 = uViewportSize * gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w; | |
vec2 p2 = uViewportSize * gl_in[2].gl_Position.xy / gl_in[2].gl_Position.w; | |
vec2 v0 = p2-p1; | |
vec2 v1 = p2-p0; | |
vec2 v2 = p1-p0; | |
float fArea = abs(v1.x*v2.y - v1.y * v2.x); | |
vVertexOut.distance = vec3(fArea/length(v0),0,0); | |
vVertexOut.color = vVertexIn[0].color; | |
vVertexOut.texcoord = vVertexIn[0].texcoord; | |
gl_Position = gl_in[0].gl_Position; | |
EmitVertex(); | |
vVertexOut.distance = vec3(0,fArea/length(v1),0); | |
vVertexOut.color = vVertexIn[1].color; | |
vVertexOut.texcoord = vVertexIn[1].texcoord; | |
gl_Position = gl_in[1].gl_Position; | |
EmitVertex(); | |
vVertexOut.distance = vec3(0,0,fArea/length(v2)); | |
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