Hello!
I’m currently working on my own cycles plugin for maya. Until here, everything works fine but i have some issues with motion blur on subdivision surfaces. The mesh seems to implode (see the joined image) like if
the values of ATTR_STD_MOTION_VERTEX_POSITION returns 0.
Is someone have an idea about that? what’s seems wrong? Have I fogotten something? Thanks!!
I’ve also tried with simple geometry with code below , it still renders wrong with subdiv (works well when subdiv is off):
//Geometry Description
Mesh* mesh = static_cast<Mesh*>(geom);
array<Node*> used_shaders = mesh->get_used_shaders();
Mesh new_mesh;
new_mesh.set_used_shaders(used_shaders);
new_mesh.set_subdivision_type(object_subdivision_type(m_ob_geo, preview, experimental));
bool subd = new_mesh.get_subdivision_type() != Mesh::SUBDIVISION_NONE;
if (subd){
new_mesh.reserve_subd_faces(1, 0, 4);
new_mesh.reserve_mesh(4, 0);
new_mesh.set_subd_dicing_rate(1.0);
new_mesh.set_subd_max_level(4);
new_mesh.set_subd_objecttoworld(maya_get_transform(m_ob_geo, “worldMatrix”));
}
else
{
new_mesh.reserve_mesh(4, 2);
}
//verts
float3 pt1 = make_float3(-1.0, 0, -1.0);
float3 pt2 = make_float3(1.0, 0, -1.0);
float3 pt3 = make_float3(1.0, 0, 1.0);
float3 pt4 = make_float3(-1.0, 0, 1.0);
new_mesh.add_vertex(pt1);
new_mesh.add_vertex(pt2);
new_mesh.add_vertex(pt3);
new_mesh.add_vertex(pt4);
//normals
AttributeSet& attributes = (subd) ? new_mesh.subd_attributes : new_mesh.attributes;
Attribute* attr_N = new_mesh.subd_attributes.add(ATTR_STD_VERTEX_NORMAL);
float3* N = attr_N->data_float3();
float3 n1 = make_float3(0.0, 1.0, 0.0);
N[0] = n1;
N[1] = n1;
N[2] = n1;
N[3] = n1;
//faces
if (subd)
{
vector vi;
vi.push_back(0);
vi.push_back(1);
vi.push_back(2);
vi.push_back(3);
new_mesh.add_subd_face(&vi[0], 4, 0, false);
}
else
{
new_mesh.add_triangle(0, 1, 2, 0, true);
new_mesh.add_triangle(2, 3, 0, 0, true);
}
//Motion Description
Mesh* mesh = static_cast<Mesh*>(geom);
Attribute* attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
if (!attr_mP)
{
attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION);
}
float3* mP = attr_mP->data_float3();
float3 m0pt1 = make_float3(-2.0, 0, -1.0);
float3 m0pt2 = make_float3(1.0, 0, -1.0);
float3 m0pt3 = make_float3(1.0, 0, 1.0);
float3 m0pt4 = make_float3(-1.0, 0, 1.0);
float3 m1pt1 = make_float3(0.0, 0, -1.0);
float3 m1pt2 = make_float3(1.0, 0, -1.0);
float3 m1pt3 = make_float3(1.0, 0, 1.0);
float3 m1pt4 = make_float3(-1.0, 0, 1.0);
//motionstep 0
mP[0] = (m0pt1);
mP[1] = (m0pt2);
mP[2] = (m0pt3);
mP[3] = (m0pt4);
//motionstep 1
mP[4] = (m1pt1);
mP[5] = (m1pt2);
mP[6] = (m1pt3);
mP[7] = (m1pt4);
- List item