Skip to content

Commit 4a3e982

Browse files
committed
upd
1 parent 6440a3e commit 4a3e982

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

content/posts/foundation/pt-6-path-tracing-adventures.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
author: mos9527
3-
lastmod: 2025-12-25T18:28:45.057640
3+
lastmod: 2025-12-25T19:12:22.889619
44
title: Foundation 施工笔记 【6】- 路径追踪
55
tags: ["CG","Vulkan","Foundation"]
66
categories: ["CG","Vulkan"]
@@ -80,13 +80,14 @@ float uintToFloat(uint x) {
8080
毕竟,我们的随机数种子也是由帧序号初始化的——这样做可以将多帧,可能不同但趋近最终积分的结过积累以逼近。小记积累部分的更新:
8181

8282
```glsl
83-
// Accumulation
84-
float3 output = L;
83+
float4 output = float4(L, 1.0f);
8584
float frameCount = float(globalParams.ptAccumualatedFrames + 1);
86-
float3 prevAvg = (globalParams.ptAccumualatedFrames == 0) ? float3(0) : accumulation[pix].xyz;
87-
// Welford mean update
88-
float3 newAvg = prevAvg + (output - prevAvg) / frameCount;
89-
accumulation[pix] = float4(newAvg, 1.0);
85+
if (frameCount == 1){
86+
accumulation[pix] = lighting[pix] = output;
87+
} else {
88+
accumulation[pix] += output;
89+
lighting[pix] = accumulation[pix] / frameCount;
90+
}
9091
```
9192

9293
还有一个好处是:因为是多帧平均采样,若对镜头做jitter,这里就是一种 ~~五毛钱~~ TAA/Temporal抗锯齿的实现。Primiary Ray生成如下:
@@ -1248,11 +1249,13 @@ public BSDFSample Sample_f(float3 wo, float uc, float2 u, TransportMode, BxDFRef
12481249
12491250
##### 遗留问题
12501251
1251-
- 积累地足够久图像会以某种奇怪的规律变暗?
1252+
- 积累地足够久图像会以某种奇怪的规律变暗? **UPD:** 解决:是精度问题。积累buffer就别省着用FP16了...换成FP32解决
12521253
![image-20251225181106479](/image-foundation/image-20251225181106479.png)
12531254
1254-
- nvpro-samples 中见到一个[限制路径roughness消除firefly的trick](https://github.com/nvpro-samples/vk_gltf_renderer/blob/master/shaders/gltf_pathtrace.slang#L761),但是不知道为什么这样有效。前后对比如下(注意左上角!
1255+
- nvpro-samples 中见到一个[限制路径roughness消除firefly的trick](https://github.com/nvpro-samples/vk_gltf_renderer/blob/master/shaders/gltf_pathtrace.slang#L761),但是不知道为什么这样有效(限制PDF?需要考证
12551256
1257+
前后对比如下(注意左上角!)
1258+
12561259
```c++
12571260
// Keep track of the maximum roughness to prevent firefly artifacts
12581261
// by forcing subsequent bounces to be at least as rough

0 commit comments

Comments
 (0)