3 पॉइंट द्वारा GN⁺ 2024-04-16 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • Spectral ray tracing RGB values ही ले जाने वाली rays के बजाय wavelength और phase तक को handle करके, हर pixel के लिए spectral power distribution (SPD) तैयार करने का तरीका है
  • सामान्य ray tracing performance के लिए camera से light source की दिशा में reverse trace करता है, और rays को RGB vector वाले particles की तरह simplify करता है
  • इंसानी आंख छोटे, मध्यम और लंबे wavelengths के प्रति संवेदनशील तीन तरह की cone cell responses से color बनाती है, और एक ही color अलग-अलग SPD से आ सकता है
  • Dispersion या thin film interference जैसे scenes में, जहां wavelength light के path और color को प्रभावित करता है, सिर्फ RGB approximation अपर्याप्त हो सकता है
  • JavaScript और GLSL से बना dependency-free spectral ray tracer, light के नियमों को जानबूझकर बदलने वाली computer art में अवास्तविक colors और motion बनाने के tool के रूप में इस्तेमाल होता है

Code से बने camera और ray tracing

  • Computer art में scene और camera दोनों code से बनाए जाते हैं, और rendering result को RGB values array में convert किया जाता है
  • Ray tracing virtual objects के बीच rays को bounce कराते हुए, simulated camera और light source के बीच से गुजरने वाले light paths को model करता है
  • Performance की वजह से असली light movement को हूबहू trace नहीं किया जाता, बल्कि कई simplifications इस्तेमाल किए जाते हैं
    • ज्यादातर light source rays camera तक नहीं पहुंचतीं, इसलिए light source से शुरू करने के बजाय camera viewpoint से उल्टी दिशा में trace किया जाता है
    • यह reverse tracing इस T-symmetry assumption के तहत physically valid है कि light transport के नियम time direction के प्रति symmetric हैं
  • इससे भी बड़ा simplification यह है कि ray को wave के बजाय RGB color vector वाले particle की तरह handle किया जाता है
    • यह light की wave nature को ignore करता है, लेकिन कई scenes में physically plausible results देता है
    • इंसानी आंख में छोटे, मध्यम और लंबे wavelengths के प्रति संवेदनशील तीन तरह की color-sensing cells होना इस approximation को संभव बनाता है

आंख RGB पर नहीं, spectrum पर react करती है

  • वास्तविक light आम तौर पर single wavelength नहीं होती, बल्कि कई wavelengths के मिश्रण वाली spectral power distribution (SPD) से बनी होती है
  • इंसान जो एक color देखता है, उसके लिए अनगिनत SPD correspond कर सकते हैं; इस phenomenon को metamerism कहा जाता है
    • उदाहरण के लिए, yellow को लगभग 580nm के आसपास के single wavelength के रूप में भी देखा जा सकता है
    • Computer monitor जैसे RGB-only devices में red और green light के combination से भी yellow reproduce किया जाता है
  • Magenta जैसे non-spectral colors भी होते हैं जिन्हें single wavelength से नहीं बनाया जा सकता
    • Magenta spectrum पर किसी single position पर नहीं होता
    • इसके लिए low wavelength और high wavelength, यानी blue और red light का combination चाहिए
  • SPD को color में बदलने की प्रक्रिया mathematically handle की जा सकती है
    • Physics, physiology और subjective color experience को जोड़ने वाला quantitative link मौजूद है
    • यह link 1931 में बनाए गए CIE 1931 color spaces में शामिल है
  • इसे खुद implement करने के लिए Physically Based Rendering का color-related chapter देखा जा सकता है

ऐसे scenes जहां wavelength result बदल देता है

  • Ray tracing में हमेशा पूरे spectrum या individual rays की wavelength पर विचार करने की जरूरत नहीं होती
  • लेकिन कुछ scenes में light की wave nature सीधे path को प्रभावित करती है, और नतीजे में दिखने वाला color भी बदल जाता है
  • इसका representative example dispersion है
    • Light का travel path wavelength के हिसाब से अलग-अलग मुड़ता है
    • Prism द्वारा white light को उसकी component frequencies में बांटना इसी phenomenon का उदाहरण है
  • एक और example thin film interference है
    • यह soap bubbles में दिखने वाले rainbow-like patterns को explain करता है
    • Soap boundary की upper और lower layers से reflected light constructive और destructive interference पैदा करती है
    • यह process spectrum को single wavelengths में अलग करने के बजाय, spectrum के कुछ हिस्सों के contribution को बढ़ाता या घटाता है
    • नतीजे में cyan, teal, magenta, brown जैसे non-spectral colors अक्सर बनते हैं

