跳到正文
网页珍奇柜Web Curio

浏览器光线追踪

WebGL Path Tracing,Evan Wallace,2011 年

正在布展…

本柜的现场复刻:按原作的技术思路从零编写,不含原作的代码和素材。原作请点上方「去看原作」。

它是怎么做的

  1. 第 1 步整个场景(球、盒子、光源)被拼成 GLSL 代码字符串并编译
  2. 第 2 步每帧在片元着色器中为每个像素随机发射光线并多次弹射
  3. 第 3 步结果与历史帧按 1/(n+1) 权重累积,噪点逐渐收敛
  4. 第 4 步交互时重置累积缓冲区

复刻配方

一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。

Describe a small scene of analytic primitives (spheres, axis-aligned boxes) in JavaScript and generate a fragment shader that intersects rays with them. Each frame, trace one randomized path per pixel with a few diffuse bounces and a hash-based random seed that changes with the frame number. Blend the new frame into an accumulation texture with weight 1/(frameCount+1) using ping-pong render targets and display the average. Reset frameCount whenever the camera or an object moves so the image re-converges.

档案

能不能拿来用

原作不是开源许可(unknown (no LICENSE file)):只能作为视觉参考,不要复制它的代码或素材,自己按技术思路实现。

性能开销

视觉强度

实现难度

尺度为策展判断(1 到 5),用于比较和推荐。

核实记录:Demo loads (200); repo exists but no LICENSE file.