• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by kilogold · Jan 09, 2016 at 08:36 PM · unity 5shadermateriallightemissive

Standard Shader Emissive Warning?

tl;dr -- Why do I get the warning in the picture below?

===================================================

I'm following was marked as answered here: http://answers.unity3d.com/questions/914923/standard-shader-emission-control-via-script.html

However, there is one unspoken caveat. Apparently GI doesn't update on it's own, as observed here: http://answers.unity3d.com/questions/920023/change-materials-emission-scale-at-runtime.html

It turns out, that setting the "_EmissionColor" on the Standard Shader is not enough, we must also set the emissivity via DynamicGI.SetEmissive (although I see other posts using DynamicGI.UpdateMaterials: http://answers.unity3d.com/questions/919499/dynamicgisetemissive-not-working.html)

I have an empty room, with a cube that has a magenta emissive light. Technically, everything is visually correct (the surroundings receive emitted light), so I have nothing to worry about, except that I have the following warning on my editor, which is bugging me: alt text

Searching for this specific error only yield one result in my Google searching: http://forum.unity3d.com/threads/unity-5-0-shader-assigning-movietexture-in-emission-map-slot-problem.309680/

I can only guess that this is due to not properly activating the shader variant related to Emissive lighting? I read about this here: http://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html Granted, I'm not satisfying requirement #2, but as per the doc, I did enable the keywords and it should be enough:

Using the keywords above is enough to get your scripted Material modifications working while running in the editor.

My code below:

 public class IlluminatingWall : MonoBehaviour
 {
     [SerializeField]
     private Color wallColor;
 
     private Material wallMaterial;
     private readonly string shaderEmissiveName = "_EmissionColor";
     private readonly string shaderKeywordFeatureEmission = "_EMISSION";
 
     private const float enabledIntensity = 1.0f;
     private const float disabledIntensity = 0.0f;
 
     MeshRenderer myrend;
     // Use this for initialization
     void Start()
     {
         Shader.EnableKeyword(shaderKeywordFeatureEmission);
         wallMaterial = GetComponent<MeshRenderer>().sharedMaterial;
         wallMaterial.EnableKeyword(shaderKeywordFeatureEmission);
 
         myrend = GetComponent<MeshRenderer>();
     }
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetButton("Fire1"))
         {
             Illuminate();
         }
         else
         {
             Dim();
         }
     }
 
     public void Illuminate()
     {
         wallMaterial.SetColor(shaderEmissiveName, wallColor * enabledIntensity);
         DynamicGI.SetEmissive(myrend, wallColor * enabledIntensity);
     }
     public void Dim()
     {
         wallMaterial.SetColor(shaderEmissiveName, wallColor * disabledIntensity);
         DynamicGI.SetEmissive(myrend, wallColor * disabledIntensity);
 
     }
 }

I even saw someone doing the same on a youtube tutorial here: https://youtu.be/h5GFoI38DOg?t=1136

I don't think I'm doing anything different from everyone else, so I'm guessing this has to do with some Material configuration?

capture.png (22.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by kilogold · Jan 22, 2016 at 01:23 PM

Found the answer!

Turns out that aside from Unity's documentation telling you that you can indeed manually activate the Standard Shader variants, the warning will still occur on the editor because it seems to deactivate the variant the moment the Emissive value is set to (or hits) zero.

I tried my same algorithms without ever setting to zero, and everything worked.

I need to figure out a more appropriate way to deal with disabling emissive, but the core of this mystery is solved!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Grisnak · Feb 05, 2016 at 07:33 PM

Can confirm, this worked for me! I was trying to manipulate the emission value on the shared material as well so I'd only have to do it once for multiple game objects. Initializing it as close to 0 fixed the issue. Really ridiculous

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

52 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Outline Shader working in editor but not in-game 0 Answers

How to change a child's shader to another shader? 1 Answer

Similar looking base and globe model 0 Answers

Glowing light [HELP] :'( 1 Answer

apply lighting to custom shader made in shader graph? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges