-
Notifications
You must be signed in to change notification settings - Fork 817
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
[ShaderGraph] Optimized the Camera's direction node. #2485
base: master
Are you sure you want to change the base?
Conversation
I was wondering why the Labeler/label action fails, and how can I resolve it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks correct at first glance.
@LandonTownsendUnity -- just double check that it is actually returning the same value as previously.
@thomas-zeng
@LandonTownsendUnity |
Today I'm going to make a test shader to test this PR vs the original algorithm. If there is even a slight change this shader should detect it. |
CameraDirParityCheck.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me but wait for XR QA. Linked shader in comments that should help with testing.
PR changes looks good to me. |
My apologies for the delays. I was busy with other tasks and vacation. I intend to perform XR testing this week. |
@DennisDeRykeUnity were you able to preform XR testing on this PR? |
@alindmanUnity No. I'll test it briefly tomorrow on URP and HDRP with CameraDirParityCheck shader. I'll test perspective camera only since orthographic is not applicable for XR. |
First I tried testing this with the SRP packages from the PR 2485 dev branch (sienaiwun:sgcameradirection cd4bc9e) but this resulted in compiler errors with several recent versions of Unity. So I obtained the SRP packages from Graphics master ce3633b and implemented one-line code change from PR 2485 locally in this file: Next I started with the default empty 3D scene, added some cubes and capsules, and assigned them all a new material that uses Landon's Camera Direction Parity Check shader. Using the configurations below, if I do not apply head tracking (the camera remains stationary) then all the objects are black as expected.
If head tracking is enabled, then the objects blink between an assortment of solid colors due to even subtle movements of the camera. However, without XR enabled I can rotate the camera in the Editor in Play mode and see similar color blinking, so I suspect the shader only returns black if the camera rotation is the default zero values (0, 0, 0). @LandonTownsendUnity Am I correct that your shader is only expected to return black when no rotation has been applied to the camera? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Landon realized that the constant float input for his shader's Multiply node was excessive. Setting it to 10000 aleviates the color blinking, and objects are all black as expected even with XR head tracking enabled using these configurations:
- Unity 2021.2.0a1 (trunk 31233d44259e)
- URP and HDRP (Graphics master ce3633b + one-line code change from PR 2485)
- Simple test scene with Landon's CameraDirParityCheck shader applied
- Quest Link
- Multi Pass Stereo and Single Pass Instancing
- Standalone player
Also I saw no anomalies using these configurations:
- Unity 2021.2.0a1 (trunk 31233d44259e)
- URP and HDRP (Graphics master ce3633b + one-line code change from PR 2485)
- URP and HDRP* Template scenes
- Quest Link
- Single Pass Instancing
- Play mode
- For this PR I used the old "workshop" HDRP scene since I am familiar with it.
I approve this PR on behalf of Unity XR QA.
Hi guys, is this issue still open? |
I went ahead and removed Alex from the PR. Please go ahead with this! |
Purpose of this PR:
Optimized the Camera's direction node. Camera direction can be gotten directly from the UNITY_MATRIX_V matrix. Two matrix operations can be saved compared to the previous version.
Testing status:
Tested with the sample URP and HDRP projects. Both work well.