PyTracer : Ray tracing with Python

Поделиться
HTML-код
  • Опубликовано: 6 дек 2019
  • PyTracer was a fun coding project I worked on back in 2017. The idea was inspired by MelRay which was a ray tracer written completely in Maya’s Mel language and done by my CG supervisor Clinton Downs at New Holland.
    Why not write a ray tracer in Python? That was the initial spark that triggered me to accept this challenge.
    It took two months of my spare time. I had learned plenty of math and physics through the process. Camera, shadow ray, sampling, dof..... So many topics that I never thought about when I was using renderers in 3D programs.
    Of course the final product is not perfect, noisy, slow, can’t render anything but spheres and planes. And I still believe my hemisphere sampling is not correctly implemented. But I’m happy with the journey and the outcome is satisfying.
    Again special thanks to Clinton for the resources and inspiration.
    If you are interested, grab the code here and give it go on your machine:
    github.com/NMVHS/PyTracer
    Other failure renders:
    shawnwangvfx.com/PyTracer
  • НаукаНаука

Комментарии • 27

  • @MACHINEBUILDER
    @MACHINEBUILDER 4 года назад +6

    So impressive!!!
    I've been writing my own ray tracing engine recently, also in python :) & I've only just implemented reflections... But this is crazy!!

    • @ShawnWang
      @ShawnWang  4 года назад +2

      Thank you! Yeah, it's very fun to write your own ray tracer. You can learn a lot. Would love to see your rendered image when you are done!

    • @MACHINEBUILDER
      @MACHINEBUILDER 3 года назад

      @@ShawnWang sorry this took so long lol (I just completely forgot about everything raytracing related as soon as I finished programming the raytracer)
      but I just came back to this video, and here's the finished rendered image:
      cdn.discordapp.com/attachments/619767228832808960/771921628211707914/4k30s6rb.png
      I didn't get around to supporting refraction, I didn't implement specular, and I didn't implement anti-aliasing :P

    • @ShawnWang
      @ShawnWang  3 года назад +2

      @@MACHINEBUILDER That's excellent! A fun process, isn't it?! Thanks for sharing it. :)

    • @MACHINEBUILDER
      @MACHINEBUILDER 3 года назад

      @@ShawnWang yeah it was really fun :)
      And glad you like it haha

  • @thehandleiwantedwasntavailable
    @thehandleiwantedwasntavailable 2 года назад

    Great to see this Shawn :)

  • @infancy8846
    @infancy8846 4 года назад

    The rendering process is beautiful

  • @isaacdiaz3221
    @isaacdiaz3221 4 года назад

    Damn it, that's a glorious work.

    • @ShawnWang
      @ShawnWang  4 года назад

      Wow, thank you so much Isaac!

  • @cybermascot
    @cybermascot 4 года назад

    excellent job , thanks for codes.

  • @novygaming5713
    @novygaming5713 Год назад

    Ray tracing is the process of shooting a single ray per pixel to get an image. Path tracing (the one in the video) is the process of shooting multiple rays for every pixel then randomizing the bounce depending on roughness and averaging every ray to get a final image.

  • @marwans4018
    @marwans4018 4 года назад +1

    Wow that is amazing

  • @aaronspeedy3087
    @aaronspeedy3087 3 года назад

    GodDamn
    This is awesome,I'm currently writing my own Raytracing Shader in Python,C,C++ and C#,and Comparing them in performance,but Im only done with rendering Pixels onto a .PPM file. Wow,This is Impressive

    • @ShawnWang
      @ShawnWang  3 года назад

      Hey Aaron, that sounds fascinating! Would love to see your comparison results. You might be interested in a render window with PyQt. See it rendering in buckets is very fun. :)

    • @aaronspeedy3087
      @aaronspeedy3087 3 года назад

      @@ShawnWang Oh,Cool. I might look into that

  • @SimulatingPhysics
    @SimulatingPhysics 3 года назад +2

    Really nice project!
    I also written a Python Ray tracer, but I'm surprised of one thing. How do you manage to use all your cpu cores at 100%?
    Do you share it in the python subreddit?. We love these projects!

    • @ShawnWang
      @ShawnWang  3 года назад +1

      Hi Rafael, thank you! It was Python's multi-processing module that allowed me to utilize all the cpu cores. Sounds nice! I'd love to share it in the forum. Also codes available here: github.com/NMVHS/PyTracer

    • @novygaming5713
      @novygaming5713 Год назад

      Its called the thread module

  • @kangsan2014
    @kangsan2014 3 года назад

    Looks really good but too much noise!

  • @lethenparkesTeamRacc
    @lethenparkesTeamRacc 3 года назад

    i feel like python isnt the correct language to write stuff like this in as seeing the performance of the programming language as a whole to better languages like C++ etc

    • @ShawnWang
      @ShawnWang  3 года назад +1

      Right, to make a production ready ray tracer, C++ is definitely necessary. This is mainly a coding practice to learn ray tracing algorithms.

    • @MrBricks148
      @MrBricks148 3 года назад

      Allow pypy to introduce itself www.pypy.org/

    • @0.Andi.0
      @0.Andi.0 2 года назад

      @@MrBricks148 True, im currently implementing ray tracing in one weekend and the performance diference between pypy and the clasical CPython is huge!

  • @dissolvesoftware
    @dissolvesoftware 3 года назад

    Make the video downloadable