OpenSubdiv: Better approximation of vertex normals
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 25 Aug 2015 10:40:50 +0000 (12:40 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 25 Aug 2015 11:16:55 +0000 (13:16 +0200)
Use vertex varying data which gives better approximation of normals.
Still not ideal but should be closer for higher poly meshes to correct
normal.

The only way to have proper smooth normals seems to be to implement
patch evaluation in tessellation shader, but that's a bit PITA with
current GLSL usage in our draw code.

intern/opensubdiv/opensubdiv_capi.cc

index e3bc5891c45ba9b632e902a348bbb8082a4f6cbd..23146fcfc5d7a4a7a4c21acb325903ef86b807ef 100644 (file)
@@ -156,14 +156,14 @@ struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
         */
        bits.set(OpenSubdiv::Osd::MeshAdaptive, 0);
        bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, 0);
-       bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 0);
+       bits.set(OpenSubdiv::Osd::MeshInterleaveVarying, 1);
        bits.set(OpenSubdiv::Osd::MeshFVarData, 1);
        bits.set(OpenSubdiv::Osd::MeshEndCapBSplineBasis, 1);
        // bits.set(Osd::MeshEndCapGregoryBasis, 1);
        // bits.set(Osd::MeshEndCapLegacyGregory, 1);
 
-       const int num_vertex_elements = 6;
-       const int num_varying_elements = 0;
+       const int num_vertex_elements = 3;
+       const int num_varying_elements = 3;
 
        GLMeshInterface *mesh = NULL;
        TopologyRefiner *refiner = (TopologyRefiner*)topology_refiner;