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

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

がむ
August 27, 2016

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

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

がむ

August 27, 2016
Tweet

More Decks by がむ

Other Decks in Technology

Transcript

  1. 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Λ࣮૷͢Ε͹Α͍ઃܭ
  2. 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 ϝϯΨʔͷεϙϯδͷແݶ൛ͷڑ཭ؔ਺
  3. 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
  4. 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 ٖࣅίʔςΟΫε
  5. ٖࣅίʔςΟΫε 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);