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
570
ReSTIRの数理と実装 (rtcamp10)
yumcyawiz
1
2.1k
fredholm(rtcamp9)
yumcyawiz
0
180
フォトンマッピングをパス空間から考える
yumcyawiz
0
570
fredholm
yumcyawiz
0
370
Introduction to volume rendering
yumcyawiz
0
2.9k
OSK#p-ray2020年度講義: 古典的レイトレーサーの実装
yumcyawiz
0
310
Ray Tracing: Overview
yumcyawiz
7
1.4k
Pybind11でC++とPythonのいいとこ取りをする
yumcyawiz
0
1.2k
Other Decks in Programming
See All in Programming
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
140
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
150
APNsからLive Activityを開始する話
yumnumm
0
170
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
270
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
contenteditable と日本語入力に向き合う
colorful12
0
210
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
AmebaブログはKMPから卒業します
kmars0605
0
210
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
180
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
290
Featured
See All Featured
A Soul's Torment
seathinner
8
3.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Automating Front-end Workflow
addyosmani
1369
210k
The untapped power of vector embeddings
frankvandijk
2
1.9k
What's in a price? How to price your products and services
michaelherold
247
13k
How to make the Groovebox
asonas
2
2.5k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
The Cult of Friendly URLs
andyhume
79
7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
870
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!