Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tsukihiができるまで #レイトレ合宿4
Search
がむ
August 27, 2016
Technology
1
8.9k
tsukihiができるまで #レイトレ合宿4
レイトレ合宿4で発表したレンダラーtsukihiの紹介です。
https://sites.google.com/site/raytracingcamp4/
がむ
August 27, 2016
Tweet
Share
More Decks by がむ
See All by がむ
距離関数を極める! / SESSIONS 2024
gam0022
0
440
redflash [portal] renderer / Raytracing Camp 10
gam0022
0
21
つぶやきGLSL解読! / Raytracing Camp 10
gam0022
0
250
LTC(Linearly Transformed Cosines)によるエリアライトのUnity URP実装
gam0022
1
35
redflash [4D] renderer / Raytracing Camp 9
gam0022
0
240
Object Space Raymarching in Unreal Engine 5.2
gam0022
0
320
IFSによるフラクタルのモデリング
gam0022
0
380
Transcendental Cube / グラフィックス解説
gam0022
1
160
redflash revolution renderer / Raytracing Camp 8
gam0022
0
3
Other Decks in Technology
See All in Technology
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
230
大規模言語モデルとそのソフトウェア開発に向けた応用 (2024年版)
kazato
2
440
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
1.5k
20241125 - AI 繪圖實戰魔法工作坊 @ 實踐大學
dpys
1
440
スケールし続ける事業とサービスを支える組織とアーキテクチャの生き残り戦略 / The survival strategy for Money Forward’s engineering.
moneyforward
0
230
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
400
型情報を用いたLintでコード品質を向上させる
sansantech
PRO
2
220
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
540
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
2
190
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
150
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
28
25k
普通のエンジニアがLaravelコアチームメンバーになるまで
avosalmon
0
670
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
550
A Modern Web Designer's Workflow
chriscoyier
693
190k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Making Projects Easy
brettharned
116
6k
Faster Mobile Websites
deanohume
305
30k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Site-Speed That Sticks
csswizardry
2
220
It's Worth the Effort
3n
183
28k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
Transcript
CPU RENDER tsukihi Sho Hosoda / @gam0022
None
UTVLJIJ͕Ͱ͖Δ·Ͱ 1
͓ “Rendering a beautiful image within 5 minutes.”
ϨΠϚʔνϯά×ύετϨʔγϯά ̑Ͳ͜Ζ͔ ̑࣌ؒͩͬͨ…
Ͳ͏ͬͯ ̑Ҏʹඳը͢Δʁ
४උ࣌ؒ εΩϧΓͳ͍ʜʜ
ઓུ ٖࣅදݱͰޡຐԽͦ͏ʂ
UTVLJIJͷಛ 2
⁞ϨΠͱγʔϯͷিಥఆϨΠϚʔνϯά ϥϯόʔτࣹʹΑΔݹయతͳγΣʔσΟϯά ٖࣅ"0ٖࣅίʔςΟΫεΛՃ্࣭͑ͯ
⁞ϨΠͱγʔϯͷিಥఆϨΠϚʔνϯά ϥϯόʔτࣹʹΑΔݹయతͳγΣʔσΟϯά ٖࣅ"0ٖࣅίʔςΟΫεΛՃ্࣭͑ͯ
w ڑؔʢӄؔʣͰදݱ͞Εͨγʔϯͱ ϨΠͱͷަΛۙతʹٻΊΔख๏ w ϑϥΫλϧਤܗڑؔͰఆٛͰ͖Δ w ࢀߟࢿྉʢ4MJEF4IBSFʣ γΣʔμ͚ͩͰੈքΛΔʂUISFFKTʹΑΔϨΠϚʔνϯά ϨΠϚʔνϯά
struct RaymarchingSphere : public RaymarchingObject { public: RaymarchingSphere(const Vec3 &position,
const double scale, const Color &emission, const Color &color, const ReflectionType reflection_type) : RaymarchingObject(position, scale, emission, color, reflection_type) { } double distanceFunction(const Vec3 &p) const { return length(p - position) - scale; } }; code ϨΠϚʔνϯάͷΦϒδΣΫτͷఆٛ 3BZNBSDIJOH0CKFDUΛܧঝͯ͠EJTUBODF'VODUJPOΛ࣮͢ΕΑ͍ઃܭ
const double mengerSpongeLoop(const Vec3& p) const { double d =
0.0; const double one_third = 1.0 / 3.0; for (int i = 0; i < 4; i++) { double k = pow(one_third, i); double kh = k * 0.5; d = std::max(d, -crossBar(mod(p + kh, k * 2.0) - kh, k * one_third)); } return d; } code ϝϯΨʔͷεϙϯδͷແݶ൛ͷڑؔ
⁞ϨΠͱγʔϯͷিಥఆϨΠϚʔνϯά ϥϯόʔτࣹʹΑΔݹయతͳγΣʔσΟϯά ٖࣅ"0ٖࣅίʔςΟΫεΛՃ্࣭͑ͯ
w ී௨ͷϥϯόʔτࣹ w ޫݯٿޫݯͷΈ w ڑͷٯଇʹΑΔޫͷݮਰ ݹయతͳγΣʔσΟϯά
⁞ϨΠͱγʔϯͷিಥఆϨΠϚʔνϯά ϥϯόʔτࣹʹΑΔݹయతͳγΣʔσΟϯά ٖࣅ"0ٖࣅίʔςΟΫεΛՃ্࣭͑ͯ
w ΦϯϥΠϯϨϯμϦϯάͷσϞγʔϯͰ ༻͍ΒΕΔख๏Ͱ"0ιϑτγϟυΛٖࣅදݱ w ίʔςΟΫεٖࣅදݱʢྗٕʣ ٖࣅදݱʹΑΔ্࣭
"0ແ "0༗ ݀ͷःณ෦͕҉͘ͳΔ ٖࣅ"0
"0ແ "0༗ ٖࣅͱ͍͑ɺޮՌൈ܈ ٖࣅ"0
inline double calcAO(const Vec3 pos, const Vec3 normal) { double
k = 1.0, occluded = 0.0; for (int i = 0; i < 5; i++) { double length = 1.5 * i; double distance = map(normal * length + pos); occluded += (length - distance) * k; k *= 0.3; } return clamp(1.0 - occluded, 0.0, 1.0); } code ٖࣅ"0
ٖࣅ"0 occluded += (length - distance) * k; ःณͳ͠ EJTUBODFMFOHUI
ःณ͋Γ EJTUBODFMFOHUI
ٖࣅίʔςΟΫε ٖࣅίʔςΟΫε ύετϨʔγϯάʹΑΔ ίʔςΟΫε
inline double calcCaustics(const Vec3 pos, const Vec3 light_dir, const double
distance) { for (int i = 0; i < 20; i++) { Vec3 p = pos + light_dir * depth_to_refraction; d_to_refraction = refraction_map(p); if (std::abs(distance - depth_to_refraction) < kEPS || depth_to_refraction > depth_to_other) break; if (std::abs(d_to_refraction) < kEPS) { Vec3 n = calcRefractionNormal(p); return 1.0 + pow(1.07 * std::max(dot(n, -light_dir), 0.0), 100.0); } depth_to_refraction += d_to_refraction; } return 1.0; } code ٖࣅίʔςΟΫε
ٖࣅίʔςΟΫε w EPU O MJHIU@EJS MJHIU@EJSিಥ͔ΒޫݯͷϕΫτϧ O۶ંΦϒδΣΫτͷ๏ઢ
w ୯७ͳੵ͕ͩɺٿମʹݶΓͦΕͬΆ͘ͳΔ w ಾͷͱ͍͏ఆ return 1.0 + pow(1.07 * std::max(dot(n, -light_dir), 0.0), 100.0);
1280x960px 4spp 37.24sec @Core i7-6700K 4core Λେ͖͘Լճͬͨʂ
ιʔείʔυ w IUUQTHJUIVCDPNHBNUTVLJIJ w FEVQUΛGPSL࣮ͯ͠ʢIPMF͞Μʹײँʂʣ w དྷͦ͜ύετϨΛ͍ͨ͠