Skip to content

Cycles : Simplify transform handling - #7136

Open
johnhaddon wants to merge 3 commits into
GafferHQ:1.7_maintenancefrom
johnhaddon:cyclesTransforms
Open

Cycles : Simplify transform handling#7136
johnhaddon wants to merge 3 commits into
GafferHQ:1.7_maintenancefrom
johnhaddon:cyclesTransforms

Conversation

@johnhaddon

Copy link
Copy Markdown
Member

I'm about to add PointInstancer support for Cycles, which will effectively mean making as many lightweight CyclesObjects as I can each with their own transform. Before doing that, let's simplify the transform handling in general, since it has a lot of cruft that doesn't seem necessary with modern Cycles.

History suggests that when I delete "redundant" code from GafferCycles I usually delete at least one thing that turned out to be necessary. But harking back to similar work for deformation blur, I've rendered a contact sheet showing various numbers of transform segments rendered across all devices and with both meshes and points - all seems to be well there :

new

- Remove unreachable code. CameraAlgo never sets `motion_position`, so we don't need to handle the different cases. It's not even clear that the different cases need different handling - I suspect not.
- Drop all the sample interpolation stuff. We learned we don't need it when refactoring the object deformation code.
- Do scaling and conversion once, instead of repeating for `set_tfm()` and `set_motion()`.
- Document weird scaling in Y, which I think should be removable in future.
As with object deformation, none of this is necessary now - Cycles happily accepts any number of samples.

@murraystevenson murraystevenson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks John, this looks like a great simplification overall. I've noted a pair of subdivision related wrinkles inline, one straightforward, the other a little vexing...

Comment on lines +1719 to +1723
if( mesh->get_subdivision_type() != ccl::Mesh::SUBDIVISION_NONE )
{
// Subdivision meshes can't be auto-instanced, so
// we should be the only one managing `subd_objecttoworld`.
assert( m_geometry.use_count() == 1 );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the addition of object-space subdivision in Cycles 5.0, we do auto-instance those meshes, so I think this should also be gated on && mesh->get_subd_adaptive_space() == ccl::Mesh::SUBDIVISION_ADAPTIVE_SPACE_PIXEL as this assert does fire on a scene with duplicated spheres all set to object-space subdivision. Looks like I missed updating this as part of the Cycles 5.0 update...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that - added in 9a4e0ea.

// Subdivision meshes can't be auto-instanced, so
// we should be the only one managing `subd_objecttoworld`.
assert( m_geometry.use_count() == 1 );
mesh->set_subd_objecttoworld( m_object->get_tfm() );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears the old code has an early-out when samples.size() == 1 and would never get here to call mesh->set_subd_objecttoworld() like we now do. As a result, transforming a pixel-space adaptive subdiv mesh with Cycles as the Viewer renderer now causes the mesh to disappear (I'm assuming because setting subd_objecttoworld is triggering an update to its adaptive subdivision, but Cycles is also expecting a fresh mesh to subdivide). So this new code is more correct, but less useful. Oy...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have been down to a missing tag_update() call, which I also added in 9a4e0ea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

2 participants