tsukihiができるまで #レイトレ合宿4

452023224091040c47c3bcaa40935c53?s=47 がむ
August 27, 2016

tsukihiができるまで #レイトレ合宿4

レイトレ合宿4で発表したレンダラーtsukihiの紹介です。
https://sites.google.com/site/raytracingcamp4/

452023224091040c47c3bcaa40935c53?s=128

がむ

August 27, 2016
Tweet

Transcript

  1. CPU RENDER tsukihi Sho Hosoda / @gam0022

  2. None
  3. UTVLJIJ͕Ͱ͖Δ·Ͱ 1

  4. ͓୊ “Rendering a beautiful image within 5 minutes.”

  5. ϨΠϚʔνϯά×ύετϨʔγϯά ̑෼Ͳ͜Ζ͔ ̑࣌ؒͩͬͨ…

  6. Ͳ͏΍ͬͯ ̑෼Ҏ಺ʹඳը͢Δʁ

  7. ४උ࣌ؒ΋ εΩϧ΋଍Γͳ͍ʜʜ

  8. ઓུ ٖࣅදݱͰޡຐԽͦ͏ʂ

  9. UTVLJIJͷಛ௃ 2

  10. ⁞ϨΠͱγʔϯͷিಥ൑ఆ͸ϨΠϚʔνϯά  ϥϯόʔτ൓ࣹʹΑΔݹయతͳγΣʔσΟϯά ⁠ٖࣅ"0΍ٖࣅίʔςΟΫεΛՃ͑ͯ඼࣭޲্

  11. ⁞ϨΠͱγʔϯͷিಥ൑ఆ͸ϨΠϚʔνϯά  ϥϯόʔτ൓ࣹʹΑΔݹయతͳγΣʔσΟϯά ⁠ٖࣅ"0΍ٖࣅίʔςΟΫεΛՃ͑ͯ඼࣭޲্

  12. w ڑ཭ؔ਺ʢӄؔ਺ʣͰදݱ͞Εͨγʔϯͱ
 ϨΠͱͷަ఺Λ઴ۙతʹٻΊΔख๏ w ϑϥΫλϧਤܗ΋ڑ཭ؔ਺ͰఆٛͰ͖Δ w ࢀߟࢿྉʢ4MJEF4IBSFʣ  γΣʔμ͚ͩͰੈքΛ૑ΔʂUISFFKTʹΑΔϨΠϚʔνϯά ϨΠϚʔνϯά

  13. 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Λ࣮૷͢Ε͹Α͍ઃܭ
  14. 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 ϝϯΨʔͷεϙϯδͷແݶ൛ͷڑ཭ؔ਺
  15. ⁞ϨΠͱγʔϯͷিಥ൑ఆ͸ϨΠϚʔνϯά  ϥϯόʔτ൓ࣹʹΑΔݹయతͳγΣʔσΟϯά ⁠ٖࣅ"0΍ٖࣅίʔςΟΫεΛՃ͑ͯ඼࣭޲্

  16. w ී௨ͷϥϯόʔτ൓ࣹ w ޫݯ͸ٿޫݯͷΈ w ڑ཭ͷٯ৐ଇʹΑΔޫͷݮਰ ݹయతͳγΣʔσΟϯά

  17. ⁞ϨΠͱγʔϯͷিಥ൑ఆ͸ϨΠϚʔνϯά  ϥϯόʔτ൓ࣹʹΑΔݹయతͳγΣʔσΟϯά ⁠ٖࣅ"0΍ٖࣅίʔςΟΫεΛՃ͑ͯ඼࣭޲্

  18. w ΦϯϥΠϯϨϯμϦϯάͷσϞγʔϯͰ
 ༻͍ΒΕΔख๏Ͱ"0ιϑτγϟυ΢Λٖࣅදݱ w ίʔςΟΫε΋ٖࣅදݱʢྗٕʣ ٖࣅදݱʹΑΔ඼࣭޲্

  19. "0ແ "0༗ ݀ͷःณ෦෼͕҉͘ͳΔ ٖࣅ"0

  20. "0ແ "0༗ ٖࣅͱ͸͍͑ɺޮՌ͸ൈ܈ ٖࣅ"0

  21. 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
  22. ٖࣅ"0 occluded += (length - distance) * k; ःณ෺ͳ͠ EJTUBODFMFOHUI

    ःณ෺͋Γ EJTUBODFMFOHUI
  23. ٖࣅίʔςΟΫε ٖࣅίʔςΟΫε ύετϨʔγϯάʹΑΔ ίʔςΟΫε

  24. 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 ٖࣅίʔςΟΫε
  25. ٖࣅίʔςΟΫε 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);
  26. 1280x960px 4spp 37.24sec @Core i7-6700K 4core ෼Λେ͖͘Լճͬͨʂ

  27. ιʔείʔυ w IUUQTHJUIVCDPNHBNUTVLJIJ w FEVQUΛGPSL࣮ͯ͠૷ʢIPMF͞Μʹײँʂʣ w དྷ೥ͦ͜͸ύετϨΛ͍ͨ͠