Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Anders_L_
Beginner
73 Views

Issue with subdivision surfaces in 2.6.0

Hi, I'm using 2.6.0 on OSX Yosemite and I'm getting weird results using subdivision meshes. It looks like the faces' connectivity isn't correct, but as far as I can tell I'm using the API correctly (I'm hoping I'm just doing something stupid).

In this example I'm rendering a simple "torus" with 9 vertices and 9 faces. Here's the geo in Maya and a subdiv render in Arnold:

 

 

 

 

...

and here's what I get rendering the same in my app:

 

...

I'm creating the subdivision mesh like so:

uint32_t geom_id =
       rtcNewSubdivisionMesh(_scene, RTC_GEOMETRY_STATIC, 9,
                             9*4, 9, 0, 0, 0, 1);

rtcSetBuffer(_scene, geom_id, RTC_VERTEX_BUFFER, vertices, 0, sizeof(V4f));
rtcSetBuffer(_scene, geom_id, RTC_FACE_BUFFER, faces, 0, sizeof(uint32_t));
rtcSetBuffer(_scene, geom_id, RTC_LEVEL_BUFFER, level, 0, sizeof(float));
rtcSetBuffer(_scene, geom_id, RTC_INDEX_BUFFER, indices, 0,
                sizeof(uint32_t));

where the arrays contain the following:

vertices = {
(-0.25 0 -0.433013 0),
(-0.25 0 0.433013 0),
(0.5 0 0 0),
(-0.625 0.433013 -1.08253 0),
(-0.625 0.433013 1.08253 0),
(1.25 0.433013 0 0),
(-0.625 -0.433013 -1.08253 0),
(-0.625 -0.433013 1.08253 0)
}

indices = {
4 3 0 1 
5 4 1 2 
3 5 2 0 
7 6 3 4 
8 7 4 5 
6 8 5 3 
1 0 6 7 
2 1 7 8 
0 2 8 6
}

and faces and level contain all 4's (9 and 36 elements, respectively). I've manually checked the indices and everything in Maya to make sure that they're correct. I'm not sure what else to try. Anyone have any idea what I"m doing wrong?

0 Kudos
10 Replies
SvennW_Intel
Moderator
73 Views

Could you please double check if the position array and index array are correct. If I render it using triangles I get some wrong looking shape.

unsigned int cube_tri_indices[18*3] = {

  4, 3, 0,  4, 0, 1,  // ok
  5, 4, 1,  5, 1, 2,  // ok
  3, 5, 2,  3, 2, 0,  // ok
  7, 6, 3,  7, 3, 4,  // ok
  8, 7, 4,  8, 4, 5,  // wrong
  6, 8, 5,  6, 5, 3, 
  1, 0, 6,  1, 6, 7, 
  2, 1, 7,  2, 7, 8, 
  0, 2, 8,  0, 8, 6
};

Anders_L_
Beginner
73 Views

Thanks for your reply Sven. I'm using a slightly different indexing for the triangles from you, but the results should be the same I think. I've checked the polygon in question by outputting the actual vertices as well, and they seem to be correct too. My indexing from quads to triangles looks like this (and the triangle mesh renders fine):

4 3 0 1 --> 1 3 0, 1 4 3 
5 4 1 2 --> 2 4 1, 2 5 4 
3 5 2 0 --> 0 5 2, 0 3 5 
7 6 3 4 --> 4 6 3, 4 7 6 
8 7 4 5 --> 5 7 4, 5 8 7 
6 8 5 3 --> 3 8 5, 3 6 8 
1 0 6 7 --> 7 0 6, 7 1 0 
2 1 7 8 --> 8 1 7, 8 2 1 
0 2 8 6 --> 6 2 8, 6 0 2

BenthinC_Intel
Employee
73 Views

I might be wrong but your vertex array has only 8 entries. Shouldn't it be 9 because you dereference the 8th vertex (starting with 0) ?

Anders_L_
Beginner
73 Views

HI Carsten, well-spotted! That was a copy-paste error, sorry. The array does have 9 vertices:

-0.24999997 0 -0.433012754 
-0.25000003 0 0.433012694 
0.5 0 0 
-0.62499994 0.433012694 -1.08253193 
-0.62500006 0.433012694 1.08253169
1.25 0.433012694 0 
-0.62499994 -0.433012754 -1.08253193 
-0.62500006 -0.433012754 1.08253169
1.25 -0.433012754 0

Anders_L_
Beginner
73 Views

On closer inspection it appears that the geometry is actually fine (sorry about that) - it's actually shadows that are causing the artefacts. Ignoring shadows or raising shadow_ray.tnear to something large removes the black spots.

For triangle meshes I'm using intersection/occlusion filters to ignore ray hits from the same geom and prim id (i.e. the same triangle)  to clear shadow acne. Is that a safe tactic for subdivision meshes? i.e. does the prim id correspond to the actual triangle that was hit?

SvennW_Intel
Moderator
73 Views

Yes, the primID corresponds to the actual face that was hit. However, we did not yet implement the intersection/occlusion filters for subdivision geometries. I will make sure that the filters work in the next release.
Anders_L_
Beginner
73 Views

Great, thanks Sven. I can make do with tris for now. What sort of timescale do you expect the next release to be on?

BenthinC_Intel
Employee
73 Views

The next release is scheduled for the beginning of August and will for example include lots of performance improvements for ray tracing subdivision surfaces.

Anders_L_
Beginner
73 Views

Thanks Carsten, looking forward to it!

Anders_L_
Beginner
73 Views

Hi guys, just wanted to confirm that the new intersection filters for SDS in 2.6.1 fix my issue. Thanks!