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

Feedback Please improve the documentation of SRP batcher

Discussion in 'Universal Render Pipeline' started by liiir1985, May 6, 2020.

  1. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    SRP Batcher is really a very nice Feature, it improves the performance significantly in our game, but it caused render artifacts so we couldn't enable it for quite a long time.

    And now we really need its power to achieve better performance, so I took many hours to experiment why the artifacts would occur in our scene, and not able to reproduce in a clean unity sample scene.

    Finally, I found the cause for the artifacts, and it's indeed not a bug, but you should really document it clearly, otherwise it'll make this wonderful feature be useless for many people.

    The problem is, unity will treat all textures declared in a shader, which are not included in the propery block, as a per frame value, and this will cause it to use random texture to render all objects in the scene. We have some textures that are set automatically during runtime, and they are not suppose to be serialized nor set by the artist, so we didn't expose it in the property block, which caused the problem. It makes sense how unity did this, but it really need to be documented in the srp batcher's Documentation, it's too under documented at the moment imo.
     
  2. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    It doesn't sound correct that it uses random textures. If not compatible, it should fall back to the old render path. Can you open a case about this on fogbugz? :)
     
  3. arnaud-carre

    arnaud-carre

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    97
    You're right, if texture isn't declared in the shader property section, SRP batcher think it's a "global" texture instead of a "per material" texture. The shader is still SRP batcher compatible, but the texture isn't properly bound in the middle of a batch. ( so you could have previously random bound texture ). That's the expected behavior of any global (ie not per material) texture.
    Declaring the texture name in the shader property section should fix your use case.

    I agree the documentation should be improved regarding this.
     
  4. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    It is srp compatible shader, and it's actually not a bug, like described below.

    Yes, we solved the problem by declaring the texture inside the shader property, it's just unity didn't mention this behaviour in the documentation.