Page MenuHome

Fix normal transformation for quadratic shadow ray offset calculation
ClosedPublic

Authored by Olivier Maury (omaury) on Dec 21 2021, 1:30 AM.

Details

Summary

The current code in shadow_ray_smooth_surface_offset() systematically transforms the normal from local to world space. This defines the offset direction of the shadow ray starting position. Most of the time, I believe the normals and other geometric quantities are already in world space: wrapping the transformation with a test on sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED seems more correct to me.

Debugging this with a any simple scene of a rotated cube will do, I'm attaching one just in case.

Diff Detail

Repository
rB Blender

Event Timeline

Olivier Maury (omaury) requested review of this revision.Dec 21 2021, 1:30 AM
Olivier Maury (omaury) created this revision.
Olivier Maury (omaury) created this object with visibility "Olivier Maury (omaury)".
Olivier Maury (omaury) created this object with edit policy "Olivier Maury (omaury)".
Olivier Maury (omaury) edited the summary of this revision. (Show Details)Dec 21 2021, 1:52 AM
Olivier Maury (omaury) changed the visibility from "Olivier Maury (omaury)" to "Public (No Login Required)".
Olivier Maury (omaury) changed the edit policy from "Olivier Maury (omaury)" to "Subscribers".
Olivier Maury (omaury) edited the summary of this revision. (Show Details)Dec 21 2021, 1:55 AM

I don't see any difference in renders. I guess the patch makes sense tho.

This revision is now accepted and ready to land.Dec 28 2021, 8:19 PM

Thanks @Mikhail Matrosov (ktdfly) for taking a look, and you're right, a difference can prob be seen with the attached file only when stepping through the code, not enough samples go through this code path to make a visible difference I imagine.

A couple follow-up questions for you @Mikhail Matrosov (ktdfly) and @Brecht Van Lommel (brecht):

  • If you look at the code a little higher, there's a call to triangle_vertices_and_normals(), which does not take time into account (like shader_setup_from_ray() does for example with a call to motion_triangle_shader_setup()). I'm assuming the cases where that's a problem are very rare to be worth it, what do you think? You would need a significant non-uniform scaling animation or direct vertex deformation I guess?
  • on the admin side, once a diff is accepted, who does the landing/commit?

A couple follow-up questions for you @Mikhail Matrosov (ktdfly) and @Brecht Van Lommel (brecht):

  • If you look at the code a little higher, there's a call to triangle_vertices_and_normals(), which does not take time into account (like shader_setup_from_ray() does for example with a call to motion_triangle_shader_setup()). I'm assuming the cases where that's a problem are very rare to be worth it, what do you think? You would need a significant non-uniform scaling animation or direct vertex deformation I guess?

I think it's actually important to take motion blur into account. Significant vertex deformation is not that rare. A patch to fix that as well would be great.

  • on the admin side, once a diff is accepted, who does the landing/commit?

I do it.