Initial commit: Minecraft 光追着色器包(从零实现的 path tracing)

This commit is contained in:
WpyQwq
2026-09-19 12:06:22 +08:00
commit 59e30822f8
314 changed files with 9259 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
// MinecraftPT — Depth of Field
// Circle of confusion computation and bokeh blur.
#ifndef DOF_GLSL
#define DOF_GLSL
// Compute CoC (circle of confusion) for a fragment
float GetCoC(float depth, float focalDepth){
float focus = focalDepth;
float aperture = DOF_BLUR;
float coc = abs(depth - focus) / focus * aperture * DOF_MAX_COC;
return clamp(coc, 0.0, DOF_MAX_COC);
}
// Simple bokeh blur (gather)
vec3 DofBlur(vec2 texelCoord, float coc){
vec3 color = vec3(0.0);
float weight = 0.0;
int radius = int(min(coc, 8.0)) + 1;
for (int i = -radius; i <= radius; i++){
for (int j = -radius; j <= radius; j++){
float dist = length(vec2(i, j));
if (dist > coc) continue;
vec2 coord = texelCoord + vec2(i, j);
vec3 sampleColor = texelFetch(colortex12, ivec2(coord), 0).rgb;
float w = max(0.0, 1.0 - dist / coc);
color += sampleColor * w;
weight += w;
}}
return weight > 0.0 ? color / weight : color;
}
#endif