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

Hololens2 performance issues #222

Open
iamx1212 opened this issue Jan 26, 2024 · 11 comments
Open

Hololens2 performance issues #222

iamx1212 opened this issue Jan 26, 2024 · 11 comments

Comments

@iamx1212
Copy link

Hello, I used UnityVolumeRendering to load a CT (Dicom) image and deployed it to the Hololens2 real machine. After opening it, it was very stuck. The model can be displayed but when I look at the model, it becomes very slow and stuck. What should I do?

@iamx1212
Copy link
Author

微信图片_20240126141103

@mlavik1
Copy link
Owner

mlavik1 commented Jan 26, 2024

Hi @iamx1212 !

I don't have a Hololens device myself, but I know there have been other users using this plugin with Hololens, so I believe it should be possible to get acceptable performance.

First of all: Is this a publically available dataset that you can share with me?

If not, could you check how large the dimension of the dataset is? If it's very large, you could consider:
A: Open the volume rendering settings window, enable "Show downscale prompt", re-import your DICOM and choose "yes" when asked if you want to downscale the dataset
or B (better): Use some software (I think 3D Slicer can do that) to downsample the dataset.

That should reduce the graphics memory usage (and memory bandwidth usage), and probably improve performance.

Also, you might want to check the appearance settings on the VolumeRenderedObject:

  • Enable ray termination: ON
  • Disable cubic interpolation: OFF
  • Disable Lighting: OFF (unless you can afford it - it's expensive though)

@iamx1212
Copy link
Author

I have been trying to solve the lag problem recently, but it hasn't had a particularly good effect.
Uploading CT.zip…

@mlavik1
Copy link
Owner

mlavik1 commented Mar 22, 2024

Just a thought: Is the performance problem bad in all render modes? (Direct volume rendering vs isosurface rendering)? Maybe not so much in Maximum Intensity Projection mode?

I saw that Hololens 2 uses a resolution of 2880x1406, which might make volume rendering a bit tricky - considering its GPU. You could try change the resolution, or in Unity: UnityEngine.XR.XRSettings.renderScale = 0.5f or something. Might look really bad, but would be interesting to see how much it affects the performance.

You could also try to change the MAX_NUM_STEPS values (one for each render mode) in the DirectVolumeRenderingShader.shader

@iamx1212
Copy link
Author

Yes, there will be lag in volume rendering, maximum density, and isosurface drawing at MAX-NUM-STEPS 512. Lowering the MAX-NUM-STEPS value can slightly alleviate this.
I used UnityEngine XR The XRSettings.renderScale=0.5f method can also alleviate lag, but my method may have been incorrect. When using it with Holo on my head, the entire model shook noticeably as I walked around.
script.zip

@mlavik1
Copy link
Owner

mlavik1 commented Mar 31, 2024

@iamx1212 hmm, if even maximum intensity projection mode is slow, then I'm afraid it's not looking very promising.. Since I don't own a Hololens device it's hard for me to investigate if this is just due to the hardware, or if there are any performance issues, but I think I'm running out of suggestions now...
Do you need to run the app natively on the Hololens, or would it be an option to run it through a PC's GPU?
I don't have experience with Hololens, but on Oculus you have Link/Airlink for that. I saw there's something called "Holographic Remoting Player" for Hololens.

@DiangF
Copy link

DiangF commented Apr 15, 2024

Do you have any measures to address the issue of loading rendering on HoloLens? thanks

@mlavik1
Copy link
Owner

mlavik1 commented Apr 19, 2024

@DiangF Hmm, what do you mean with "loading rendering"? Are you running into any issues loading datasets?

@iamx1212 I've recently added a new "sampling rate multiplier" setting. If you check out latest from "master" branch you can try it out.
Try reducing the value and see how much the FPS improve. Feel free to share here! :)

图片

I now also do opacity correction, so the only visual different should now be more/less artifacts (the colours don't change like they did before)

@shiauyang
Copy link

Hi @mlavik1,
Firstly, be pretty appreciating at your EasyVolumeRenderer project, it helps me a lot.

I use HoloLens2 to display only slice, so changes MAX_NUM_STEPS, disable the DEPTHWRITE_ON and disable cubic interpolation is not helpful for me to improve FPS on HoloLens2, it all for volume rendering.

And i have downscale my .dcm from 100 MB to 80MB, it improves FPS a little, but when rendering slice, the FPS will be the same low.

You said that use URP will help boost FPS, i change my unity project to URP and change SliceRenderingShader.shader to URP, it successufully run on HoloLens2 but the performance remains the same.

Is there any suggestion for improve FPS for only slice rendering?

Finally, thank you very much

@mlavik1
Copy link
Owner

mlavik1 commented Aug 28, 2024

Hi @shiauyang ,

I still don't have a Hololens device available, so I'm unfortunately not able to look into that myself, but I'll try to answer what I can:

  • You no longer need to change the "MAX_NUM_STEPS" value. Instead, you can now adjust the "Sampling rate multiplier" in the VolumeRenderedObject inspector (see screenshot in comment above)
  • I don't think URP should improve performance for you on Hololens. URP enables you to use FidelityFX upscaling, but I don't think that's available on Hololens standalone..
  • Regarding downscaling: Did you downscale the size of the whole dataset, in a tool like Slicer?

Also, what do you mean when you say "rendering slice"? Are you talking about the "Slice renderer" window? I would suspect that one to be really fast, but you may need to disable the VolumeRenderedObject, or at least its' MeshRenderer.

@shiauyang
Copy link

Thank you for your constructive replied @mlavik1,

There are some methods I tried to improve FPS for HoloLens2 APP natively:

In my project, after add slice in Slice renderer, there will be new object 'slice plane' under VolumeContainer. I just want to render it without 3D volume, so, yes, I disable MeshRenderer in MeshRenderer.

From my experiment, adjusting Sampling rate multiplier didn't change FPS in my HoloLens2, I think is about volume rendering, not slice rendering.

Both URP and HDRP work well for HoloLens2, I see your post about performance to do it, thinking about self-define shader at SRP can improve FPS, and the results are same as you think. It can't improve FPS. https://github.com/mlavik1/UnityVolumeRendering/blob/master/Documentation/General/VolumeRendering/ShadowVolumes.md

About render scale, I have tried XRSettings.renderScale = 0.5f and 0.1f for both built-in render pipeline and URP, however, the FPS remained unchanged and because the lower resolution, HoloLens cannot render object stably and precisely.

Regarding downscaling, both python scripts and 3D slicer can downsample my CT dataset, nonetheless, there will some data miss which is not I want. Hence, I will not use this method despite it can boost FPS.

Here's my thought: Batches (drawcall) is pretty slow <10, so I don't think is CPU-bound and vertices is <600 which is acceptable for HoloLens2 GPU, but FPS is about 15, really don't have any ideas.

Do you have any suggestion for changing SliceRenderingShader.shader or any idea?

Pretty appreciate for your work, time and replied.

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

No branches or pull requests

4 participants