Importing assets with quad geometry for tessellation

Howdy, folks.

I’m playing around with Aras’ DX11 example project, trying to use the tessellation shaders. We’re not exactly getting the results we wanted from a triangulated mesh, and I remember reading the following line from the new documentation:

So… the question is how do I import my model with quads? The original file is made out of quads (I can see them in Maya) but it comes into Unity with trangles. I don’t see any “use quads” option in the import settings. Am I missing something?

bump

Hey there! I ended up solving my own question!

After giving up on finding a baked-in solution (if there’s an “import as quads” checkbox somewhere I’ll fall on my sword) I decided that it was up to me. My first attempt involved trying to “copy” a quad mesh from an existing triangulated mesh in Unity. I first started by trying to group up any coplanar pairs of triangles. It turns out that there’s a very easy method to doing this, which is to check if the determinant of a 4x4 matrix with all 4 vertex positions and a column of ones is equal to zero. Thanks to Wolfram for that gem! However, as it turns out, not all quads are made of coplanar triangles. I tried including a threshold and even searching for all determinant values and picking the lowest one. Obviously that wasn’t very efficient and ended up not working anyway.

So I revised my approach to just try building the mesh by parsing an OBJ text string. I was saved countless hours by a pre-existing project to do just that. All I had to do was introduce a case for importing a quad-based mesh and there I had it! Simple!

If anyone’s interested in my solution I’d be happy to share it, and eventually commit the changes back to the OBJ loader project! Great Success!

Oh, and also, here’s a video of the shader inaction :wink:

PLEASE post this! I’ve been hungry to get my hands on some DX11 shaders, and this looks like a good one to dive into. If you don’t mind posting the source, that would be awesome. I’d be willing to pay a little cash for it if you’re looking to sell it. Not a lot of DX11 shaders for unity floating around :frowning:

I’ve posted the code (and an explanation) in a blog post. Check her out!