Search Unity

Standard Shader EnableKeyword("_EMISSION") Not Working on Mobile

Discussion in 'Shaders' started by wkwan, Dec 21, 2015.

  1. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
    I've got a cube using a material with the standard shader, and I want to vary the Emission dynamically.

    I'm doing it like this:
    newMesh.material.EnableKeyword("_EMISSION");
    newMesh.material.SetColor("_EmissionColor", emissionBlue);

    and it works fine in the editor. However, it doesn't do anything when I build for iOS and Android (even when I set the quality settings to Fantastic). Furthermore, it used to work before I upgraded to 5.3.1f1.

    Here's how my material looks:
    Screen Shot 2015-12-21 at 5.41.24 PM.png
     
  2. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The ShaderVariantCollection is the official way to get unity to not to stip shader variants that are used only at runtime but not included into the scene.
     
  4. Voliware

    Voliware

    Joined:
    Feb 4, 2023
    Posts:
    15
    You probably also need to do this

    renderer.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;