Calculate the sh coefficient of cube Map

Source: Internet
Author: User

DX provides a set of basic functions used to operate sphereical harmonic, such as d3dshadd, d3dshdot, and d3dshevaldirection. One of them is d3dshprojectcubemap, which is used to obtain the sh coefficient from cubemap projection, it is quite useful. Generally, different sampling points need to be set when light probe is used in the game scenario, and then the corresponding probe is generated and the sh coefficient is calculated, these sh coefficients are used to calculate the effect of ambient light on objects in real time. There are two methods to calculate the sh coefficient of probe:

  • Using ray-tracing: directly emit light from the probe position to the outside and obtain the environmental sampling value at the spherical sampling point. Then, computation of the spherical harmonic coefficient is performed. In general, this method may be difficult or even slow, especially in scenarios where the game is used and the engine does not directly support light tracing;
  • Using raster cube-map: first, use the GPU rendering pipeline to generate a cube-map at the probe position, and then calculate the sh coefficient corresponding to this point on the cube-map. Generally, the scenario editor of the engine may have integrated the cube-map generation function (because cube-map is used in many places, such as various static reflection ), therefore, this method is easy to use. You only need to add a computation from cube-map to sh.

There are also two ways to calculate its corresponding sh coefficient from cube-map: the first is similar to ray tracing, however, we can directly sample the scene information in the direction of the corresponding light from the texture corresponding to the cube-map. Of course, this requires additional implementation, however, some parameters such as the number of samples can be controlled more flexibly. Another method is to useD3dshprojectcubemapTo directly perform computation. It passes in two parameters: Sh order and cube-map, return the sh coefficient of the R, G, and B channels on the corresponding order (note that sufficient coefficient space should be input according to the sh order ). After a simple trial, the effect can be improved (After calculating the sh coefficient ):

Of course, this is not only usable by light probe, but also by computing such as irradiance environment map.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.