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

Regularlise coordinate system #521

Merged
merged 7 commits into from
Apr 19, 2021

Conversation

julescmay
Copy link
Contributor

@julescmay julescmay commented Apr 2, 2021

Sorry about the very long explanation of a very simple fix.

In material::Evaluate and ::Sample, the light and eye rays are expressed in a coordinate system which is local to the polygon: to a first approximation the normal to the polygon is aligned along z. Where the polygon carries a u or v, u is aligned along x in the local frame, and v is aligned along y. So far, so good.

But if the poly doesn't provide u and v, then Frame calls Vector::CoordinateSystem to invent one. It uses the polygon normal to create an orthogonal basis. But: there are two bases it could make: one where u is located somewhere on the y=0 plane, and another where v is located on x=0. It chooses based on the direction of the normal.

That means, in turn, that inside ::Evaluate and ::Sample, the light and eye rays can appear in one of two frames, with no way to find out which. So long as the material is isotropic, this doesn't matter. But if the material is anisotropic, it matters very much, because the anisotropy "grain" switches across the face of polygon, creating very objectionable seams.

I was working with some highly anisotropic materials, but even with the stock materials you can see it. Create a glossy2 or a metal with uroughness=0.7 and vroughness = 0.1, and render a ball. You can see the streaky reflections quite clearly, but you'll also see the seams around it.

cornell-texball ocl error (Incorrect - note seam to the right side of the ball. Also note very slight seam on the left wall)
cornell-texball ocl (Correct: no seams)

This mod selects the frame where u is horizontal in world space, and v points as vertically as possible (no matter the orientation of the poly). Where the poly faces directly upwards, it adopts a standard frame, were v points along z. Inside ::Evaluate and ::Sample the local frame's x will always have z=0 in world space, and y will almost-always have z != 0.

The change should be invisible to isotropic materials, and should improve anisotropic ones.

Jules May added 3 commits April 2, 2021 11:04
- Corrected discrepancy between cpu and ocl versions (also crash in cpu version) at low roughnesses
- Glossy2 is now double-sided
@julescmay julescmay changed the base branch from master to for_v2.6 April 2, 2021 12:29
@Dade916
Copy link
Member

Dade916 commented Apr 16, 2021

It looks like this patch is mixed with the other one (#519) so it is not usable in its current form.

I assume the "Fixes to glossy2 material" commit shouldn't be there.

@julescmay
Copy link
Contributor Author

That's right. I noticed I'd checked the glossy2 changes into master (and not into the bracnh I thought I was on). Do you want me to redo this?

@Dade916
Copy link
Member

Dade916 commented Apr 18, 2021

Yes, please, we need separate PR for each feature.

@julescmay
Copy link
Contributor Author

julescmay commented Apr 18, 2021

Done - I think.

…cmay/LuxCore into regualriseCoordinateSystem"

This reverts commit 38035a6, reversing
changes made to a24fc5c.
@Dade916 Dade916 self-requested a review April 19, 2021 10:33
@Dade916 Dade916 self-assigned this Apr 19, 2021
@Dade916 Dade916 merged commit cf2a27e into LuxCoreRender:for_v2.6 Apr 19, 2021
@Dade916
Copy link
Member

Dade916 commented Apr 19, 2021

Thanks, merged.

Dade916 added a commit that referenced this pull request Apr 19, 2021
Dade916 added a commit that referenced this pull request May 24, 2021
@Dade916
Copy link
Member

Dade916 commented May 24, 2021

Actually, there was an error in the OpenCL code of this patch. It was breaking volume rendering on GPUs ... bugs work in mysterious ways.

Dade916 added a commit that referenced this pull request May 24, 2021
@julescmay
Copy link
Contributor Author

Ah - quite right. Thanks for picking that one up.

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.

2 participants