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

Fix the call to anisotropic_vdf closure in OSL #2016

Merged

Conversation

niklasharrysson
Copy link
Contributor

Update the implementation of anisotropic_vdf node to call the corresponding closure in OSL.

Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

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

This looks great to me, thanks @niklasharrysson!

@jstone-lucasfilm
Copy link
Member

@niklasharrysson I just ran new GLSL/OSL render tests with this code, and there's a new difference that seem worthwhile to highlight, just to make sure it's expected:

Here's the GLSL/OSL comparison for LamaDielectric before this change:

LamaDielectric_08_24_2024

And here's the same GLSL/OSL comparison after this change:

LamaDielectric_09_16_2024

LamaDielectric is one of the nodes that makes use of a BSDF/VDF layering operation, so it's worthwhile to consider whether this change would be expected with the latest code.

@niklasharrysson
Copy link
Contributor Author

@jstone-lucasfilm That change in the OSL result was not expected. Since volumetric rendering is not supported yet in OSL testrender I would expect this change on MaterialX side to have no effect at all on our test suite results.

And even if it was supported this result looks wrong.. It looks like the refraction is changed. Perhaps there is a bug in testrender where somehow the IOR of the top closure is modified when there is a vdf closure layered as base?

@jstone-lucasfilm
Copy link
Member

I'm CC'ing @fpsunflower, in case he has thoughts on why this visual change might occur on the OSL side.

@fpsunflower
Copy link

fpsunflower commented Sep 17, 2024

That closure is ignored by testrender, so there must be something else going on here.

Actually sorry, yes, this closure does set the medium IOR to 1.0 so it will impact the result. The medium_vdf is a strict superset and lets you set the medium IOR as well.

@fpsunflower
Copy link

It could also be argued that the way testrender parses the closure tree here could be improved. Maybe anisotropic_vdf should leave the refraction_ior field alone? This way the microfacet closure would "win" when both are present.

@niklasharrysson
Copy link
Contributor Author

Yes, since anisotropic_vdf doesn't have a separate parameter for the ior of the medium, I think it should be assumed that the medium ior is the same as the ior set on the transmission BSDF (the BSDF set as top layer above the VDF).

@jstone-lucasfilm
Copy link
Member

@fpsunflower @niklasharrysson That proposed change on the OSL side sounds like a good resolution to me.

For now, should we proceed with this update to OSL shader generation in MaterialX, with the expectation that testrender will give us unexpected results in the short term?

@fpsunflower
Copy link

Yes, I will submit a PR to fix the OSL side.

@jstone-lucasfilm
Copy link
Member

Thanks @fpsunflower, and let's go ahead and merge this change from @niklasharrysson.

@jstone-lucasfilm jstone-lucasfilm merged commit 80e1b56 into AcademySoftwareFoundation:main Sep 21, 2024
34 checks passed
@fpsunflower
Copy link

OSL fix: AcademySoftwareFoundation/OpenShadingLanguage#1870

lgritz pushed a commit to AcademySoftwareFoundation/OpenShadingLanguage that referenced this pull request Sep 23, 2024
The MaterialX team noticed this issue here: AcademySoftwareFoundation/MaterialX#2016

Basically, if you add a medium through the anisotropic_vdf closure, it should not force the ior back to 1.0 as this IOR might have been changed by one of the microfacet closures. The IOR already defaults to 1.0 so cases that do not involve a microfacet closure are not affected.

Signed-off-by: Chris Kulla <[email protected]>
lgritz pushed a commit to lgritz/OpenShadingLanguage that referenced this pull request Sep 24, 2024
…ation#1870)

The MaterialX team noticed this issue here: AcademySoftwareFoundation/MaterialX#2016

Basically, if you add a medium through the anisotropic_vdf closure, it should not force the ior back to 1.0 as this IOR might have been changed by one of the microfacet closures. The IOR already defaults to 1.0 so cases that do not involve a microfacet closure are not affected.

Signed-off-by: Chris Kulla <[email protected]>
lgritz pushed a commit to lgritz/OpenShadingLanguage that referenced this pull request Sep 24, 2024
…ation#1870)

The MaterialX team noticed this issue here: AcademySoftwareFoundation/MaterialX#2016

Basically, if you add a medium through the anisotropic_vdf closure, it should not force the ior back to 1.0 as this IOR might have been changed by one of the microfacet closures. The IOR already defaults to 1.0 so cases that do not involve a microfacet closure are not affected.

Signed-off-by: Chris Kulla <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants