happy-turtle / oit-unity

Order-independent Transparency Implementation in Unity with Per-Pixel Linked Lists
Apache License 2.0
181 stars 25 forks source link

optimize the clear head method from SetData to a CS kernel #11

Closed SnowWindSaveYou closed 1 year ago

SnowWindSaveYou commented 1 year ago

it can improve the performance in most scenarios, but still an limitation, it can't work properly on a very large screen (e.g. 4K HUD 3840*2160) due to the buffer counts over the max thread group. but it can be fixed by split thread size into many dispatches with an index offset. original optimized

happy-turtle commented 1 year ago

Thank you! Wow, that really is a huge performance boost. Can we maybe prevent the maximum screen size by using a two (or later even three-dimensional) number of threads? And then offset by the second dimension. I will try to explain in code comments.

SnowWindSaveYou commented 1 year ago

Thank you! Wow, that really is a huge performance boost. Can we maybe prevent the maximum screen size by using a two (or later even three-dimensional) number of threads? And then offset by the second dimension. I will try to explain in code comments.

i fixed it by using a for loop with buffersize in compute shader.

happy-turtle commented 1 year ago

Ah nice, I would still like to try a two-dimensional number of threads though. It would remove those big numbers. I can look at it at the next opportunity

happy-turtle commented 1 year ago

Thanks a lot for this! The whole process is a lot more performant now. I added two-dimensional thread groups and did some cleanup to align more with the other shaders.