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
		
			
				
	
	
		
			21 lines
		
	
	
		
			469 B
		
	
	
	
		
			GLSL
		
	
	
	
	
	
			
		
		
	
	
			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
 | 
						|
}
 |