Spectral ray tracing क्या handle करता है

  • Spectral ray tracing, light की wave nature को ध्यान में रखने वाली ray tracing है
  • यह दुनिया को सिर्फ RGB color से calculate नहीं करता, बल्कि scene के हर pixel के लिए spectral power distribution बनाता है
  • Ray की wavelength और phase को साथ में इस्तेमाल करके, उन situations में color का बेहतर estimate करता है जहां यह information महत्वपूर्ण होती है
  • Dispersion या thin film interference जैसी cases में, जहां wavelength और phase resulting color को बदलते हैं, यह खास तौर पर उपयोगी है

Computer art में उपयोग

  • हालिया works में light के चलने के नियमों को जानबूझकर तोड़कर, वास्तविकता से थोड़े अलग universe का camera code से बनाने का तरीका इस्तेमाल हुआ है
  • पूरे light spectrum की richness को handle करते हुए, light transport rules को non-realistic तरीके से बदला जा सकता है
  • Published outputs हाथ से लिखे गए dependency-free JavaScript और GLSL spectral ray tracer से generate किए गए हैं
  • Example works में ये शामिल हैं
    • Light Doesn't Bend That Way #1, 2023
      • Reflection angle को wavelength का function बनाकर generate किया गया
      • यह process केवल spectral colors ही generate करती दिखती है
    • Untitled, 2023
      • FULL_SPECTRUM series के लिए work-in-progress piece है, और 2023 में Tokyo में सार्वजनिक किया गया
    • Untitled, 2023
      • Video 3 के रूप में उपलब्ध है
      • इस system में artwork को move कराने की process को खास तौर पर महत्वपूर्ण माना गया है
    • Untitled, 2024

