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

redflash renderer / Raytracing Camp 7

がむ
September 07, 2019

redflash renderer / Raytracing Camp 7

レイトレ合宿7の自作レンダラーのプレゼン資料です。
OptiX6上でレイマーチングとポリゴンをハイブリッドにレンダリングできるパストレーサーを実装しました。
https://github.com/gam0022/redflash
https://sites.google.com/site/raytracingcamp7/

がむ

September 07, 2019
Tweet

More Decks by がむ

Other Decks in Technology

Transcript

  1. Α͋͘Δػೳ͸͢΂࣮ͯ૷ʂ • Unidirectional Path Tracing ‣ implemented in NVIDIA® OptiX

    6.0 • Disney BRDF • Next Event Estimation (Direct Light Sampling) • Multiple Importance Sampling • Primitives ‣ Sphere ‣ Mesh ‣ Distance Function (Raymarching) • ACES Filmic Tone Mapping • Deep Learning Denoising 3
  2. ϨΠϚʔνϯάͱ͸ • ڑ཭ؔ਺ΛώϯτʹϨΠΛগͣͭ͠ਐΊΔ͜ͱͰަࠩ൑ఆ • ڑ཭ؔ਺ = ೚ҙͷ఺p͔Β෺ମද໘΁ͷ࠷୹ڑ཭Λฦؔ͢਺ 5 float sdSphere(

    vec3 p, float s ) { return length(p)-s; } float udBox( vec3 p, vec3 b ) { return length(max(abs(p)-b,0.0)); } http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
  3. ڑ཭ؔ਺ͷܰྔԽ • Mandelbox ͱ͍͏఻౷తͳϑϥΫλϧਤܗ • if෼ذ΋͋ͬͯॲཧ͕ॏ͍… • ݟͨ໨ͷྼԽΛ཈͑ͳ͕Βڑ཭ؔ਺ΛܰྔԽʂ 8 //

    http://blog.hvidtfeldts.net/index.php/2011/11/distance-estimated-3d-fractals-vi-the-mandelbox/ float minRadius2 = 0.5; float fixedRadius2 = 1.0; float foldingLimit = 1.0; #define Iterations 8 void sphereFold(inout vec3 z, inout float dz) { float r2 = dot(z,z); if (r2 < minRadius2) { // linear inner scaling float temp = (fixedRadius2 / minRadius2); z *= temp; dz *= temp; } else if (r2 < fixedRadius2) { // this is the actual sphere inversion float temp = fixedRadius2 / r2; z *= temp; dz *= temp; } } void boxFold(inout vec3 z, inout float dz) { z = clamp(z, -foldingLimit, foldingLimit) * 2.0 - z; } float dMbox(vec3 z) { vec3 offset = z; float dr = 1.0; for (int n = 0; n < Iterations; n++) { boxFold(z, dr); // Reflect sphereFold(z, dr); // Sphere Inversion z = kadoScale * z + offset; // Scale & Translate dr = dr * abs(kadoScale) + 1.0; } float r = length(z); return r / abs(dr); } float dMandel(float3 p, float scale, int n) { float4 q0 = float4 (p, 1.0); float4 q = q0; for (int i = 0; i < n; i++) { q.xyz = clamp(q.xyz, -1.0, 1.0) * 2.0 - q.xyz; q = q * scale / clamp(dot(q.xyz, q.xyz), 0.5, 1.0) + q0; } return length(q.xyz) / abs(q.w); } ܰྔԽ ※GLSL ※HLSL ҰൠԽ͞Εͨܗ͔ࣜΒύϥϝʔλ ൣғʹ੍ݶΛ͚ͭͯॲཧΛ؆ུԽ
  4. ϨΠϚʔνϯάͷিಥ൑ఆͷਫ਼౓ͷLOD 1/2 • Χϝϥʹ͍ۙ෦෼͸ detail ͕ཉ͍͠ • ԕ͍෦෼͸ݫີʹিಥ൑ఆ͠ͳͯ͘ྑ͍ ͭ·Γ-0%(Level of

    Detail) ͕͍ͨ͠ʂ • Mandelboxͷڑ཭ؔ਺͸ %JTUBODF&TUJNBUPSʢڑ཭ਪఆثʣ ‣ ༗ݶͷΠςϨʔγϣϯճ਺Ͱ͸ද໘ʹ઴ۙ͢Δ͕ɺڑ཭0ʹͳΒͳ͍ ‣ ద౰ͳڑ཭ eps ͰিಥͱΈͳͯ͠ܭࢉΛଧͪ੾Δඞཁ͕͋Δ ‣ eps Λখ͘͢͞ΔͱɺΑΓࡉ͔͍ detail ·ͰՄࢹԽͰ͖Δ ‣ ԕܠ·Ͱ eps ͕খ͍͞ͱߴप೾੒෼͕ݱΕͯ݁Ռ͕Ԛ͘ͳΔʢMipMap OFFঢ়ଶʣ 9 ଎౓໘ ඼࣭໘
  5. ϨΠϚʔνϯάͷিಥ൑ఆͷਫ਼౓ͷLOD 2/2 • Χϝϥ͔Βͷڑ཭ = ϨΠ͕ਐΜͩڑ཭ Λ༻͍ͯ eps Λಈతʹܾఆ •

    ϨΠϚʔνϯάͷিಥ൑ఆͷਫ਼౓ͷLOD͕Ͱ͖ͨʂ • ۙܠʙԕܠ͕ࠞࡏͨ͠ΧοτͰ΋៉ྷʹඳըͰ͖Δʂ 10
  6. 1ճͷlaunchͰͳΔ΂ͨ͘͘͞ΜαϯϓϦϯά͢Δઓུ • OptiXͰ͸ launch ͰγʔϯͷඳըΛ࣮ߦͰ͖Δ • sample_per_launchʢ1ճͷlaunch͝ͱͷαϯϓϦϯάճ਺ʣ
 Λ૿΍͢ͱɺCPUॲཧͷΦʔόʔϔουΛݮΒͤΔ ‣ υϩʔίʔϧ࡟ݮͷ࠷దԽͱಉ͡ݪཧ

    • ࠷ॳͷ4αϯϓϦϯάͰϚγϯͷੑೳΛϕϯνϚʔΫ ‣ ࣌ؒ੾ΕʹͳΒͳ͍࠷େͷ sample_per_launch Λܾఆ ‣ launch ίετΛ࠷খԽ 11 TBNQMF@QFS@MBVODI UPUBMTBNQMF       RTX2070 60ඵͷܭଌ݁Ռ
  7. • Deep Learning Denoising ༻ʹ albedo ͱ normal Λੜ੒ ‣

    Bufferʢ= RenderTextureʣ͕߹ܭͰ5ຕ΋ඞཁʹͳͬͯ͠·ͬͨ • ΢Οϯυ΢ʹදࣔ͠ͳ͍ͳΒ RT_BUFFER_GPU_LOCAL ͰOK ‣ createBuffer ͷୈ1Ҿ਺ͰࢦఆͰ͖Δ ‣ An RT_BUFFER_INPUT_OUTPUT has separate copies on each device that are not synchronized • 60ඵؒͷαϯϓϦϯά਺͕ 88 → 100 (13.6%) ʹ૿͑ͨʂ RT_BUFFER_GPU_LOCAL ʹΑΔ࠷దԽ 13 normal albedo liner color gamma corrected
 + tonemapped denoised