Cycles: support for motion vector and UV passes.

Most of the changes are related to adding support for motion data throughout
the code. There's some code for actual camera/object motion blur raytracing
but it's unfinished (it badly slows down the raytracing kernel even when the
option is turned off), so that code it disabled still.

Motion vector export from Blender tries to avoid computing derived meshes
when the mesh does not have a deforming modifier, and it also won't store
motion vectors for every vertex if only the object or camera is moving.
This commit is contained in:
Brecht Van Lommel
2012-04-30 12:49:26 +00:00
parent 796dd8a321
commit 1d8c798188
52 changed files with 1140 additions and 309 deletions

View File

@@ -31,7 +31,7 @@ void Attribute::set(ustring name_, TypeDesc type_, Element element_)
name = name_;
type = type_;
element = element_;
std = STD_NONE;
std = ATTR_STD_NONE;
/* string and matrix not supported! */
assert(type == TypeDesc::TypeFloat || type == TypeDesc::TypeColor ||
@@ -81,20 +81,24 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b)
return false;
}
ustring Attribute::standard_name(Attribute::Standard std)
ustring Attribute::standard_name(AttributeStandard std)
{
if(std == Attribute::STD_VERTEX_NORMAL)
if(std == ATTR_STD_VERTEX_NORMAL)
return ustring("N");
else if(std == Attribute::STD_FACE_NORMAL)
else if(std == ATTR_STD_FACE_NORMAL)
return ustring("Ng");
else if(std == Attribute::STD_UV)
else if(std == ATTR_STD_UV)
return ustring("uv");
else if(std == Attribute::STD_GENERATED)
else if(std == ATTR_STD_GENERATED)
return ustring("generated");
else if(std == Attribute::STD_POSITION_UNDEFORMED)
else if(std == ATTR_STD_POSITION_UNDEFORMED)
return ustring("undeformed");
else if(std == Attribute::STD_POSITION_UNDISPLACED)
else if(std == ATTR_STD_POSITION_UNDISPLACED)
return ustring("undisplaced");
else if(std == ATTR_STD_MOTION_PRE)
return ustring("motion_pre");
else if(std == ATTR_STD_MOTION_POST)
return ustring("motion_post");
return ustring();
}
@@ -164,24 +168,28 @@ void AttributeSet::remove(ustring name)
}
}
Attribute *AttributeSet::add(Attribute::Standard std, ustring name)
Attribute *AttributeSet::add(AttributeStandard std, ustring name)
{
Attribute *attr = NULL;
if(name == ustring())
name = Attribute::standard_name(std);
if(std == Attribute::STD_VERTEX_NORMAL)
if(std == ATTR_STD_VERTEX_NORMAL)
attr = add(name, TypeDesc::TypeNormal, Attribute::VERTEX);
else if(std == Attribute::STD_FACE_NORMAL)
else if(std == ATTR_STD_FACE_NORMAL)
attr = add(name, TypeDesc::TypeNormal, Attribute::FACE);
else if(std == Attribute::STD_UV)
else if(std == ATTR_STD_UV)
attr = add(name, TypeDesc::TypePoint, Attribute::CORNER);
else if(std == Attribute::STD_GENERATED)
else if(std == ATTR_STD_GENERATED)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == Attribute::STD_POSITION_UNDEFORMED)
else if(std == ATTR_STD_POSITION_UNDEFORMED)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == Attribute::STD_POSITION_UNDISPLACED)
else if(std == ATTR_STD_POSITION_UNDISPLACED)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == ATTR_STD_MOTION_PRE)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == ATTR_STD_MOTION_POST)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else
assert(0);
@@ -191,7 +199,7 @@ Attribute *AttributeSet::add(Attribute::Standard std, ustring name)
return attr;
}
Attribute *AttributeSet::find(Attribute::Standard std)
Attribute *AttributeSet::find(AttributeStandard std)
{
foreach(Attribute& attr, attributes)
if(attr.std == std)
@@ -200,7 +208,7 @@ Attribute *AttributeSet::find(Attribute::Standard std)
return NULL;
}
void AttributeSet::remove(Attribute::Standard std)
void AttributeSet::remove(AttributeStandard std)
{
Attribute *attr = find(std);
@@ -218,7 +226,7 @@ void AttributeSet::remove(Attribute::Standard std)
Attribute *AttributeSet::find(AttributeRequest& req)
{
if(req.std == Attribute::STD_NONE)
if(req.std == ATTR_STD_NONE)
return find(req.name);
else
return find(req.std);
@@ -240,14 +248,14 @@ void AttributeSet::clear()
AttributeRequest::AttributeRequest(ustring name_)
{
name = name_;
std = Attribute::STD_NONE;
std = ATTR_STD_NONE;
type = TypeDesc::TypeFloat;
element = ATTR_ELEMENT_NONE;
offset = 0;
}
AttributeRequest::AttributeRequest(Attribute::Standard std_)
AttributeRequest::AttributeRequest(AttributeStandard std_)
{
name = ustring();
std = std_;
@@ -296,7 +304,7 @@ void AttributeRequestSet::add(ustring name)
requests.push_back(AttributeRequest(name));
}
void AttributeRequestSet::add(Attribute::Standard std)
void AttributeRequestSet::add(AttributeStandard std)
{
foreach(AttributeRequest& req, requests)
if(req.std == std)
@@ -308,7 +316,7 @@ void AttributeRequestSet::add(Attribute::Standard std)
void AttributeRequestSet::add(AttributeRequestSet& reqs)
{
foreach(AttributeRequest& req, reqs.requests) {
if(req.std == Attribute::STD_NONE)
if(req.std == ATTR_STD_NONE)
add(req.name);
else
add(req.std);
@@ -324,7 +332,7 @@ bool AttributeRequestSet::find(ustring name)
return false;
}
bool AttributeRequestSet::find(Attribute::Standard std)
bool AttributeRequestSet::find(AttributeStandard std)
{
foreach(AttributeRequest& req, requests)
if(req.std == std)