1 | float scale = tan(camera.fov * 0.5); |
刚开始看这段代码的时候,没有想清楚代码里预设的内容,也即成像平面的距离是1;这里面注意两个地方,成像平面(的距离,z方向的位移)上的点来确定光线的方向,以及对焦距离确定对焦点。
Near Plane(近平面) 是裁剪用的,距离相机很近(比如 0.01),比它更近的物体不渲染。在光栅化管线中有意义,在 path tracing 中通常不需要。
1 | float scale = tan(camera.fov * 0.5); |
刚开始看这段代码的时候,没有想清楚代码里预设的内容,也即成像平面的距离是1;这里面注意两个地方,成像平面(的距离,z方向的位移)上的点来确定光线的方向,以及对焦距离确定对焦点。
Near Plane(近平面) 是裁剪用的,距离相机很近(比如 0.01),比它更近的物体不渲染。在光栅化管线中有意义,在 path tracing 中通常不需要。
their normal points away from xMesh类,包含vao/vbo/ibo这些OpenGL资源,包含了析构函数,在释放资源时候通过glDeleteBuffers 和 glDeleteVertexArrays销毁了这些资源。Mesh通过std::vector管理,添加Mesh使用了push_back或emplace_back,会导致不同的Mesh持有的vao/vbo/ibo一样。 几个问题:
在 StartupModule() 中添加调用栈输出的方法 方法 1:使用 FPlatformStackWalk::StackWalkAndDump
1 | #include "HAL/PlatformStackWalk.h" // 需要添加这个头文件 |
1 | #include "HAL/PlatformStackWalk.h" |
| 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 |
Reflectance Equation(反射方程)
作为脚本附到GameObject上,我选择附到相机上 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目录下
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++编程中,虚函数和模板都是强大的特性,但它们不能结合使用。许多开发者都会疑惑:为什么不能声明虚函数模板?这个限制背后的技术原理是什么?本文将深入探讨这个问题,分析技术可行性,并讨论可能的解决方案。