We have a wireframe shader that calculates the barycentric coordinates in the Geometry program, and out puts is into the triangle stream. Looks like this:
- Code: Select all
// inverseW is to counteract the effect of perspective-correct interpolation so that the lines
// look the same thickness regardless of their depth in the scene.
float4 viewPos : SV_POSITION;
float inverseW : TEXCOORD0;
float3 dist : TEXCOORD1;
void geom(triangle v2g i, inout TriangleStream<g2f> triStream)
// Calculate the vectors that define the triangle from the input points.
float2 point0 = i.viewPos.xy / i.viewPos.w;
float2 point1 = i.viewPos.xy / i.viewPos.w;
float2 point2 = i.viewPos.xy / i.viewPos.w;
// Calculate the area of the triangle.
float2 vector0 = point2 - point1;
float2 vector1 = point2 - point0;
float2 vector2 = point1 - point0;
float area = abs(vector1.x * vector2.y - vector1.y * vector2.x);
distScale = float3(area / length(vector0), 0, 0);
distScale = float3(0, area / length(vector1), 0);
distScale = float3(0, 0, area / length(vector2));
float wireScale = 800 - _WireThickness;
// Output each original vertex with its distance to the opposing line defined
// by the other two vertices.
for (uint idx = 0; idx < 3; ++idx)
o.viewPos = i[idx].viewPos;
o.inverseW = 1.0 / o.viewPos.w;
o.dist = distScale[idx] * o.viewPos.w * wireScale;
Essentially we are creating a wireframe out of the GEO and rendering that via the shader.
I understand that this isn't something that can be done with amplify, based on other threads (?) or I might be wrong?
I also found this thread :http://amplify.pt/forum/viewtopic.php?f=8&t=883&p=3840&hilit=barycentric#p3840 discussing using an expression node for the calculation, but I don't understand how I would get the proper inputs for the node (being A,B,C, And P).
I was wondering what would be the best way to achieve the desired behavior within the context of amplify?