This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_edges_overlay_frag.glsl
Mike Erwin 5b26c36008 OpenGL: edge overlay shaders
As seen at #bcon16. These were produced quickly and probably need further work.

SIMPLE variant draws triangle mesh edges. Based on this research:
http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf
http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf

Non-SIMPLE variant can adjust thickness per edge. This can be used to draw only some edges, or accentuate some edges. Given the right inputs this is a general n-gon perimeter shader.

Part of T49165
2016-11-05 19:26:13 +01:00

21 lines
469 B
GLSL

#define SMOOTH 1
const float transitionWidth = 1.0;
uniform vec4 fillColor = vec4(0);
uniform vec4 outlineColor = vec4(0,0,0,1);
noperspective in vec3 distanceToOutline;
out vec4 FragColor;
void main() {
float edgeness = min(min(distanceToOutline.x, distanceToOutline.y), distanceToOutline.z);
#if SMOOTH
FragColor = mix(outlineColor, fillColor, smoothstep(0, transitionWidth, edgeness));
#else
FragColor = (edgeness <= 0) ? outlineColor : fillColor;
#endif
}