Deep understand of barycentric coordinates from Raycasthit structure

Hi, I try to understand how work barycentric coordinates in deep.
I know how it is definied:

In RaycastHit structure we have barycentricCoordinate field. I don’t know how can I use it in practice.
I do some research about barycentic cordinates:

https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/barycentric-coordinates

Where and why I should use barycentric coordinates? Why don’t use uv instead of barycentic coordinates?

I also try to understand example script from documentation:

I don’t understand why we multiply triangleIndex by 3?

Vector3 n1 = normals[triangles[hit.triangleIndex * 3 + 1]];

Also I don’t understand idea behind this line of code:

Vector3 interpolatedNormal = n0 * baryCenter.x + n1 * baryCenter.y + n2 * baryCenter.z;

Why don’t use Raycasthit.normal?

Summary:

Where I must use barycentric coordinates? Are other variables from Raycasthit not enought to do everything?

What are pros and cons of that space in practice?

Sorry for chaos in my question but after few hours of searching explanation I don’t know how to define question.

Where and why I should use barycentric coordinates? Why don’t use uv instead of barycentic coordinates?

If you only want the UV coord of a raycast, than just use UV from the raycast. Barycentric coordinates can be used to interpolate arbitrary per-vertex data across a triangle.

I don’t understand why we multiply triangleIndex by 3?

the triangle array is an array of indexes that make up a triangle, with each index representing a vertex. There are 3 vertices in a triangle, so you multiply triangle index by 3.

e.g. 0,1,2,1,2,3,1,3,4 would be a valid list of indexes for a mesh, representing 3 triangles. The first triangle would be composed of vertices 0,1,2, the second triangle 1,2,3, and the third triangle 1,3,4. If you wanted to access the indexes for the second triangle (triangleIndex = 1), that triangle would start at the third position of the array, so you multiply it by 3. The third triangle (triangleIndex = 2) would start at the 6th index (1,3,4), and so on.

Why don’t use Raycasthit.normal?

This is merely an example on how to use barycentric coordinates, not an example on how you should get the normal of a hit.

Where I must use barycentric coordinates?

Where you need them. If you do not find you need them to solve a particular problem, then you don’t have to use them.

Are other variables from Raycasthit not enought to do everything?

Nope. Boneweights and tangents are two things I can think of off the top of my head not provided by Raycasthit. Barycentric coordinates are a great way to calculate values on triangles of other custom per-vertex data that you have as e.g. part of a script.