Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Unity Ray-Tracer :)

Discussion in 'Made With Unity' started by zezba9000, Nov 4, 2013.

  1. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    So I rly wanted to make a test Ray-Tracer for Unity this weekend... and here is what came of it so far.
    Also would anybody find the ability to Ray-Trace your Unity3D scene useful as a plugin??

    $Gold.png $PinkBlueSoft.png $Robo.png $RoboColorSoft.png $RoboColor.png
     
    Last edited: Nov 4, 2013
    Ufimsev and mgear like this.
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,170
  3. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    Sounds Good. Removed the link to the other post.
     
  4. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    498
    nice results. doubt its realtime though :(
     
  5. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    419
    it looks promising, and chance you could provide a quick standalone demo (mac,pc,linux) or a web player. it looks astonishing, please tell me that is in REAL-TIME!!!!! if not, i will sob in the corner of my room (just joking). great job Btw

    dose this require unity pro?
     
  6. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    Ya I could make a demo app. Its not real-time though. Its rendered on the CPU using one core right now(would make it multi core later). But its cool because you can set your scene up in the Unity Editor.
    Also this could run in realtime using compute shaders, not sure how fast though.

    No it runs with Unity Free or Pro.


    Im kind of wondering if people would find a tool like this useful... or maybe I should just keep it a hobby project.
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    This sir is impressive! Keep Up the good work!

    BTW, I know it isn't in real-time, but how fast does it take to do ONE render? If you're going to put it up on the asset store, or post it here, that would be appreciated!
     
  8. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    Keep in mind Its a prototype so its not optimized, so its only using one CPU core ect... But as an example on the last two Pink/Blue Robot images. The one with Hard shadows took about 30sec and the Soft Shadow one took about 4min.
     
  9. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,284
    Hello, do you still have that Ray Tracer? What did you do with it? Are you going to release it?
     
  10. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    I didn't think there was any interest so never continued the project.
    If there was interest I might consider doing this but because this takes a lot of time I would need to know its worth it for me... not sure where to get the data required to make that determination though.
     
    smitchell likes this.
  11. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,284
    Well if you don't want to do any more on it and are not using it for anything, why not just put it on the internet for people to download for free? It seems a shame for all that work to go to waste!

    You could put it on the Unity Wiki pages?

    Or if you put it in the asset store I'd buy it for $15 in its current state. No problem.
     
  12. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    I'll see if I have it backed up as I did this in 2013 but keep in mind it was a simple prototype and never ment to be used for anything other then a concept with that version so I don't think that version would be useful.

    Maybe i'll take another look into making a useful one ;)
    Out of curiosity, what kind of things were you hoping to use it for? What kind of scene rendering features would be useful for something like this besides the typical features like soft-shadows ect. Maybe Volumetrics, Toon-Shading, God-Rays, Sub-surface-scattering, Ambient-Occlusion, Depth-Of-Field, ect?
     
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,919
    I think the real interesting bit happens when you turn it into a compute shader!
     
    shkar-noori likes this.
  14. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,284
    Well think it would be useful for apps where you create some sort of 3D object or creature and you want to render take a nice screenshot of it to put on Tumblr or something. Or even you could use it in a game and take a ray-traced screenshot of your car passing the finishing line.

    Or you could use it to make a ray traced image of your game scene for use as a title screen.

    I think it looks cool as it is. Maybe you could do a simple one as it is for a cheap price (or free!) and then if you want to add in all the extras you could do a pro version if you get a lot of interest!

    I think a lot of people would like it just to see how ray tracing works and mess around with the scripts.
     
  15. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    Exporting Ray traced renders from an interactive architecture walk through could be very useful.
     
  16. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    SAOTA likes this.
  17. akabane

    akabane

    Joined:
    Apr 26, 2007
    Posts:
    143
    I've also been working on an offline-ish renderer in Unity on and off, it's a modular Path Tracer, running multithreaded.
    Built it so that it's very easily portable between Unity integration and a Standalone version (as I rewrote all the math/vectors, physics, added BVH spatial subdivision bla bla to circumvent Unity API multithreaded problems). Also has its own scene format etc...I'll leave some RnD shots here! Very interesting others are working on similar stuff!

     
  18. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    520
    Very impressive! Do you have plans to release this to the public (Asset Store)? Would love to get my hands on this!
     
  19. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    920
    +1

    @akabane your work is really interesting for my non-game app
    Any plan for future release?
     
  20. akabane

    akabane

    Joined:
    Apr 26, 2007
    Posts:
    143
    @jcarpay @kenshin :
    Thanks! Glad to see some interest in this.
    For now it's just a pet project. We plan on using it in-house for visualization stills when it's "production ready" (which might be sooner than I think actually). After we delivered the first jobs with it we'll think about releasing to the community to see what can happen with it. The main problem for now is, of course, speed. Even if multithreaded, path tracing is so so cruel without SIMD vectors and very smart SAH algorithms to split the image in good buckets - two things I haven't implemented. I think the next step is going to be translating at least the rays and path calculation on a compute shader to get to use some of the power of the GPU. After that is done, I'll see what the rest of the studio thinks about it and eventually get it out on the Asset Store :)

    On another note, another branch of our renderer is getting ready to be made as small plug-ins for Unity once it gets to the computeShader route - so that one could choose to use just the traced DoF/True reflections/Indirect Light/Traced Shadows etc...so it would have a baseline rendertime (which would be the time needed for the scene to get traced) but then the time for the calculations of the path tracer can be cut by not wanting some effects, etc...We'll see :)
    Another very interesting thing will be porting it to Unity5 and see how to integrate it with the new lighting system (maybe steal unity's bdrfs to calculate the trace? hehehe), and I also read some things about new thread-safe APIs we can call. I'm going to need to see if there's something that can help the current structure of the software :)
     
    Last edited: Mar 30, 2015
  21. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    920
    Ciao Emanuele :)

    thanks for the quick answer and good luck with your development!
     
  22. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    520
    Thanks for the answer. Really interesting stuff, keep us in the loop! In case you need a beta tester, don't forget to PM me ;)
     
  23. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    This is awesome! I also ran into performance issues with Unity's version of C#/Mono (.NET would be at least 3-4 times as fast). Even with 8 cores its slower then expected. Your ray-tracer looks pretty flushed out and usable even if slow.
     
  24. christianterrence

    christianterrence

    Joined:
    Jan 23, 2018
    Posts:
    7
    Awesome work! Would you guys happen to have some code or implementation tips? I also want to make a ray tracer in Unity, preferrably in the compute shader but I can't seem to figure out how I can ray trace against the meshes made in the scene view.
     
  25. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    729
    For this ray-tracer I did a long time ago, I just used the PhysX objects to do ray collisions (as it was an experiment). However you can read mesh data from objects in Unity but they have to be marked as read/write. If you use the compute shader you might be best off manually uploading the mesh data into a buffer then later figure out if you can directly use scene data already in GPU ram. Also I think Unity 2018 is adding a ray-tracer of some kind built in.
     
  26. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    738
    Wouldn't it be better to just use octanerender now?
     
  27. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,919
    Perhaps he just wants to make a raytracer.
     
  28. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    738
    That might be true, or he just wants to render from Unity. Better to know there's an option :)