# Undo barycentric interpolation

How do I undo the interpolation of vertex attributes? I'm using unity shader graph which doesn't support nointerpolation. I assume I need to store 3 float3 with one component of each float3 being 1 and the rest 0, this will give the barycentric coordinate. But I don't know how to actually use them to undo the interpolation.

• do you have access to the barycentric weights? which geometry type are you using (triangles, quads, lines)? what is the shader language (glsl, hlsl)? Jan 12 at 15:56
• @Thomas: "what is the shader language (glsl, hlsl)?" The OP said that they're "using unity shader graph", so that's the "shader language". Jan 12 at 16:25
• Unity uses triangles as the primitive type. Shader Graph uses nodes, not code, but shaders can be written in hlsl. But I'm using a render pipeline which makes it hard to write shader code, so I'd rather use Shader Graph. I think to get the barycentric coordinate, we just have 3 float3 attributes (I think they are called varyings), (1,0,0),(0,1,0),(0,0,1), Which automatically get processed in the vertex->frag stage, and those values become the barycentric coordinate in the fragment stage. @Thomas Jan 12 at 16:32
• Does shader graph have "partial derivatives" (in glsl it is the function dFdx/dFdy) within its fragment stage? If so, I think you can back calculate each vertex value... Jan 12 at 19:43
• yes, there are 3 derivative nodes, ddx, ddxy,ddy, how would I calculate them? Jan 12 at 21:53

Even with the barycentric coordinates, you cannot "undo" interpolation. Interpolation uses 3 input values and produces one output value: $$f(A, B, C) = O$$. So to reverse that would mean that you have one equation with three unknowns, ignoring the coordinate itself. You cannot solve for 3 unknowns with one equation.