https://github.com/blurgyy/rwwtt

Rendering 🍦 with two triangles

https://github.com/blurgyy/rwwtt

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

Basic Info
  • Host: GitHub
  • Owner: blurgyy
  • Language: C++
  • Default Branch: rwwtt
  • Homepage:
  • Size: 3.72 MB
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

demo

使用

  1. /shaders 目录下执行 make all 以编译顶点着色器和片段着色器 (需要安装 GLSL 编译器 glslc)
  2. 得到编译出的 /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).

参考资料

Owner

  • Name: Gaoyang Zhang
  • Login: blurgyy
  • Kind: user
  • Company: Zhejiang University

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
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels