Upgrade to Pro — share decks privately, control downloads, hide ads and more …

コンピュータグラフィクスの空

Fadis
December 02, 2023

 コンピュータグラフィクスの空

2020年にEpic GamesのSébastien Hillaire氏が発表した論文「A Scalable and Production Ready Sky and Atmosphere Rendering Technique」を実装してみます
これは2023年12月2日に行われた Kernel/VM探検隊@北陸 Part 6 での発表資料です

発表動画: https://youtu.be/YrQ4ACuvM68
ソースコード: https://github.com/Fadis/gct/tree/kernelvm_20231202

Fadis

December 02, 2023
Tweet

More Decks by Fadis

Other Decks in Programming

Transcript

  1. ίϯϐϡʔλάϥϑΟΫεͷۭ
    NAOMASA MATSUBAYASHI

    View full-size slide

  2. ੨ۭΛඳ͍ͨ൘
    ࠓ೔΋ۭ͕੨͍ͳ

    View full-size slide

  3. ݱ࣮ͷۭͷ৭

    View full-size slide

  4. ੨ۭ͸ओʹଠཅޫ͕


    ۭؾதͰࢄཚ͢ΔࣄͰੜ͡Δ

    View full-size slide

  5. ΠϚυΩͷϦΞϧλΠϜϨϯμϦϯά


    ۭؾதͰͷޫͷࢄཚΛܭࢉ͢Δ

    View full-size slide

  6. ஍ٿͷେؾʹೖ͖ͬͯͨଠཅޫͷࢄཚΛܭࢉ͢Ε͹


    ݁Ռͱͯ͠ਖ਼͍͠੨ۭ͕ಘΒΕΔͷͰ͸

    View full-size slide

  7. https://diglib.eg.org/handle/10.1111/cgf14050
    େؾதͰͷޫͷࢄཚΛܭࢉͯ͠


    ۭͷ৭ΛٻΊΔ
    ϦΞϧλΠϜϨϯμϦϯάͰ


    ࢖͑Δ଎͞Ͱܭࢉ͢Δ
    Unreal Engineͷ


    ඪ४ͷۭͷϨϯμϦϯάख๏
    ͜ͷ࿦จͷख๏Λ


    ࣮૷ͯ͠ΈΑ͏

    View full-size slide

  8. ۭؾΛߏ੒͢Δ෼ࢠ΍ۭؾதΛඬ͏ཻࢠʹޫ͕Ϳ͔ͭΔͱ


    ޫ͕޲͖Λม͑ͨΓ(ࢄཚ)ผͷΤωϧΪʔʹͳͬͨΓ(ٵऩ)͢Δ
    ٵऩ
    ࢄཚ
    ࢄཚ

    View full-size slide

  9. ٵऩ
    ޫͷਐΉڑ཭͕௕͘ͳΔఔ


    ޫͷΤωϧΪʔ͕ݮΔ

    View full-size slide

  10. ग़ࢄཚ
    ࢹ఺ʹ޲͔ͬͯ์ͨΕͨޫ͕


    ࢄΒ͹͍ͬͯ͘ࣄͰ


    ࢹ఺ʹಧ͘ޫͷΤωϧΪʔ͕ݮΔ

    View full-size slide

  11. ೖࢄཚ
    Ͳ͔͜Ͱग़ࢄཚͨ͠ޫ͕


    ࢹ఺ʹ޲͔͏ޫʹՃΘΔࣄͰ


    ࢹ఺ʹಧ͘ޫͷΤωϧΪʔ͕


    ૿͑Δ

    View full-size slide

  12. ͋Δ఺Ͱೖࢄཚͯ͠ࢹ఺ʹ޲͔͏ޫͷΤωϧΪʔ͸


    ͦͷ఺ʹपғ͔ΒඈΜͰ͖ͨޫͷΤωϧΪʔͰܾ·Δ
    ͭ·Γશͯͷํ޲ʹ͍ͭͯͷੵ෼

    View full-size slide

  13. ͋Δ఺ʹ޲͔ͬͯඈΜͰ͘ΔޫͷΤωϧΪʔ͸


    ผͷ͋Δ఺Ͱ޲͖Λม͑ͨޫͩͬͨΓ͢Δ
    ੵ෼ͷੵ෼

    View full-size slide

  14. ੵ෼ͷੵ෼ͷੵ෼ͷੵ෼
    ͜ΕΛΠϯλϥΫςΟϒʹܭࢉ͢Δͷ͸ແཧ

    View full-size slide

  15. ޫ͸1ճ͚ͩࢄཚͰ޲͖Λม͑Δࣄʹ͢Δ
    ࢹ఺ͱःṭ෺Λ݁Ϳઢ෼্ͷ֤఺Ͱ


    ޫݯ͔Βͷޫ͕ࢄཚͯ͠


    ࢹ఺ʹ޲͔͏


    ޫͷΤωϧΪʔʹՃΘΔ
    ͜ͷઢ෼ʹԊͬͯੵ෼
    γϯάϧεΩϟολϦϯά

    View full-size slide

  16. Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei
    ͜ͷܦ࿏Ͱ


    ੜ͡Δٵऩͱ


    ग़ࢄཚ
    ͜͜ʹಧ͍ͨޫͷ͏ͪ


    ೖࢄཚͰࢹ఺ͷํ޲ʹ


    ޲͖Λม͑Δޫͷׂ߹
    ͜ͷܦ࿏Ͱੜ͡Δ


    ٵऩͱग़ࢄཚ
    ඈΜͰ͖ͨ


    ޫͷΤωϧΪʔ
    v :
    li
    :
    ||c − x||
    ଠཅͷ޲͖
    x + tatmo
    li
    : ඪߴ100kmͷ໘ͱ


    ํ޲ʹ৳͹ͨ͠


    ௚ઢͷަ఺
    li
    c
    x

    View full-size slide

  17. T(xa
    , xb
    ) = e−∫xb
    x=xa
    σt
    (x)||dx||
    ϥϯϕϧτɾϕʔϧͷ๏ଇ
    ֤఺Ͱͷޫͷ௨Γ΍͢͞ Λޫ͕௨Δܦ࿏Ͱੵ෼
    σt
    (x)
    ͦͷ஋͕େ͖͍ఔಁաͰ͖ΔޫͷΤωϧΪʔ͸খ͘͞ͳΔ
    Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei

    View full-size slide

  18. 100km
    ଠཅ͔ΒͷޫΛݦஶʹࢄཚͤ͞Δͷ͸


    ஍ද͔Β100km͘Β͍ͷൣғͷۭؾ
    ີ౓͕ߴ͍
    ີ౓͕௿͍
    ۭؾͷີ౓͸


    ஍ද͔Βԕ͘ͳΔఔ


    খ͘͞ͳΔ

    View full-size slide

  19. σr
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    e− ||x|| − 6.36 × 106
    8 × 103
    ||x||
    6.36 × 106m
    1ؾѹͷۭؾதͰ


    ޫ͕ۭؾΛߏ੒͢Δ


    ෼ࢠͱͿ͔ͭͬͯ


    ग़ࢄཚ͢Δׂ߹
    ߴ౓
    ߴ౓͕ߴ͘ͳΔఔ


    ۭؾͷີ౓͕Լ͕Δ
    x
    ۭؾதͷ෼ࢠʹΑΔ


    ग़ࢄཚ

    View full-size slide

  20. σm
    (x) = (3.996 × 10−6 + 4.40 × 10−6) e− ||x|| − 6.36 × 106
    1.2 × 103
    6.36 × 106m
    ߴ౓͕ߴ͘ͳΔͱ


    ۭؾதΛඬ͏ཻࢠͷྔ͸ٸ଎ʹݮΔ
    ۭؾதΛඬ͏ཻࢠʹΑΔ


    ग़ࢄཚͱٵऩ
    ग़ࢄཚ ٵऩ
    ||x||
    x

    View full-size slide

  21. 6.36 × 106m
    ΦκϯʹΑΔޫͷٵऩ
    ||x||
    x
    σo
    (x) =
    0.650 × 10−6
    1.881 × 10−6
    0.085 × 10−6
    max
    (
    0,1 −
    |(||x|| − 6.36 × 106) − 25 × 103 |
    15 × 103 )
    ٵऩ
    ߴ౓25kmΛϐʔΫͱ͢Δ


    ্Լ֤15kmͷൣғ

    View full-size slide

  22. T(xa
    , xb
    ) = e−∫xb
    x=xa
    σt
    (x)||dx||
    σt
    (x) = σr
    (x) σm
    (x) σo
    (x)
    σr
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    e− ||x|| − 6.36 × 106
    8 × 103
    σm
    (x) = (3.996 × 10−6 + 4.40 × 10−6) e− ||x|| − 6.36 × 106
    1.2 × 103
    σo
    (x) =
    0.650 × 10−6
    1.881 × 10−6
    0.085 × 10−6
    max
    (
    0,1 −
    |(||x|| − 6.36 × 106) − 25 × 103 |
    15 × 103 )
    Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei

    View full-size slide

  23. σs
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    p (v, li) =
    3 (1 + (v ⋅ li)
    2
    )
    16π
    ۭؾΛߏ੒͢Δ෼ࢠʹΑΔࢄཚ(ϨΠϦʔࢄཚ)
    Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei

    View full-size slide

  24. σs
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    p (v, li) =
    3 (1 + (v ⋅ li)
    2
    )
    16π
    ۭؾΛߏ੒͢Δ෼ࢠʹΑΔࢄཚ(ϨΠϦʔࢄཚ)
    σs
    (x) = 3.996 × 10−6
    p (v, li) =
    3

    (1 − g2) (1 + (v ⋅ li)
    2
    )
    (2 + g2) (1 + g2 − 2g (v ⋅ li))
    3
    2
    ۭؾதΛඬ͏ཻࢠʹΑΔग़ࢄཚͱٵऩ(ϛʔࢄཚ)
    g = 0.8
    Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei
    ϔχΤΠɾάϦʔϯελΠϯؔ਺

    View full-size slide

  25. Lscat
    (c, x, v) = T (c, x) T (x, x + tatmo
    li) σs
    (x) p (v, li) Ei
    L (c, v) =

    ||p−c||
    t=0
    Lscat
    (c, c − tv, v) dt
    c
    100km p
    ͜ͷઢ෼ʹԊͬͯੵ෼

    View full-size slide

  26. Lscat
    (c, x, v) = T (c, x) T (x, x + tatmo
    li) σs
    (x) p (v, li) Ei
    T(xa
    , xb
    ) = e−∫xb
    x=xa
    σt
    (x)||dx||
    σt
    (x) = σr
    (x) σm
    (x) σo
    (x)
    σr
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    e− ||x|| − 6.36 × 106
    8 × 103
    σm
    (x) = (3.996 × 10−6 + 4.40 × 10−6) e− ||x|| − 6.36 × 106
    1.2 × 103
    L (c, v) =

    ||p−c||
    t=0
    Lscat
    (c, c − tv, v) dt
    ਺஋ੵ෼ͷ਺஋ੵ෼͸


    ϦΞϧλΠϜϨϯμϦϯάʹ͸ਏ͍

    View full-size slide

  27. 100km
    ߴ౓h
    ఱ௖ͱଠཅͷ


    ͳ֯͢θ
    ͸ ͱ ͚ͩͰܾ·Δ
    e−∫xb
    x=xa
    σt
    (x)||dx||
    θ h
    xa
    xb

    View full-size slide

  28. ଠཅ͔Β ʹࢸΔޫͷಁա཰
    xa
    1 −
    (
    1 −
    θ
    θmax
    )
    2
    1 − (1 −
    h
    1 × 105 )
    2
    ଠཅͱ Λ݁Ϳ௚ઢ͕஍໘ʹ઀͢Δ֯౓
    xa

    View full-size slide

  29. ݱ࣮ͷۭͷ৭
    ۭͷ৭͸


    ؇΍͔ʹ͔͠


    มԽ͠ͳ͍
    ݶΒΕͨ఺͚ͩ


    ܭࢉͯ͠


    ؒ͸ิؒͰे෼

    View full-size slide

  30. θ
    ϕ
    θ
    ϕ
    π
    2

    π
    2
    0 2π
    ͳΜ͔ബ҉͍

    View full-size slide

  31. σr
    (x) =
    5.802 × 10−6
    13.558 × 10−6
    33.1 × 10−6
    e− ||x|| − 6.36 × 106
    8 × 103
    ग़ࢄཚ͔͠ແ͍
    ۭؾதͷ෼ࢠʹΑΔٵऩ͸ແࢹͰ͖Δ΄Ͳখ͍͞
    ࢄཚͨ͠ޫ͸


    ຆͲΤωϧΪʔΛࣦΘͣʹ


    ࢄཚΛ܁Γฦ͢
    ͦͷ͏ͪزΒ͔͸ࢹ఺ʹಧ͘
    ϚϧνεΩϟολϦϯάͷӨڹ͕


    ແࢹ͢Δʹ͸େ͖͗͢Δ

    View full-size slide

  32. ίετΛ͔͚ͣʹ


    ࡶʹෳ਺ճͷࢄཚΛܭࢉͨ͠ࣄʹ͍ͨ͠
    ͜ͷ෼Λࣄલʹ


    ܭࢉ͍ͨ͠

    View full-size slide

  33. ߴ౓
    x ೖࢄཚͷ޲͖(ܦ౓)
    ೖࢄཚͷ޲͖(Ң౓)
    ଠཅͷ޲͖(Ң౓)
    ଠཅͷ޲͖(ܦ౓)
    2ճࢄཚ͢Δޫͷࣗ༝౓ : 5࣍ݩ
    ࣄલʹܭࢉͨ͠஋Λ഑ྻʹ͢Δʹ͸


    ࣍ݩ͕େ͖͗͢Δ
    y

    View full-size slide

  34. ࠨ͔Βདྷͨޫ͕


    ϨΠϦʔࢄཚ͢Δ৔߹ͷ


    ࢄཚํ޲ͷ෼෍
    શͯͷํ޲ʹͦΕͳΓͷେ͖͞Ͱ


    ෼෍͍ͯ͠Δ
    ࢄཚΛ܁Γฦ͢ͱ


    ݩͷޫͷ޲͖ͷ৘ใ͸


    ٸ଎ʹࣦΘΕΔ

    View full-size slide

  35. ߴ౓
    x ೖࢄཚͷ޲͖(ܦ౓)
    ೖࢄཚͷ޲͖(Ң౓)
    ଠཅͷ޲͖(Ң౓)
    ଠཅͷ޲͖(ܦ౓)
    Ͳͷ޲͖͔Βͷೖࢄཚ΋ಉ͡
    ೖࢄཚͷ޲͖ຖʹ


    ܭࢉ݁ՌΛ࣋ͭඞཁ͸ͳ͍

    y

    View full-size slide

  36. ߴ౓
    x
    ଠཅͷ޲͖(Ң౓)
    ଠཅͷ޲͖(ܦ౓)
    Ͳͷ޲͖͔Βͷೖࢄཚ΋ಉ͡
    ޲͖͸Ͳ͏Ͱ΋͍͍ͷͰ


    ଠཅͷ޲͖ͷܦ౓͸ཁΒͳ͍

    y

    View full-size slide

  37. L2 (xs
    , p) =

    Ω4π
    L′

    (xs
    , p, − ω)
    1


    L′

    (x, p, v) =

    ||p−x||
    t=0
    T (x, x − tv) σs
    (x)
    1

    T (x, x + tatmo
    li) dt
    શͯͷ޲͖͔Βͷ2࣍ͷೖࢄཚ
    c
    x

    View full-size slide

  38. L2 (xs
    , p) =

    Ω4π
    L′

    (xs
    , p, − ω)
    1


    L′

    (x, p, v) =

    ||p−x||
    t=0
    T (x, x − tv) σs
    (x)
    1

    T (x, x + tatmo
    li) dt
    શͯͷ޲͖͔Βͷ2࣍ͷೖࢄཚ
    c
    x

    D
    0
    e−σt
    xSdx =
    S − Se−σt
    D
    σt
    Λ࢖ͬͯ Λղੳతʹղ͘
    L′

    View full-size slide

  39. fms (xs
    , p) =

    Ω4π
    Lf (xs
    , p, − ω)
    1


    Lf (x, p, v) =

    ||p−x||
    t=0
    T (x, x − tv) σs
    (x) dt
    Fms (x, p) =
    1
    1 − fms (x, p)
    ψms (x, p) = L2 (x, p) Fms (x, p)
    L2 (xs
    , p) =

    Ω4π
    L′

    (xs
    , p, − ω)
    1


    L′

    (x, p, v) =

    ||p−x||
    t=0
    T (x, x − tv) σs
    (x)
    1

    T (x, x + tatmo
    li) dt
    શͯͷ޲͖͔Βͷ2࣍ͷೖࢄཚ
    શͯͷ޲͖͔Βͷ


    2͔࣍Β ࣍·Ͱͷೖࢄཚ


    D
    0
    e−σt
    xSdx =
    S − Se−σt
    D
    σt
    ͜Ε΋ Ͱղ͘
    ͜͜ʹ2࣍ͷೖࢄཚ͕ՃΘΔͱ͢Δͱ


    ઴ԽࣜʹͳΔ

    View full-size slide

  40. Lscat
    (c, x, v) = T (c, x) σs
    (x) p (v, li) T (x, x + tatmo
    li) Ei
    + ψms (x, li) Ei
    ͜ͷܦ࿏Ͱ


    ੜ͡Δٵऩͱ


    ग़ࢄཚ
    ͜͜ʹಧ͍ͨޫͷ͏ͪ


    ೖࢄཚͰࢹ఺ͷํ޲ʹ


    ޲͖Λม͑Δޫͷׂ߹
    ͜ͷܦ࿏Ͱੜ͡Δ


    ٵऩͱग़ࢄཚ
    c
    x
    ෳ਺ճࢄཚͯ͠


    ʹͨͲΓண͘෼
    x

    View full-size slide

  41. θ
    ϕ
    θ
    ϕ
    π
    2

    π
    2
    0 2π

    View full-size slide

  42. https://fadis.booth.pm/
    /&8 ϦΞϧλΠϜϨϯμϦϯάͷख๏Λ


    ήʔϜΤϯδϯͱ͔࢖Θͣʹ


    ࣗྗͰ࣮૷͢Δ


    ϨΠϠʔ͕௿͍ਓͷͨΊͷ


    ίϯϐϡʔλάϥϑΟΫεղઆຊ
    ٕज़ॻయͰຊग़ͯ͠·͢

    View full-size slide