I do not know any built-in functions for obtaining barycentric coordinates. But you do not need any calculations in the fragment shader.
You can pass the barycentric coordinates of the vertices of the triangle as attributes to the vertex shader. The attribute values ββfor the three vertices are simply (1, 0, 0), (0, 1, 0), and (0, 0, 1). Then pass the attribute value through the fragment shader (using the variable varyingin the deprecated OpenGL, outin the vertex shader and inin the fragment shader, mainly OpenGL). Then the value of the variable obtained by the fragment shader is the barycentric coordinates of the fragment.
, , , .