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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

extending PositionDepth.cs : VFXBlock via Camera_colorBuffer / Camera_depthBuffer

Discussion in 'High Definition Render Pipeline' started by brianchasalow, Oct 14, 2019.

  1. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    204
    Hi there- i'm on 2019.3.0b6 - @ThomasVFX, and other VFX Graph team folks.

    I'm looking at PositionDepth.cs (the VFXBlock version) and trying to make it work with a camera other than the MainCamera. Firstly, it would appear that even though there's a "Custom" dropdown for the Camera field, this functionality seems unfinished maybe?

    I can get most of the way there I think with VFXPropertyBinders. I made a VFXCameraBinder, where it reads from the Camera and applies all the public fields to the PositionDepth block. My only issue, I think, is I don't know how to set the colorBuffer or depthBuffer Texture2DArrays using the color/depth from the secondary camera.

    I figured it'd be something like this, but this doesn't work. Initializing in UpdateSubProperties():

    Code (CSharp):
    1.             ColorBuffer = m_Property + "_colorBuffer";
    2.             DepthBuffer = m_Property + "_depthBuffer";
    and then applying:

    Code (CSharp):
    1.  
    2.         public override void UpdateBinding(VisualEffect component)
    3. {
    4.             component.SetTexture(DepthBuffer, otherCamera.targetTexture);
    5.             component.SetTexture(ColorBuffer, otherCamera.targetTexture);
    and then somehow it would read the _colorBuffer and _depthBuffer from each of those textures?
    Do I need to render my second camera to a rendertexture for this to work at all?
    I don't quite understand what's going on, because there doesn't seem to be a public setter for SetTexture2DArray which is what those fields need, i think, and the shaders use Camera_colorBuffer and Camera_depthBuffer which I can't see defined anywhere. But there's a Camera_depthBuffer_b and Camera_colorbuffer_b in the generated vfx graph shaders and I don't know where they're coming from...
     
    Last edited: Oct 14, 2019