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

Performance: instead of "sort every N frames", add option to only sort when orientation changes enough #34

Open
andybak opened this issue Oct 15, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@andybak
Copy link

andybak commented Oct 15, 2023

I've been experimenting with VR (thanks to the fix generously provided by @skaale here: https://x.com/DSkaale/status/1712462036146553120?s=20 )

and it works brilliantly.

I tried using the "sort every n frames" option to improve the framerate but there's enough micro-movements of one's head that the effect is a little distracting. But it got me thinking. Sorting is only neccesary when the view has transformed a certain amount. Maybe the logic for sorting could be based around a certain threshold (maybe a separate threshold for orientation and translation?)

Would this also benefit non-VR use cases?

@aras-p aras-p changed the title Lazy Sorting Sorting: instead of "sort every N frames", add option to only sort when orientation changes enough Oct 15, 2023
@aras-p
Copy link
Owner

aras-p commented Oct 15, 2023

Yeah that might work, keeping this open as a todo.

I don't understand why VR fix shared on that tweet would work, btw. It seems to assign a variable to itself, and also use a shader variable that is not provided for compute shaders to begin with? (that, or I don't understand anything about how VR is integrated into Unity, which is also a possibility)

@skaale
Copy link

skaale commented Oct 15, 2023 via email

@aras-p
Copy link
Owner

aras-p commented Oct 16, 2023

@skaale what I don't understand is this, line by line:

float4x4 projMatrix;
projMatrix = UNITY_MATRIX_P; // 1
projMatrix._13_23_33_43 = projMatrix._13_23_33_43; // 2

1st line assigns a shader variable that is not provided by Unity into compute shaders. It might just happen to work correctly, but only by accident. That is, UNITY_MATRIX_P does not mean anything inside a compute shader.

2nd line assigns the same matrix row to the same matrix row? Why?

@skaale
Copy link

skaale commented Oct 16, 2023 via email

@aras-p aras-p added the enhancement New feature or request label Oct 18, 2023
@aras-p aras-p changed the title Sorting: instead of "sort every N frames", add option to only sort when orientation changes enough Performance: instead of "sort every N frames", add option to only sort when orientation changes enough Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants