Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Principled BSDF - anisotropic roughness rotation #1467

Open
tomasiser opened this issue Jan 23, 2025 · 5 comments
Open

Principled BSDF - anisotropic roughness rotation #1467

tomasiser opened this issue Jan 23, 2025 · 5 comments

Comments

@tomasiser
Copy link
Member

tomasiser commented Jan 23, 2025

Hello,

the Principled BSDF supports anisotropic roughness with the anisotropic float parameter. However, inspecting the calc_dist_params function, it seems to me that the anisotropy is always in the same orientation, it's just the aspect ratio that changes.

In Blender, for example, the specular part of the principled material has an additional parameter "Anisotropic Rotation" to control the orientation. Inspecting the Cycles source codes in node_principled_bsdf.osl show that they use this parameter to rotate the tangent.

What would be the easiest way to incorporate it into Mitsuba 3? I am guessing it might be sufficient to modify calc_dist_params such that it returns ax and ay corresponding to the rotation.

A super trivial fix would be to simply allow users to plug-in their own alpha_u and alpha_v parameters in Disney BRDF similarly to the API of rough conductors etc.


Blender docs:
Image

@ziyi-zhang
Copy link
Contributor

Hi @tomasiser,

I wasn't aware of the anisotropic rotation parameter before, and I didn’t see it mentioned in the Disney notes either.
Thanks for pointing out the Cycles code --- their approach of rotating the tangent direction before computing the NDF is quite straightforward.

it might be sufficient to modify calc_dist_params such that it returns $\alpha_x$ and $\alpha_y$ corresponding to the rotation.

This may not work. A rotated GGX, when expressed in the original coordinate system, introduces non-zero covariance terms, which microfacet.h does not support (and is impossible to support since the sampling and visible normal sampling would be a mess). That is, I don't think there’s a pair of $\alpha$​ that can exactly reproduce the shape of the target rotated function.

@merlinND
Copy link
Member

merlinND commented Feb 4, 2025

I think I remember that @tizian had achieved something like this with another BSDF. Do you know if the same would be achievable with principled?

@tomasiser
Copy link
Member Author

tomasiser commented Feb 4, 2025

Thank you for the answers! I have to admit that I have not realized that rotating the tangent is not equivalent to just adjusting $\alpha_u$ and $\alpha_v$. It makes me question how much parametrization anisotropy really needs. I still think that the current Mitsuba implementation is too simplistic in the sense that the anisotropy parameter is only adjusting the aspect ratio in one direction.

@ziyi-zhang you're right that the anisotropy rotation is not part of the original Disney paper, so it must be something they did extra in Blender.

If you have already implemented this for another BRDF, it would be nice to see!

@tizian
Copy link
Contributor

tizian commented Feb 4, 2025

Hi all,
Anisotropic tangent rotations can be implemented at different levels of a renderer.

  1. Directly as part of the microfacet distribution, see e.g. Jonathan Dupuy's PhD thesis Section 2.3 about "Elliptically Anisotropic Roughness": https://hal.science/tel-01291974. As you discussed, adjusting alpha_x, alpha_y isn't enough and a third parameter needs to be added. The thesis chapter describes two possible parameterizations.
  2. As a separate BSDF plugin that has a nested BSDF that is evaluated with a rotated shading frame, similar to how normal mapping is implemented currently. I've done this before for an old project, in a now outdated version of Mitsuba: https://github.com/tizian/layer-laboratory/blob/master/src/bsdfs/tangentrotation.cpp
  3. Outside of the material/BSDF code by directly modifying the tangents of the intersected geometry somehow. I would guess this is how Disney chose to implement it and why it isn't discussed in their tech report about the BSDF.

It's a fairly important parameter in practice to control anisotropy so it's not just something Blender added on top. Here is e.g. the Renderman documentation about it: https://rmanwiki-26.pixar.com/space/REN26/19661705/PxrTangentField

@tomasiser
Copy link
Member Author

tomasiser commented Feb 5, 2025

@tizian Thank you so much for your insight and code! Do I assume correctly that the AngleEncoding::Direct in your implementation would be the equivalent to Blender Cycles? Of course +- a possible orientation difference between Mitsuba and Blender.

EDIT: Actually the Renderman documentation you provided explains it quite well and even provides examples of such input textures. Great! If I have the time I could try to port your code to the current Mitsuba 3 and make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants