# 实时全局光照 1

## SH

![image-20230322181051217](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221810308.png)

![image-20230322181250154](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221812252.png)

![image-20230322181339962](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221813010.png)

由于 B 是 SH 的基函数具有正交性，所以只有 p = q 的时候才有值为 1

## Glossy Case

![image-20230322182024123](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221820175.png)

T 是关于 o 的函数，也投影到 SH。

i 和 o 共同组成 transport matrix 的两个维度。

该矩阵需要记录在顶点上

![image-20230322184310473](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221843590.png)

光线弹射路径

* L 光线发出，E 眼睛接收，Glosy 磨砂弹射，介于 D 粗糙平面，S 光滑镜面之间
* LE 直接看到
* LGE 一次弹射
* 其他像正则匹配

### 总结

![image-20230322184837744](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221848795.png)

只适合描述低频函数

![image-20230322184916496](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221849629.png)

## Wavelet 二维小波

![image-20220309191920557](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221903463.png)

* 给定任意函数能投影到小波的各个基函数上
* 高频留右下角度，能保留全部高频信息![image-20230322190943400](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221909511.png)
* 大部分高频信息的区域都是 0，所以能大量压缩图片大小
* Jpeg 使用离散余弦变换，类似小波变换的思路来压缩图片
* 旋转光照需要重新生成纹理

## Real-Time Global illumination 实时全局光照

解决一次间接光照的问题

### 3D Space

![image-20220309192013150](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221934212.png)

#### Reflective Shadow Maps （RSM）

**Theory**

* ShadowMap 上的每个像素点都看作次级光源，都看成漫反射，能对目标着色像素作贡献。
* ![image-20220309192055936](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221936567.png)
* ![image-20230322195004857](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221950959.png)
* 不需要存次级光源的入射光方向，只要存 irradiance 就可以，就是 ShadowMap
* 不考虑可见性，要考虑次级光源所在的表面方向

**Steps**

* 大胆假设，在着色点 ShadowMap 附近离散采样，不考虑世界空间
* 大概采样 400 个次级光源
* ![image-20220309192116503](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221936563.png)
* 通过 Depth,l world coordinate, normal, flux 等 G-Buffer 调整贡献，通常配合着延迟渲染使用，适合在手电筒的场景

![image-20230322195439293](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303221954500.png)

![image-20230322200119706](https://image-1253155090.cos.ap-nanjing.myqcloud.com/202303222001782.png)

离线渲染中 VPL (Virtual point light) 和 RSM 是类似的


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://okzkx.gitbook.io/blogs/game-tech/engine/render/tutorials/games-202/7.real-time-global-illumination-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
