Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Shader pass called twice?

Discussion in 'General Graphics' started by dotsquid, May 20, 2021.

  1. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    211
    I have a world-space UI canvas which is rendered into a render texture.
    For some reason every shader pass of each mesh is called twice.
    Знімок екрана 2021-05-20 о 16.04.20.png
    Знімок екрана 2021-05-20 о 16.04.27.png If the shader has more than one pass all passes are called twice one by one, e.g. #0 #0 #1 #1

    Any idea why is this even happening and how to stop it?

    UPD. Just forgot to mention that everything is fine in the Editor and this behaviour appears on iOS device (didn't check builds for other platforms though)
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,746
    Does it render exact same geometry for each shader pass? If this only happens on iOS device, I'd do a frame capture via Xcode, and see there what's going on. Maybe the whole canvas gets split into multiple "chunks" for some reason, and each pass renders it's own chunk.
     
  3. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    211
    I noticed that this is happening by accident. I was implementing various blend modes and it appeared that "Multiply" is much darker than it should be. So I opened frame debugger and get surprised by what was happening.
    So this not only affects the performance due to doubled draw calls but also breaks my effects since they don't look as expected.
    I had a remote chance that maybe it's due to culling set to "Off". I thought that maybe Unity for some reason draws the mesh twice with back face and front face culling. But it isn't the case.
     
  4. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    211
    Thanks for reaching me out so fast.
    It draws exactly the same mesh.
     
  5. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,746
    Ok, no idea then (I know nothing about UI/Canvas). Time for a bug report?
     
  6. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    211
    Hehe, well, I went through the captured GPU frame in XCode and surprisingly it shown that everything is fine and rendered once as it should.
    Then I came back to Unity Frame Debugger and tried other textures (the white one as background, stronger contrast for the front one) to see the details better. And it appeared that it's just an issue of the Frame Debugger. It indeed makes the renderer draw everything twice as I described in the first post. But when it's disabled everything is fine.
    What a relief.

    I'll try to find some time to commit a bug report.
     
    Aras likes this.
unityunity