Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] [2021.3] Add clamp to HairAngleWorld to prevent nan from FastASin
Jira: [UUM-72279](https://jira.unity3d.com/browse/UUM-72279) As reported in JIRA, the Scene view flickers due to `NaN` output from the hair shader. It is because in `GetHairAngleWorld`, `angles.sinThetaI` can exceed the range [-1, 1] depending on the input hair `normalWS`. (The `L` vector may not be a unit vector in some cases.) * `half3x3 localToWorld = GetLocalFrame(bsdfData.normalWS, bsdfData.hairStrandDirectionWS);` * `half3 L = mul(localL, localToWorld);` I was able to see that this `NaN` problem could happen if both `T` and `L` vectors are a unit vector due to precision. `angles.sinThetaI` can slightly exceed 1.0 so the `FastASin` result will be `NaN` in this case. ![image](https://media.github.cds.internal.unity3d.com/user/3842/files/f49cd338-9620-4d69-84e3-c9248bfb8a87) By explicitly clamping the angles, we can prevent `NaN` output from `FastASin` calculation.
- Loading branch information