From 1adfda5d791112d82dc3f83c6eeed570cc6eae25 Mon Sep 17 00:00:00 2001 From: David G Yu Date: Wed, 12 Jul 2017 15:20:21 -0700 Subject: [PATCH] Fixed mtlViewer face-varying evaluation Updated the mtlViewer to compute correct offsets for face-varying param and index buffers when using the Gregory Basis end cap approximation. --- examples/mtlViewer/mtlViewer.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mtlViewer/mtlViewer.mm b/examples/mtlViewer/mtlViewer.mm index dcd13743..9986c092 100644 --- a/examples/mtlViewer/mtlViewer.mm +++ b/examples/mtlViewer/mtlViewer.mm @@ -355,8 +355,8 @@ using PerFrameBuffer = MTLRingBuffer; auto& fvarPatch = pfvarav[i]; assert(sizeof(Osd::PatchParam) == sizeof(int) * 3); - [renderCommandEncoder setVertexBufferOffset:fvarPatch.primitiveIdBase * sizeof(int) * 3 atIndex:OSD_FVAR_PATCHPARAM_BUFFER_INDEX]; - [renderCommandEncoder setVertexBufferOffset:fvarPatch.indexBase * sizeof(unsigned) atIndex:OSD_FVAR_INDICES_BUFFER_INDEX]; + [renderCommandEncoder setVertexBufferOffset:(fvarPatch.primitiveIdBase+patch.primitiveIdBase) * sizeof(int) * 3 atIndex:OSD_FVAR_PATCHPARAM_BUFFER_INDEX]; + [renderCommandEncoder setVertexBufferOffset:(fvarPatch.indexBase+(patch.primitiveIdBase*fvarPatch.desc.GetNumControlVertices())) * sizeof(unsigned) atIndex:OSD_FVAR_INDICES_BUFFER_INDEX]; } [renderCommandEncoder setVertexBufferOffset:patch.indexBase * sizeof(unsigned) atIndex:INDICES_BUFFER_INDEX];