Search Unity

DrawMeshInstanced Does Not Work When Using SetReplacementShader In Build

Discussion in 'General Graphics' started by brilliantgames, Sep 8, 2019.

  1. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    So I've come to a very frustrating discovery. DrawMeshInstanced does not work when using SetReplacementShader specifically in a windows build. It works perfect in editor, but as soon as I make a build, the instanced models do not show up in the render when using SetReplacementShader. If I reset the camera placement shader, the models show up in the render. I even made sure the script execution order lines up so that the models are drawn before the render is called while using SetReplacementShader.

    Anyone ever come across this issue/bug? If so, are there any workarounds?
     
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Could it be that the replacement shader is stripped in the build. Try to make a material with the replacement shader. Add it to a resources folder to get it included and make sure the instanced checkbox is enabled.
     
    richardkettlewell likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    Did you ever find a solution? I also stumbled upon this issue as well. It seems DrawMeshInstanced and replacement shaders are simply not compatible in builds.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    I guess it's instancing that's the problem.

    We implemented a workaround where we use Graphics.DrawMesh instead when we activate replacement shaders and it works. But this is a bug IMO.