Mtl implementation screenspace fvar interp

Fixed smooth face-varying interpolation for the Metal viewer
when using screen-space tessellation. The location to evaluate
the face-varying value needs to match the computed tess location
instead of the intrinsic position_in_patch.
This commit is contained in:
David G Yu 2019-05-24 13:52:47 -07:00
parent 11bcf82632
commit 8912b3f3d3
5 changed files with 6 additions and 2 deletions

View File

@ -434,7 +434,7 @@ vertex OutputVertex vertex_main(
out.patchColor = patchVertex.patchCoord.xyz;
#elif SHADING_TYPE == SHADING_TYPE_FACE_VARYING
int patchIndex = OsdGetPatchIndex(patch_id);
float2 uv = position_in_patch;
float2 uv = patchVertex.tessCoord;
#if OSD_FACEVARYING_PATCH_REGULAR
float wP[16], wDs[16], wDt[16], wDss[16], wDst[16], wDtt[16];
int patchCVs = 16;

View File

@ -197,6 +197,7 @@ OsdPatchVertex ds_regular_patches(
output.vSegments = vSegments;
#endif
output.tessCoord = UV;
output.patchCoord = OsdInterpolatePatchCoord(UV, patchParam);
output.position = P;
return output;

View File

@ -147,6 +147,7 @@ struct OsdPatchVertex {
float3 tangent;
float3 bitangent;
float4 patchCoord; //u, v, faceLevel, faceId
float2 tessCoord; // tesscoord.st
#if OSD_COMPUTE_NORMAL_DERIVATIVES
float3 Nu;
float3 Nv;

View File

@ -36,7 +36,7 @@ void OsdComputePerVertex(
OsdPatchParamBufferSet osdBuffers
)
{
OsdComputePerVertexGregory(vertexId, position.xyz, hullVertex, osdBuffers);
OsdComputePerVertexGregory(vertexId, position.xyz, hullVertex, osdBuffers);
#if OSD_ENABLE_PATCH_CULL
float4 clipPos = mul(modelViewProjectionMatrix, position);
@ -164,6 +164,7 @@ OsdPatchVertex ds_gregory_patches(
output.Nv = dNv;
#endif
output.tessCoord = UV;
output.patchCoord = OsdInterpolatePatchCoord(UV, patchParam);
return output;

View File

@ -165,6 +165,7 @@ OsdPatchVertex ds_gregory_basis_patches(
output.Nv = dNv;
#endif
output.tessCoord = UV;
output.patchCoord = OsdInterpolatePatchCoord(UV, patchParam);
return output;