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. Dismiss Notice

Question Output texture from subshader

Discussion in 'Shader Graph' started by miczac, Jun 20, 2023.

  1. miczac

    miczac

    Joined:
    Feb 28, 2021
    Posts:
    7
    I am trying to create feedback/fluid simulation effects in a shadergraph. I need to output a texture2D from a shader and read it in another pass in another shader. I can't use custom Render Textures since I am in HDRP. Is there no way if doing this in HDRP?
     
    Last edited: Jun 20, 2023
  2. FredMoreau

    FredMoreau

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    112
    Hi @miczac,

    I'm not sure when this was added, but in 2023.1.1, you can use Custom Render Textures with Shader Graph and HDRP.
    1. Assets/Create/Shader Graph/Custom Render Texture
    2. Assets/Create/Custom Render Texture
    3. Assign the SG Material instance to the CRT's material field.
    4. Use that texture anywhere.
    In this example, it's used as a Light Cookie.

    image.png

    Hope this helps.
     
    miczac likes this.
  3. miczac

    miczac

    Joined:
    Feb 28, 2021
    Posts:
    7
    Ah! Dang, I had just moved my whole project to standard pipeline to be able to use Custom Render Textures, but good to know this is now an option
     
  4. miczac

    miczac

    Joined:
    Feb 28, 2021
    Posts:
    7
    Related to this: I have 3 Custom Render Textures set up. All works well but I get this (yellow) error:
    ``Custom Render Textures contain a cyclic dependency. Update order will not be sorted.`` I tried unsuccessfully to get rid of it and I can't find any reference to how to order the sorting of the textures. Any idea?
     
  5. FredMoreau

    FredMoreau

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    112
    From CustomRenderTexture documentation

    Chaining Custom Render Textures
    You can chain Custom Render Textures together. To do this, use a Custom Render Texture as the input for a material that you have assigned to the Material or Initialization Mode > Texture in another Custom Render Texture.

    You can use chained Custom Render Textures to generate a simulation with multiple steps.

    Chained Custom Render Textures are dependent on each other. Unity calculates this dependency automatically so that each update happens in the right order. It does this by looking at the materials assigned to the Material and Initialization Mode > Texture properties in the Custom Render Textures inspector window.​

    So, when CRT A depends on CRT B to render and vice-versa, the system doesn't know which one to render first.
     
  6. miczac

    miczac

    Joined:
    Feb 28, 2021
    Posts:
    7
    So you are saying that there is no way of getting rid of the error message? I did all of the above mentioned steps assigning dependencies in the Initialization mode. I tried both selecting Texture and Color and Material, selecting the CRT or Material the CRT is dependent upon but I still get the error