Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GLSLでパストレーシングしてコーネルボックスを出す
Search
yumcyawiz
November 28, 2020
Programming
640
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GLSLでパストレーシングしてコーネルボックスを出す
OSK11月LT会のスライド
Github:
https://github.com/yumcyaWiz/glsl-cornellbox
yumcyawiz
November 28, 2020
More Decks by yumcyawiz
See All by yumcyawiz
rtcamp 10 (vk-illuminati)
yumcyawiz
1
580
ReSTIRの数理と実装 (rtcamp10)
yumcyawiz
1
2.1k
fredholm(rtcamp9)
yumcyawiz
0
190
フォトンマッピングをパス空間から考える
yumcyawiz
0
580
fredholm
yumcyawiz
0
370
Introduction to volume rendering
yumcyawiz
0
2.9k
OSK#p-ray2020年度講義: 古典的レイトレーサーの実装
yumcyawiz
0
320
Ray Tracing: Overview
yumcyawiz
7
1.4k
Pybind11でC++とPythonのいいとこ取りをする
yumcyawiz
0
1.2k
Other Decks in Programming
See All in Programming
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
150
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
350
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.1k
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
210
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
180
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
160
Performance Optimization With LLMs
xleitix
0
230
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.3k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.3k
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
270
AmebaブログはKMPから卒業します
kmars0605
0
310
Featured
See All Featured
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
350
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.2k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Utilizing Notion as your number one productivity tool
mfonobong
4
630
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
320
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
490
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
Docker and Python
trallard
47
4.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Transcript
GLSLでパストレーシングしてコーネルボックスを 出す OSK11月LT会 @yumcyawiz
GLSLとは?
GLSLとは? • OpenGLで使用されるシェーダー • ユーザー定義のグラフィクス処理を記述できる • 計算はGPUで行われる • 文法はCと似ている
シェーダーの種類 • Vertex Shader • Fragment Shader • Geometry Shader
• Tessellation Shader • Compute Shader
シェーダーで処理する流れ Vertex Shader ポリゴン データ Fragment Shader 出力 頂点座標 テクスチャ座標など
頂点座標をスクリー ン上の座標に変換 各画素の色を計算
Vertex Shaderの例 vPosに頂点情報が入っている gl_Positionに座標変換した頂点情報が格納される
GLSLでパストレ?
GLSLでパストレ? • Vertex Shader -> Fragment Shaderの流れで自然にパストレを 組み込むのは不可能
GLSLでパストレ • Vertex Shader -> Fragment Shaderの流れで自然にパストレを 組み込むのは不可能 画面一杯に四角形を表示して, Fragment
Shaderでパストレする (レイマーチングと同じ方法)
四角形 + Fragment Shader Vertex Shader 画面を覆う四角形 Fragment Shader 各画素の色をパストレ
で計算 3次元空間上に置かれた 四角形
GPUレイトレ • 現在はOptiX, DirectX RayTracing, Vulkan RayTracingがあるの でGLSL縛りでレイトレする必要性はない 今回の主題: GLSLだけでどこまで実装できるのか?
パストレの実装 in GLSL
レイの表現 • vec3は最初から用意されている • classはないがCライクな構造体が利用できる
カメラ • normalizeなどvec3の組み込み関数が使える • C++の場合と全く同じように実装できる
物体 • 物体情報を全部Structに押し込む • type=0(球), type=1(平面)
物体とのintersect • typeに応じてintersectの演算を切り替える
シーンの表現 • Primitiveの配列をハードコーディング(本当はCPU側から渡し たほうが良い)
シーンとのintersect • 線形探索(頑張ればBVHも組み込めるみたい)
乱数 • xorshift32を利用
シード • 画素の位置, 現在のサンプル数をhash関数に通したものをシー ドに設定(アドホックだが見た目は悪くない)
パストレ • これもCPUの場合と同様に実装できる • BRDFはDiffuse only
サンプルの蓄積 • Framebufferを用意し, サンプル蓄積用のテクスチャにレンダリ ングする
結果の表示 • サンプル蓄積用のテクスチャをサンプル数で割ったものを画面 に表示
結果 実際に動いているところをお見せします
Future Works • コードをもっと綺麗に書きたい • GUIを付ける • インタラクティブな操作を可能にする • BVHを組み込んでsponzaとかレンダリングしてみたい
• Disney BRDF • NEE, MIS, BDPTなども実装してみる
Thank you for listening!