Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (1.8%) to scientific vocabulary
Keywords
glsl
sdf
shader
vulkan
Last synced: 6 months ago
·
JSON representation
Repository
Rendering 🍦 with two triangles
Statistics
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
glsl
sdf
shader
vulkan
Created almost 6 years ago
· Last pushed over 5 years ago
Metadata Files
Readme
README.md
Final Project: 用两个三角形渲染世界
演示视频: https://blurgy.xyz/cg/demo.mp4
presentation 视频: https://blurgy.xyz/cg/pre.mp4
GitHub: https://github.com/Blurgyy/rwwtt

使用
- 在
/shaders目录下执行make all以编译顶点着色器和片段着色器 (需要安装 GLSL 编译器glslc) - 得到编译出的
/shaders/vert.spv和/shaders/icecream.spv之后, 回到根目录下执行
bash
$ mkdir build && cd build
$ cmake .. # 需要 Vulkan 支持
$ make # 编译
$ ./rwwtt # 运行
说明
- 使用 Vulkan 直接传递两个覆盖整个屏幕的三角形给 vertex shader. 渲染过程全部使用 GLSL 在 fragment shader 中实现.
- 在 Fragment shader 中构造距离场, 然后使用 ray marching 方法渲染场景.
- ray marching 中使用了 adaptive eps, 令固定的 epsilon 乘以当前点与起点之间的距离, 代表 ray marching 走得越远, 则判断与物体相交的条件越宽松.
- 距离场中某一位置 p 的法线方向可以通过计算距离场的梯度方向来估计, 距离场的梯度方向是该点到场景中物体的距离变化最快的方向.
- 根据 ray marching 的特性估计了软阴影, 具体: 从着色点向光源做 ray marching, 在每一步估计一个阴影, 某一步距离附近的物体越近则阴影越黑; 同时在某一步离着色点越远, 该步估计的阴影颜色应越浅, 两个因素结合起来再乘以一个系数 k, 取 ray marching 时估计的最"黑"的阴影作为着色点的阴影颜色. 如果途中打到物体, 则直接返回黑色.
- 根据 ray marching 的特性估计了环境光遮蔽. 具体: 沿表面法向量向外取若干个点 q (5 个), 根据 q 点到世界的距离 d=map(q) 和 q 点到 p 点的距离 h, 就可以估计出点 p 处的环境光遮蔽系数 occ.
- 定义了材质
- 最后添加了反走样 (SSAA 2x).
参考资料
- 调用 Vulkan API 的 C++ 代码参考自
https://vulkan-tutorial.com/ - Fragment shader 中:
- 平滑融合两个形状的函数参考自
https://iquilezles.org/www/articles/smin/smin.htm, 使用了其中提到的多项式型 blend 函数. - 自己实现的圆台距离场函数因为没有考虑点在内部时的距离, 对圆台求法线时会在侧面出现大量噪点. 修正后的圆台的距离场函数参考自
https://iquilezles.org/www/articles/distfunctions/distfunctions.htm. - 软阴影的估计方式参考自
https://iquilezles.org/www/articles/rmshadows/rmshadows.htm. - 环境光遮蔽的估计方式参考自:
https://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf第 53 页https://www.shadertoy.com/view/lsKcDD
- 平滑融合两个形状的函数参考自
- ray marching 中的 adaptive eps, 使用距离场通过变换生成绕轴对称的物体, 环境光遮蔽等技巧参考自:
- NVScene 2008: Rendering Worlds with Two Triangles: Raytracing on the GPU
Owner
- Name: Gaoyang Zhang
- Login: blurgyy
- Kind: user
- Company: Zhejiang University
- Repositories: 6
- Profile: https://github.com/blurgyy
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0