1 टिप्पणियां

 
GN⁺ 2024-04-16
Hacker News की राय
  • अगर आप खुद बनाकर देखना चाहते हैं, तो मुफ्त e-book Ray Tracing Gems II 1 नए API और hardware acceleration पर आधारित real-time GPU ray tracing को कवर करती है, और इसमें spectral rendering पर भी एक अध्याय है
    खास तौर पर अध्याय 42 “Efficient spectral rendering on the GPU for predictive rendering” इसी से जुड़ा है

    1 https://www.realtimerendering.com/raytracinggems/rtg2/

    • बहुत तेज़ शुरुआत के लिए Ray Tracing in One Weekend 1 भी सुझाऊंगा, और अगर बाद में गहराई में जाना चाहें तो Physically Based Rendering [2] अच्छा है

      1 https://raytracing.github.io/

      [2] https://pbrt.org/

    • ray tracing को खुद हाथ से आज़माने का समय नहीं है, लेकिन किताब के शुरुआती हिस्से को सरसरी तौर पर देखा तो alias sampling एक बेहद elegant और अच्छी तकनीक लगी
      यह graphics से कहीं व्यापक संदर्भों में उपयोगी है, इसलिए लगा कि काश इसके बारे में पहले पता होता

  • spectral ray tracer के उदाहरण के तौर पर कुछ विकल्प हैं
    Mitsuba differentiable rendering जैसी कई शानदार सुविधाओं वाला open source research renderer है https://www.mitsuba-renderer.org/
    Maxwell में अलग-अलग accuracy वाले दो spectral mode हैं, और अधिक जटिल तरीका optics में अक्सर इस्तेमाल होता है https://maxwellrender.com/
    Wētā FX का Manuka एक spectral renderer है और कई feature films में इस्तेमाल हुआ है https://dl.acm.org/doi/10.1145/3182161 और https://www.wetafx.co.nz/research-and-tech/technology/manuka

    • अगर आप अंदरूनी संरचना देखना चाहते हैं, लेकिन बड़े production वाले सिस्टम बहुत जटिल लगते हैं, तो इस implementation को देखने की सलाह दूंगा
      यह spectral path tracer के minimal setup के करीब एक बेहतरीन उदाहरण है https://github.com/TomCrypto/Lambda

    • Indigo Renderer और open source LuxRender भी हैं

      https://indigorenderer.com

      https://luxcorerender.org

  • मेरे विचार में spectral rendering इस बात का अच्छा उदाहरण है कि ray tracing खुद rendering का अंतिम पड़ाव नहीं, बल्कि शुरुआती बिंदु जैसा है
    कभी-कभी real-time ray tracing को लेकर ऐसा माहौल दिखता है मानो rendering की समस्या हल हो गई हो, लेकिन मुझे लगता है कि यह हकीकत से काफी दूर है
    जहां तक मुझे पता है, ज़्यादातर spectral rendering systems thin-film interference या दूसरे wave-based effects को handle नहीं करते, इसलिए वह भी एक अलग frontier है
    वास्तविक दुनिया में हैरान कर देने जितनी detail होती है

    • rendering जितनी ज़्यादा आधारभूत physics principles के करीब जाएगी, game engines उतने ही world simulation engines बनते जाएंगे
      आज जिन engine components को आम तौर पर अलग-अलग माना जाता है, वे एक साझा बिंदु की ओर converge होंगे; मसलन physics layer और rendering layer के बीच का फर्क कम हो सकता है
      उत्सुकता है कि क्या यह रुझान अभी भी कुछ हद तक दिखाई दे रहा है
      computing performance अगर कई orders of magnitude और बढ़ जाए, तो आज की abstractions भी 30 साल पहले की cutting-edge technology की तरह, पुराने technical constraints से बनी चीज़ें लगेंगी

    • यह fractal जैसा है: जितना करीब से देखते हैं, जो हम देखते हैं उसे प्रभावित करने वाली उतनी ही ज़्यादा details सामने आती हैं
      हम 100% physically accurate rendering के धीरे-धीरे करीब पहुंच रहे हैं, लेकिन शायद 100% तक कभी नहीं पहुंचेंगे और छोटे-छोटे प्रतिशत लगातार जोड़ते रहेंगे

    • वास्तविक दुनिया में हैरान कर देने जितनी detail होती है—इस बात के अलावा, light polarization1 भी है, जिसे implement करने वाले कम हैं लेकिन कुछ खास scenes में यह काफी noticeable effect देता है

  • एक बेहतरीन spectral ray tracing engine LuxRender है: https://luxcorerender.org/
    हालांकि यह पुराने version के संदर्भ में है, और नए LuxCore renderer में full spectral support नहीं है
    यहां बताए गए effects के अलावा भी spectral rendering के और फायदे हैं
    अगर इसे light tracing तरीके से implement किया जाए, तो बाद में light source का color, spectrum और intensity बदला जा सकता है, और कई scenes में indirect lighting भी कहीं ज़्यादा accurate हो जाती है

  • अगर आप ray tracing implementation के साथ प्रयोग करना चाहते हैं, तो इसे खुद लिखना हैरानी की बात है कि आसान है
    एक अच्छी मुफ्त किताब (https://raytracing.github.io/books/RayTracingInOneWeekend.ht...) है, और अगर आपको Unity थोड़ी आती है, तो GPU-based tutorial (https://medium.com/@jcowles/gpu-ray-tracing-in-one-weekend-3...) भी अच्छा है
    Unity version में scene preview और camera movement को आसान बनाने वाला GUI है, इसलिए उसके साथ छेड़छाड़ करना ज़्यादा सुविधाजनक है
    अगर शुरुआत से नहीं लिखना चाहते, तो इन resources पर आधारित implementations भी बहुत हैं, लेकिन खुद करके देखना निश्चित रूप से क़ीमती है
    basic implementation के साथ खेलते हुए मैंने rays को particles की तरह चलवाकर उनके paths को objects की ओर या उल्टी दिशा में मोड़ना, या आखिरी reflection angle को याद रखकर अगले material collision में इस्तेमाल करना आज़माया था
    ज़्यादातर results खास नहीं थे, लेकिन जिस चीज़ को देख रहा था उसके बारे में intuition बना, और camera को थोड़ा हिलाकर देखना भी काफ़ी मददगार रहा
    छोटे hobby programming project के तौर पर यह वाकई मज़ेदार है
    बस, किसी object से intersection होने पर ray की maximum length छोटी set करता है, फिर उस point से आसपास कई rays छोड़ता है और हर collision पर gravity equation जैसी कोई चीज़ लागू करता है
    बेशक यह slow है और सिर्फ approximation है, लेकिन आसान है, और scene में light को bend करने वाला black hole object जैसी चीज़ भी implement कर सकते हैं

    • जब मैंने अपना पहला ray tracer लिखा था, तो उसमें पूरा weekend नहीं लगा; वह एक रात में लिखा हुआ C code के करीब चार pages था

      http://canonical.org/~kragen/sw/aspmisc/my-very-first-raytra...

      बाद में मैंने Clojure और Lua में ray tracers, और JavaScript में एक ray marcher बनाया; ये बहुत छोटे और सरल हो सकते हैं
      कल रात मैंने mentor/TBC का Spongy https://www.pouet.net/prod.php?which=53871 देखा, जिसमें fog वाला fractal animation ray tracer 65 machine-language instructions में है और MS-DOS executable 128 bytes का है
      ray tracing images इतनी शानदार होती हैं कि उन्हें बनाने वाले algorithms और data structures भी बहुत मुश्किल होंगे, ऐसा सोचकर डर जाना आसान है, लेकिन अगर आपको 3D vectors पहले से पता हैं, तो असल में यह काफ़ी सरल है
      SDF ray marching मुझे पारंपरिक Whitted-style ray tracer से भी सरल लगता है, क्योंकि यह scene geometry के साथ exact intersection हल करने वाली जटिल maths के बड़े हिस्से को बहुत सरल sequential approximation algorithm से बदल देता है
      Spongy या Oscar Toledo G. के bootsector raytracer https://github.com/nanochess/RayTracer जैसे बेहद छोटे ray tracers कई बार थोड़े बड़े implementations की तुलना में समझने में उल्टे कठिन होते हैं
      इतना छोटा बनाने के लिए बहुत tricks चाहिए होती हैं, और वे tricks सीधे-सादे code से समझने में मुश्किल होती हैं

  • अंत तक जाना हो तो हर ray की wavelength के साथ-साथ polarization और phase भी track करने होंगे
    ऐसी properties वास्तविक human perception को प्रभावित करती हैं, ऐसे cases thin films या diffraction gratings जैसे rare हैं, लेकिन निश्चित रूप से मौजूद हैं

  • maths और physics के सच में काम करने की खूबसूरती दिखती है
    सोचता हूँ कि सुंदरता के लिए जोड़े गए कुछ adjustments क्या दूसरी visualization approaches में भी उपयोगी हो सकते हैं
    Apple II पर polyphonic music बनाने के लिए किताब का code टाइप करके copy करने का समय भी याद आता है
    चलाकर देखा तो साफ़ था कि कुछ गड़बड़ है, लेकिन कर्कश noise की जगह अजीब तरह से सुंदर tone patterns निकले, और वह accidental mistake काफ़ी मोहक थी

  • लगता है कि hyperspectral images जैसी 3 channels से बहुत आगे की images बनाई जा सकती हैं
    बच्चों को रंग बेहतर सिखाने के लिए spectrum को highlight करने के उद्देश्य से मैंने इसे देखा था
    उदाहरण के लिए image1 पर किसी pixel पर mouse ले जाने से spectrum दिखे, ताकि color और spectrum का संबंध मजबूत हो
    लेकिन hyperspectral images दुर्लभ हैं, और परंपरागत रूप से cameras[2] महंगे रहे हैं
    तो synthetic hyperspectral images कैसी रहेंगी?
    बहुत low-resolution browser renderer lighting और materials के साथ interactively खेलने लायक तेज़ हो सकता है
    साथ ही color vision deficiency, “cataract lens हटाने के बाद UV देख सकने वाले” इंसान, dichromatic non-primate mammals (चूहे/कुत्ते), और tetrachromatic zebrafish के viewpoints भी implement करके देखे जा सकते हैं

    1 http://www.ok.sc.e.titech.ac.jp/res/MSI/MSIdata31.html
    [2] time-multiplexed narrow-band illumination इस्तेमाल करने वाला सस्ता multispectral camera: https://ubicomplab.cs.washington.edu/publications/hypercam/

    • light tracing इस्तेमाल करें तो इसे efficiently implement किया जा सकता है
      image की final value हर light source के contributions को transform किया हुआ value है, और चूंकि light source का spectrum पता है, इसलिए pixel का spectrum भी रखा जा सकता है
      हालांकि अगर meaningful dispersion या thin-film effects मिलते हैं, तो हर path के लिए wavelength sample करनी पड़ेगी, इसलिए यह ज़्यादा approximate approach बन जाती है
  • मैं अपने distribution ray tracer में refraction लागू करने के बारे में सोच रहा था
    यह probabilistic तरीका है, parallel तरीका नहीं https://en.m.wikipedia.org/wiki/Distributed_ray_tracing
    मुझे लगता है कि frequency को random तरीके से sample करके, उसका color calculate करने के बाद उसे ray color को adjust करने में इस्तेमाल किया जा सकता है
    pure refraction color की brightness 1/3 हो जाने को compensate करने के लिए result को 3 से multiply करना होगा

    • “distribution ray tracing” शब्द शायद Whitted ray tracing से आज के path tracing की ओर evolve होने के बीच के दौर की अभिव्यक्ति के ज्यादा करीब था
      मेरी याद में यह Rob Cook के SIGGRAPH papers में से एक में आया term है
      ज्यादा general और unified concept के तौर पर path tracing की तरफ जाना बेहतर है, और search या research करते समय tips और techniques ढूंढना भी आसान होता है
      spectral rendering और refraction को combine करते समय distribution को sample करके frequency चुननी पड़ती है, यह सही है
      आम तौर पर यह tricky हो सकता है, इसलिए step-by-step build करना बेहतर है
      reflection के लिए भी यही बात है, लेकिन दोनों cases में frequency-dependent materials इस्तेमाल करने हैं या नहीं, यह आपकी choice पर निर्भर है
      simplified materials इस्तेमाल करने पर भी spectral approach अपनाने की वजह फिर भी रहती है