Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Is it possible to bind a RenderTexture to a Texture3D in a VFX asset?

Discussion in 'Visual Effect Graph' started by ShiftedClock, Aug 2, 2020.

  1. ShiftedClock

    ShiftedClock

    Joined:
    Sep 12, 2012
    Posts:
    18
    Edit: Problem solved, my configuration was slightly incorrect somehow. I would delete this post but I can't figure out how, please close it if possible. This does work, as can be seen here:


    Using 2020.1, I have a Texture3D asset that is used to initialize a RenderTexture, which is then bound to a fragment shader and a compute shader. I can modify the RWTexture3D in the compute shader, and the changes are visible in the fragment shader, like this shrink/grow effect:



    The goal is to have the level "geometry" represented as Texture3D's that the player can modify (through compute shaders). I want the VFX graph collider to change accordingly, so particles bounce off the walls as they're changed.

    I set up a test script that sets some properties on a test vfx, including an object's position and the same Texture3D that's used to initialize the RenderTexture. This code works, you can see particles bouncing off around the center of the block:


    vfx.SetTexture(vfxTexId, sdfData.sdfTexture);




    But when I change it to use the same RenderTexture that's passed to the fragment+compute shaders, it doesn't work, you can see the particles passing directly through without any bounces:


    vfx.SetTexture(vfxTexId, renderTexture);




    Is it possible to bind a RenderTexture as a Distance Field in a VFX graph, so that it updates when a compute shader modifies it?

    Thanks for reading, any info is appreciated, and let me know if there's any other info that would help.
     
    Last edited: Aug 2, 2020