-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Regularlise coordinate system #521
Conversation
- Corrected discrepancy between cpu and ocl versions (also crash in cpu version) at low roughnesses - Glossy2 is now double-sided
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. |
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? |
Yes, please, we need separate PR for each feature. |
…Core into regualriseCoordinateSystem
Done - I think. |
Thanks, merged. |
…with glossy material (pull request #521)
Actually, there was an error in the OpenCL code of this patch. It was breaking volume rendering on GPUs ... bugs work in mysterious ways. |
Ah - quite right. Thanks for picking that one up. |
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.
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.