Search Unity

Static batching messing with vertex colors?

Discussion in 'General Graphics' started by thebarryman, Oct 3, 2017.

  1. thebarryman

    thebarryman

    Joined:
    Nov 22, 2012
    Posts:
    130
    Does static batching modify vertex colors somehow? Such as converting the colors to a lower bit depth?

    I am storing data in vertex colors which I'm then using, in my vertex shader, to look up and blend between values in a StructuredBuffer.

    This works fine with a "DisableBatching" = "True" tag, but once I allow static batching the vertices are no longer retrieving the correct data from the buffer.

    There are no calculations being done in local space in my shader, so I don't think that batching "gotcha" applies in this case.
     
  2. thebarryman

    thebarryman

    Joined:
    Nov 22, 2012
    Posts:
    130
    I was able to fix the problem I was having by packing the data differently - I'm now storing part of the data in the primary texture coordinate so there is far less data that now needs to be packed into the vertex color.

    This makes me think there is some kind of change to the precision of the vertex color when static batching is enabled, but I can't find any documentation about that. It'd be nice to get an explanation of what's going on, but this specific problem is solved.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,795
    I think it's related to this bug : https://issuetracker.unity3d.com/is...when-certain-shaders-are-present-in-the-scene

    (by the way, since I did that bug report, the "certain shaders" part was added by QA, I don't use any of the shaders mentioned in my real scenes, so I don't know how related it is)

    Anyone have any hints on how I can work around this? I use vertex colors a lot and static batching keeps wiping them in my scenes.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619