がむ
August 27, 2016
7.6k

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

レイトレ合宿4で発表したレンダラーtsukihiの紹介です。

August 27, 2016

## Transcript

2. None

13. ### struct RaymarchingSphere : public RaymarchingObject { public: RaymarchingSphere(const Vec3 &position,

const double scale, const Color &emission, const Color &color, const ReﬂectionType reﬂection_type) : RaymarchingObject(position, scale, emission, color, reﬂection_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 ϝϯΨʔͷεϙϯδͷແݶ൛ͷڑ཭ؔ਺

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; ःณ෺ͳ͠ EJTUBODFMFOHUI

ःณ෺͋Γ EJTUBODFMFOHUI

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 [email protected]   [email protected]িಥ఺͔ΒޫݯͷϕΫτϧ  O۶ંΦϒδΣΫτͷ๏ઢ

w ୯७ͳ಺ੵ͕ͩɺٿମʹݶΓͦΕͬΆ͘ͳΔ w ಾͷͱ͍͏ఆ਺ return 1.0 + pow(1.07 * std::max(dot(n, -light_dir), 0.0), 100.0);