Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

Discussion 2023.1.0a11 - VFX Graph Ray-tracing

Discussion in '2023.1 Beta' started by cpkcpk, Sep 26, 2022.

  1. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    Hey,

    I just saw that 2023.1.0a11 has added ray-tracing support for VFX graph, but can anyone explain what scenarios this works in?

    I have enabled VFX graph in the HDRP ray-tracing settings, and found a ray-tracing checkbox in the Lit Quad Output settings, but can't see the effects of it anywhere. It doesn't show up when using path-tracing, and it's not showing up in ray-traced reflections etc

    Thanks!
     
    vx4, Zarbuz and Lex4art like this.
  2. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    Here's a very basic use case of ray-traced reflections in a mirror.

    I have checked ray-tracing support in the output quad settings, and VFX ray-tracing support in the HDRP asset, but the particles are not being reflected in the mirror. Any ideas?

     
  3. Zarbuz

    Zarbuz

    Joined:
    Oct 13, 2015
    Posts:
    22
    I ask myself the same question, seems that it has no effect in all cases.
    Bug or we don’t understand the scenario where it should work ?
     
    cpkcpk likes this.
  4. landonth

    landonth

    Joined:
    Dec 3, 2018
    Posts:
    141
    It works in my case, with some caveats / limitations. I have been testing since 2023.1a11.
     
    cpkcpk likes this.
  5. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    Ah cool, what scenarios is it working for you in? I'm still a bit confused - should I be seeing particles reflected in my screenshot above? And should particles show up when using path tracing?
     
  6. dstrictxrlab

    dstrictxrlab

    Joined:
    Oct 26, 2020
    Posts:
    2
    little more explanation would be super helpful :)
     
  7. landonth

    landonth

    Joined:
    Dec 3, 2018
    Posts:
    141
    Last time I checked only the Output Lit Quad works as expected with raytracing Output Quad (Unlit) may work as well. Output Lit Mesh and Particle Strips did not work yet. I doubt the "Imposter" primitives like Output Lit Sphere work yet either.

    I started with the latest 2023.1 alpha with one of the example raytracing scenes (I used the Apartment scene as it is quite simple and has some mirrors for easy testing of reflections.) I reccomend doing the same then drop in a new VFX graph and use some of the Quad Output contexts.

    https://github.com/Unity-Technologies/HDRPRayTracingScenes

    I started to modify VFX graph a bit to support Particle Strips with okayish results but the normals are faceted in raytracing as I was starting from the existing code for raytracing flat quads. I didn't go futher than that, i'll just wait for the Unity team to work on that integration. Though as usual... the main issue with VFX graph is the most essential runtime code for simulation (AND setting buffers for rendering) is hidden in the black box of the closed source C++ engine core.

    https://portal.productboard.com/8uf...tribute-buffer-read-access-from-outside-graph

    If this feature ^ was already available, we could just copy and read the graphicsbuffer ourselves to use as instance positions or generate a mesh using compute shaders and hand that off to the new Mesh API (or add the instances to the RTAS ourselves using the new raytracing API features for that) and it would "just work" with raytracing. I've hacked a proof of concept of some of this together myself using an HDRP Custom Pass to set a global buffer in the render pipeline context and using custom VFX graph nodes to copy the VFX Graph Attributes GraphicsBuffer to my one that I can use wherever and however I want, but it's uneccesarily complex and doesn't scale well, i've only used with one VFX graph instance at a time, managing multiple Global buffers seems it would be problematic.

    I really don't mind features not being finished or available (as I can implement then myself or someone else in the community and provide it on github or the asset store, etc) but the lack of even the simplest extensibility in VFX graph has been a huge oversight (as long as it's been anyway.)

    It seems we may be getting fairly close to an extensible VFX graph with the runtime core ported to DOTS (now that DOTS is reaching maturity) which I look forward to. This is more important than any other feature in VFX graph to the community, whether they are telling you that or not. They don't know to ask they just know that they can't do X with VFX graph and no one is providing an extension / asset to do so either. But I appreciate the desire for a solid foundation for that API.

    https://portal.productboard.com/8ufdwj59ehtmsvxenjumxo82/c/128-dots-runtime

    @ludovic-theobald @INedelcu @JulienF_Unity @SebLagarde @LaurentGibert and many others: Thanks for all the work you've done to get all these features to coalesce this far and looking forward to it coming together further in the next year and beyond. :D
     
    Last edited: Dec 7, 2022
    cecarlsen likes this.
  8. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    I've been trying in every new 2023.1 alpha version and have still never managed to get this working, so still very confused.

    Here is a screenshot from the Apartment scene in 2023.1.21. Raytracing VFX enabled in Output Lit Quad (also tried Unlit), HDRP Global Settings and Custom Frame Settings.

    2023.1.21 apartment.png
     
    Zarbuz likes this.
  9. landonth

    landonth

    Joined:
    Dec 3, 2018
    Posts:
    141
    hmm, can you zip up the project and upload it somewhere, post a link here?
     
  10. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    Sure, uploaded the project here. I had to delete the Library folder to fit on WeTransfer - https://we.tl/t-BMLdKLZ1wT

    I just cloned the HDRPRayTracingScenes project from Github, enabled VFX ray-tracing everywhere I could think of, and saved a new Apartment scene with the VFX added. The only thing I changed was Screen Space Reflections to Ray Tracing instead of Mixed.
     
  11. landonth

    landonth

    Joined:
    Dec 3, 2018
    Posts:
    141
    Ah ok so the current major limitation is (Aside from only Quad / primitive planar output working) that only the Blend Mode: Opaque seems to work with Raytracing reflections, possibly other passes. You can use Alpha Clipping in conjunction with Opaque but the other Blend Modes do not work with raytraced reflection, (though they do seem to work with raytraced shadows?). (Perhaps in the future that Opaque may be available as an auto fall back for raytracing effects even when using the other modes.)

    In the meantime (aside from using Opaque only) you could combine mutiple Outputs to get a hybrid effect.

    1. Primary Output can use Alpha (or Additive) Blend mode Output. Enable Cast Shadows and Enable Ray Tracing (for shadows.)
    2. And then for the secondary Output set Blend: Opaque and also set Cull to Front faces, so that it appears in raytraced effects like reflection but does not occlude the primary ouput. You may also want to use alpha clipping. Disable Cast Shadows and Enable Ray Tracing (for reflections.)

    It should end up looking something like this:
    Screenshot 2022-12-09 164724.png
     
    Last edited: Dec 9, 2022
    Lex4art and cpkcpk like this.
  12. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    172
    When i read the title, i assume now we can do inline ray tracining inside vfx graph. which wasnt the case. Anyway i think vfx graph need to proviede api to generate and bake mesh like SkinnedMeshRenderer.BakeMesh to build AS. In addition to support inline ray inside vfx graph.
     
    Last edited: Dec 10, 2022
    landonth likes this.
  13. cpkcpk

    cpkcpk

    Joined:
    Dec 13, 2019
    Posts:
    40
    Ah I didn't think to try changing the Blend Mode! Thanks a lot for testing and clearing that up. I just tried what you suggested and it works as expected, so will go this route until the other blend modes are added.
     
    landonth likes this.