Search Unity

CustomRenderTexture 2 passes / cyclic dependency error

Discussion in 'Shaders' started by vladstorm_, Jul 28, 2017.

  1. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    Hi,

    I'm trying to use CustomRenderTexture but having an error.
    I have a liquid simulation system with 2 shaders where
    shader 1 depends on texture A and generates texture B
    shader 2 depends on texture B and generates texture A


    so I set up the CustomRenderTexture A and B and run 2 serial updates via script. Then I have this error
    Code (CSharp):
    1. Assertion failed: Custom Texture cyclic dependency should not exist.
    Which is weird. Why i can't use cyclic dependency when I run passes via script ?

    Another way to do it is to run 2 different passes with just one texture on IN and OUT of those passes. but I can't figure out how to switch passes via script because it's not documented. i didnt find a command like SetPass() or anything
    https://docs.unity3d.com/Manual/CustomRenderTextures.html

    Please, tell me either how can I run 2 different passes on CustomRenderTexture via script or how can I avoid cyclic dependency on 2 CustomRenderTextures.


    P/S CustomRenderTexture should be a cool thing but the way its implemented atm is bit confusing.
     
    Last edited: Jul 28, 2017
  2. andrei_kushner

    andrei_kushner

    Joined:
    May 23, 2018
    Posts:
    1
    I have the same error and the same question
     
  3. grllle

    grllle

    Joined:
    May 4, 2015
    Posts:
    28
    I think you need to use an extra texture as input for CustomRenderTexture B and blit A's output between A and B.

    At least that seems what they are doing with a double buffered CustomRenderTexture according to the docs: