fragment_hidden.tpl 495 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// template file for shader generator

in vec3 outGeometryBary;


float edgeFactor()
{
  // compute smoothed distance to edge, source:
  // http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/
  
  vec3 d = fwidth(outGeometryBary);
  vec3 a3 = smoothstep(vec3(0.0), d*1.5, outGeometryBary);
  return min(min(a3.x, a3.y), a3.z);
}

void main()
{
  SG_FRAGMENT_BEGIN

  sg_cColor.xyz = mix(vec3(0.0), sg_cColor.xyz, 1-edgeFactor());
    
  SG_FRAGMENT_END
}