Looooong / Unity-SRP-VXGI

Voxel-based Global Illumination using Unity Scriptable Render Pipeline
MIT License
766 stars 62 forks source link

[Question] Use case of voxel GI #64

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi Looooong, could you give me an idea of use cases where voxel GI is a better option? I think that voxel GI would better for procedural worlds. Am I right? Or am I not even close?

Looooong commented 4 years ago

You are right. The general case of using VXGI is for dynamically generated world, either by procedural algorithm or by user input. Another use case is for extremly open world because generating indirect lightmapping will take days or weeks and the result lightmap would take dozen of Gigabytes on the hard drive. You can think of using VXGI in a situation where pre-baked lighting is neither possible or practical.

ghost commented 4 years ago

Would you say VXGI is more expensive than running Baked GI and Realtime GI together?

Looooong commented 4 years ago

That depends on what "Realtime GI" does.

ghost commented 4 years ago

I don't understand. I'm talking about a scene with same conditions for both.

jeske commented 4 years ago

Both precomputed lightmaps, and unity "precomputed" realtime gi, require static world geometry... VXGI does not... If you have static world geometry, use precomputed techniques, if you don't, precomouted techniques don't work so the question is moot.

Precomputed lightmaps have extremely low framerate performance cost.. they take a little extra texture memory, and an extra lookup, but these costs are generally low. The costs of precomputed lightmaps are the inability to move assets because of the static lighting bake and increased world asset storage sizes from the saved lightmaps.

By realtime GI i suspect you mean the depreciated Enlighten "precomputed realtime gi" system. This precomputes lighting bounce for static world geometry, so it can be applied to dynamic objects in real time. The cost of this is much less than VXGI, but it also requires static world geometry.

VXGI is completely dynamic, meaning there is no requirement for static world geometry. However, in addition to more GPU memory consumption and more performance cost, it also has many limitations.. and visual artifacts (like flickering when objects move and voxel aliasing artifacts). We are working to minimize the vixel artifacts. minimizing flickering requires temporal smoothing, which slows light reactivity. As a result, vxgi is best suited to situations with dynamic world building where precomouted techniques are unviable, and artifacts are toloeable.. such as architecture previs.

ghost commented 4 years ago

Thank you for your patience, @jeske. I think I understand now. Given the same non-static scene, like a dynamically generated world, Enlighten would have a lesser cost than VXGI, but VXGI gives a result closer to static lighting. Is this right?

I'm working on and off on a prefab-based dungeon generator and VXGI sounds cool. I used to follow SEGI, back in the day. He showcased SEGI while greyboxing levels with probuilder https://www.youtube.com/watch?v=LolerRBhaAs. I don't know if this is another use case for VXGI. What do you think?

jeske commented 4 years ago

No. Given a non-static dynamically generatated world... Enlighten doesn't work.

Enlighten takes a static set of world geometry, and does a long slow "precalculation" of light transmission in the static scene. Then, at runtime, you can put dynamic objects (like players, or cars) in that scene, and Enlighten uses it's precalculated data to approximate indirect light transmission between the dynamic objects and the static scene. To change the scene geometry with Enlighten you need to reload Unity, change it, and rebaked the Enlighten precalculation step.

SEGI, and Unity-SRP-VXGI both do all their indirect lighting calculations in real time, based on voxel GI rendering and light transmission. So they work with arbitrary dynamic geometry. However, there are some real limitations in how they operate. To get something with fewer compromises we need hybrid ray-traced GI using newer DXR/RTX hardware.

As for probuilder/SEGI.... I do think that VXGI can be a good interactive visualization for GI. If the game doesn't allow truly dynamic world building / world-change, then right now it's probably best to still bake an offline lightmap. However, if the world can be changed in real time, then the only GI solutions out there short-of hybrid raytracing are voxel GI solutions like VXGI (and the variants).

ghost commented 4 years ago

Oh, thank you. This explains why I was getting "weird" results in the past. There is a lot of information in youtube and reddit, but is mostly wrong whenever the subject is no more for beginners. I will close the issue now. I'm downloading the editor in Linux, I hope VXGI works for me.