Search Issue Tracker

By Design



Found in





Issue ID




CommandBuffer on AfterLighting is not executed in a player

Graphics - General


How to reproduce:
1. Open attached Unity project
2. Enter the play mode
3. Notice four colored point lights are rendered
4. Build and run test scene
5. Notice there are no colored lights drawn with the build

Expected result: Four colored point lights are rendered (Works in Editor).
Actual result: There are no colored lights drawn with the build.

Reproduced with: 2018.4.9f1, 2019.2.6f1, 2019.3.0b3, 2020.1.0a4

On step 3 you can open frame debugger and notice they are drawn in the AfterLighting phase with only one draw call.
On step 5 you can open frame debugger, connect to a build and notice there's no draw call for the four lights.
Can't test on 2017.4 because of errors.

  1. Response avatar

    Resolution Note (fix version ):

    User is using GPU instancing to draw lights in this CommandBuffer, and the instancing variant is being stripped during player build (because the shader is only being used in the script).

    To solve this:
    Go to ProjectSettings > Graphics > scroll to bottom, there is a drop down menu called "Instancing Variants" > choose "Keep All"

    Another workaround, which is less overkill:

    1. Create a material
    2. Assign user's shader to this material
    3. On the material inspector, enable the GPU Instancing checkbox
    4. Create a monobehavior script that takes a public material and does nothing
    5. Add this script component to any object on the scene
    6. Save the scene and build player as usual

    The idea is that, this will make the build pipeline knows there is something in the scene using this material, with the GPU instancing enabled shader variant.

Comments (1)

  1. B038002cae4da6cfbc91faecfe107a28?d=mm


    Sep 13, 2019 08:12

    The UPS Company is a messenger company in the United States. It has grown into a multi-billion dollar corporation by clearing focusing on the goal of enabling commerce around the globe.

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.