Search Issue Tracker

Won't Fix

Votes

13

Found in

2018.1.0f2

Issue ID

1038686

Regression

No

Graphics.DrawMeshInstanced doesn't draw anything in build

Windows

-

To reproduce:

1. Open the project, attached by the user (TestInstancing.zip)
2. Open the "SampleScene" scene
3. Enter Play mode
4. Observe that 3 red cubes are drawn
5. Build and run the project for PC standalone
6. Observe that in the build nothing is drawn

Expected: the cubes are drawn in the build as well

Reproduced in 2017.3.2f1, 2017.4.3f1, 2018.1.0f2, 2018.2.0b4, 2018.3.0a1

Reproduced on Windows, Mac and WebGL

  1. Resolution Note (2018.3.X):

    This happens because shader have instancing support but the material they use (with enabled instancing) is created at runtime, so the "instancing variants" are stripped on build. As a workaround it is enough to create material with this shader and instancing enabled and assign it to some public variable in script.
    But there might be better workarounds

Comments (11)

  1. mahis4799

    Apr 28, 2020 05:45

    Go to Roku page https://sites.google.com/site/rokuactivationn/ record enter Roku com activation code appeared on Roku TV. My Roku com activate not working use new Roku code.

  2. LightStriker

    Mar 07, 2019 17:22

    It's not a "bug", but a feature, as stripping unwanted shaders is very useful.

    What you want to do, is have a script on a GameObject in a scene you use, and have it a Material field. Create a material, apply your shader on it, and enable "Instancing" on it. Assign your material to your gameobject.

    This way, the compiler will see your shader being used and won't strip it.

  3. devil_is_god

    Dec 28, 2018 04:03

    I also having the same issue,and i don't know how to fix it! I'm using Unity 2017.4.3.f

  4. fnaith

    Oct 01, 2018 08:04

    Solve by attaching materials with our shader to a GameObject, then us:

    GameObject.Find("Shader").GetComponent<Renderer>().materials

    to load shader and copy it to runtime generated material

  5. fnaith

    Sep 29, 2018 04:49

    not fixed in Unity-2018.2.10f1

  6. fnaith

    Sep 22, 2018 01:13

    Bug still appears in Unity-2018.2.9f1

  7. fnaith

    Sep 16, 2018 01:13

    Will this bug also remain us to build standalone regularly...

  8. petey123567

    Sep 15, 2018 18:49

    This is affecting our shipping game, any ETA on a fix?

  9. fnaith

    Sep 14, 2018 02:47

    Up

  10. fnaith

    Sep 12, 2018 08:46

    Dear all, this problem still exist in 2018.2.7f1.

    My scene is more complex but it works with on edit mode:
    https://user-images.githubusercontent.com/11421034/45274388-de043f00-b4e9-11e8-984f-99d289602a74.PNG

    But after building as standalone windows exe. The input still works, but I cannot see anything include ambient light color effect

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.