In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you the example analysis of the light probe in unity3d, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Demand
Conventional unity baked light probes use third-order spherical harmonics to store 9 float3 data. Generally, the number of probes in the project is not too large, so there is no need to consider the memory problem. But I participated in the life and death sniper 2 (click to watch the game video) project, there is an open world, all lightmap plus lightprobe memory costs more than 500m. So I realized a set of VLM baking method, which increases the baking speed by 10 times and saves 22 times the video memory cost. This solution is too complicated. I'm just sharing one of the compression techniques here. If you also need to compress for other reasons or because there is a light leakage in the tail of the spherical harmonic model, you can refer to my practice.
Basic ideas
The first thing that comes to mind must be the second-order spherical harmonic, because many bosses have said that the accuracy is enough. And unity's realtime gi seems to use the second order. The reason why I did not use the second order is that the spherical harmonic algorithm is not fully mastered. It is very difficult to control the reverse construction and compression according to the color, especially the hemispheric copy (copying the color from one direction of sh to another direction of sh) according to the color reverse construction and compression tool. Although you can find the algorithm, if you, like me, are a little worried about using the algorithm that you do not fully master. Then it is suitable for storage in such an intuitive way.
We use a rich baking situation as the test benchmark.
The spherical harmonic of unity engine is taken as the reference.
The first thing that comes to mind is that the cubemap xyz stores a color in six positive and negative directions. When sampling, you only need to calculate max (0ddot (dir,normal)) * colr; 6 times to get a good result as follows.
6-direction color simulation
The rendering algorithm is also super-simple, and the weight can be calculated in each direction. Is it very close?
Upgrade ideas (the beginning of the real play)
Although the simulation is approximate, six colors are not much less than nine, and second-order spherical harmonics only need four colors, so I'm going to start using the 4-direction axis. I think of a regular tetrahedron, because the four vertices are symmetrical, that is, the mathematical meaning is exactly the same, so the angles between the two of the four axes obtained by the center pointing to the four vertices are all the same. so it is very suitable to establish a 4-axis coordinate system (which should be considered as a non-Cartesian coordinate system). You can choose a direction of four axes by calculating or querying a fixed angle. I chose a TetrahedroDirs = {new Vector3 (- 0.8164966f,-0.33331f,-0.4714046f), new Vector3 (0.8164966f,-0.33331f,-0.4714046f), new Vector3 (0,-0.33331f, 0.9428091f), new Vector3 (0,1,0)} Is that a vertex is upward. Because there are only 4 colors, it is easy to use 3 pictures to store. The effect can be seen that the error is serious, in fact, the indirect light contribution of the effect is not large, and the gap is not sensitive.
Simulation effect of 4-axis coordinate system
The code is also very simple, why you can think about it by yourself than Cartesian coordinate system + 1 rgba 3, you can actually further reduce it by 75%, because you can set only one color in a large area and record only the intensity of indirect light, so that 4 intensities can be stored in a 1max 7 capacity of only the engine. If this limit compression does not match the project, you can make a scene use only 256 colors and then each probe has an extra byte in the color index. 256 colors with 256 intensity and interpolation calculation is also very rich.
Actual effect of game project on PC
Traditional lightmap+lightprobe baking dynamic object static object indirect light is inconsistent, but static object indirect light rich new pure probe baking probe compression mode is the case of the 4-axis coordinate system, dynamic and static are unified, but the details are not rich.
Significant memory / explicit memory gain
0.58g to 23m compressed to 3.87%
Of course, the huge benefit of memory / video memory comes not directly from this probe scheme but from the implementation of my VLM, which is used by a large number of probes in VLM.
The above is all the contents of the article "sample Analysis of Lighting probes in unity3d". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.