GPv3: Curve to Mesh node #113659
|
@ -12,6 +12,16 @@
|
|||
#if defined(USE_BARYCENTRICS) && defined(GPU_FRAGMENT_SHADER) && defined(MAT_GEOM_MESH)
|
||||
vec3 barycentric_distances_get()
|
||||
{
|
||||
# if defined(GPU_METAL)
|
||||
/* Calculate Barycentric distances from available parameters in Metal. */
|
||||
float wp_delta = length(dfdx(interp.P)) + length(dfdy(interp.P));
|
||||
float bc_delta = length(dfdx(gpu_BaryCoord)) + length(dfdy(gpu_BaryCoord));
|
||||
float rate_of_change = wp_delta / bc_delta;
|
||||
vec3 dists;
|
||||
dists.x = rate_of_change * (1.0 - gpu_BaryCoord.x);
|
||||
dists.y = rate_of_change * (1.0 - gpu_BaryCoord.y);
|
||||
dists.z = rate_of_change * (1.0 - gpu_BaryCoord.z);
|
||||
# elif
|
||||
/* NOTE: No need to undo perspective divide since it has not been applied. */
|
||||
vec3 pos0 = (ProjectionMatrixInverse * gpu_position_at_vertex(0)).xyz;
|
||||
vec3 pos1 = (ProjectionMatrixInverse * gpu_position_at_vertex(1)).xyz;
|
||||
|
@ -29,7 +39,8 @@ vec3 barycentric_distances_get()
|
|||
dists.y = sqrt(dot(edge10, edge10) - d * d);
|
||||
d = dot(d10, edge21);
|
||||
dists.z = sqrt(dot(edge21, edge21) - d * d);
|
||||
return dists.xyz;
|
||||
# endif
|
||||
return dists;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue