- 方法
- A reflective shadow map is an extension to a standard shadow map, where every pixel is considered as an indirect light source.
- 一次bounce间接光照的粗糙近似
- survey
- soft shadow方法
- RSM都可以结合
- Instant Radiosity
- pass太多
- ray tracing
- 难做到高分辨率的交互/实时
- soft shadow方法
- 算法
- 公式
- reflective shadow map,from light view
- depth
- world-space position
- normal
- reflected flux
- 光照计算
- 采样shading位置周围的rsm像素,作为间接光照光源
- screen space interpolation
- 先渲染低分辨率的间接光照,然后在渲染完整分辨率的间接光照,如果着色点周围的低分辨率位置可用(世界坐标足够近),就使用低分辨率结果插值得到,否则,就通过完整的采样计算
- 采样shading位置周围的rsm像素,作为间接光照光源
- 公式
- 局限
- 只考虑diffuse
- 不考虑间接光照光源的遮挡关系
- 着色点只考虑距离范围内的像素影响
- 细节
- 次级光源的可视性,是通过发现和光线方向的cos判断的(
),也就是文章里的 their normal points away from x
- 次级光源的可视性,是通过发现和光线方向的cos判断的(
C++ vector扩容导致的OpenGL资源析构
问题
Mesh类,包含vao/vbo/ibo这些OpenGL资源,包含了析构函数,在释放资源时候通过glDeleteBuffers 和 glDeleteVertexArrays销毁了这些资源。Mesh通过std::vector管理,添加Mesh使用了push_back或emplace_back,会导致不同的Mesh持有的vao/vbo/ibo一样。 几个问题:
- 析构后,vao/vbo/ibo应该设置成一个无效值
- std::vector没有分配足够内存,插入元素后,可能导致空间的重新分配,旧元素的拷贝或移动到新位置,旧元素内存析构掉。
- 一个OpenGL资源申请、释放、在申请,可能是同一个id
新手司机倒车技巧
Unreal4: 打印当前调用栈
在 StartupModule() 中添加调用栈输出的方法 方法 1:使用 FPlatformStackWalk::StackWalkAndDump
1 | #include "HAL/PlatformStackWalk.h" // 需要添加这个头文件 |
1 | #include "HAL/PlatformStackWalk.h" |
Light Unit in Graphics
单位
| QUANTITY | RADIOMETRIC | PHOTOMETRIC |
|---|---|---|
| Power | W | Lumen (lm) = cd·sr |
| Power Per Unit Area | W/m² | Lux (lx) = cd·sr/m² = lm/m² |
| Power Per Unit Solid Angle | W/sr | Candela (cd) |
| Power Per Unit Area Per Unit Solid Angle | W/m²·sr | cd/m² = lm/m²·sr = nit |
RTR4 Reading Notes
11. Global Illumination
11.1 The Rendering Equation
Reflectance Equation(反射方程)
Unity截屏脚本
作为脚本附到GameObject上,我选择附到相机上
Screenshot.csview raw 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38// 创建这个脚本,挂在任意 GameObject 上
using UnityEngine;
using System.IO;
public class Screenshot : MonoBehaviour
{
[Header("截屏设置")]
public KeyCode screenshotKey = KeyCode.F12;
public int superSize = 1; // 1 = 原始分辨率, 2 = 2倍分辨率
void Update()
{
if (Input.GetKeyDown(screenshotKey))
{
TakeScreenshot();
}
}
void TakeScreenshot()
{
string folderPath = Path.Combine(Application.dataPath, "..", "Screenshots");
// 创建文件夹
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
// 生成文件名
string fileName = $"Screenshot_{System.DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png";
string filePath = Path.Combine(folderPath, fileName);
// 截图
ScreenCapture.CaptureScreenshot(filePath, superSize);
Debug.Log($"截图已保存: {filePath}");
}
}修改编辑器UI,作为菜单使用;需要放到scene文件同目录的Editor目录下
效果如下:Editor/ScreenShotTest.csview raw 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
public class ScreenShotTest : MonoBehaviour
{
//ctrl + shift + y 截图
[MenuItem("Screenshot/Take Screenshot %#y")]
private static async void Screenshot()
{
string folderPath = Directory.GetCurrentDirectory() + "\\Screenshots";
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
var timestamp = System.DateTime.Now;
var stampString = string.Format("_{0}-{1:00}-{2:00}_{3:00}-{4:00}-{5:00}", timestamp.Year, timestamp.Month, timestamp.Day, timestamp.Hour, timestamp.Minute, timestamp.Second);
ScreenCapture.CaptureScreenshot(Path.Combine(folderPath , stampString + ".png"));
Debug.Log("截图中......");
//等待5秒
await Task.Delay(5000);
System.Diagnostics.Process.Start("explorer.exe", folderPath);
Debug.Log("截图" + stampString + ".png");
}
void OnMouseDown()
{
ScreenCapture.CaptureScreenshot("SomeLevel.png");
}
}
C++特化模板的内部匹配参数代码解析
C++模板成员函数可以是虚函数吗
C++模板成员函数可以是虚函数吗
引言
在C++编程中,虚函数和模板都是强大的特性,但它们不能结合使用。许多开发者都会疑惑:为什么不能声明虚函数模板?这个限制背后的技术原理是什么?本文将深入探讨这个问题,分析技术可行性,并讨论可能的解决方案。
SVD求解配准的推导过程
配准误差函数
下面整理配准中计算推导过程,包含:平移