2016-02-29 03:06:27 +03:00
|
|
|
$input v_view, v_bc
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2016 Dario Manesku. All rights reserved.
|
2022-01-15 22:59:06 +03:00
|
|
|
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
|
2016-02-29 03:06:27 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../common/common.sh"
|
|
|
|
#include "uniforms.sh"
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec3 color = u_wfColor;
|
|
|
|
float opacity = u_wfOpacity;
|
|
|
|
float thickness = u_wfThickness;
|
|
|
|
|
2016-02-29 03:34:16 +03:00
|
|
|
if (gl_FrontFacing) { opacity *= 0.5; }
|
2016-02-29 03:06:27 +03:00
|
|
|
|
|
|
|
vec3 fw = abs(dFdx(v_bc)) + abs(dFdy(v_bc));
|
2016-03-01 19:24:58 +03:00
|
|
|
vec3 val = smoothstep(vec3_splat(0.0), fw*thickness, v_bc);
|
2016-02-29 03:06:27 +03:00
|
|
|
float edge = min(min(val.x, val.y), val.z); // Gets to 0.0 around the edges.
|
|
|
|
|
|
|
|
vec4 rgba = vec4(color, (1.0-edge)*opacity);
|
|
|
|
gl_FragColor = rgba;
|
|
|
|
}
|
|
|
|
|