Search Unity

Prefab Mode Lighting

Discussion in 'Prefabs' started by noethis, Dec 13, 2018.

  1. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Just downloaded 2018.3 to try out the new prefab features. First thing I noticed was that as soon as I enter prefab mode the lighting is way darker and off. So then I set up the prefab environment scene in the project settings so that it would match my scene but it's still way off.

    I'm using a flat lighting approach where scene ambient color is full white--I'm guessing this has something to do with it? Even when I set the ambient color in the prefab environment scene it seems to not take that into effect. Since everything is flat and I'm coloring scenes in editor I absolutely need to see correct lighting/colors while in prefab mode. Am I doing something wrong?

    intended lighting vs prefab mode:
    1.JPG vs 2.JPG
     

    Attached Files:

  2. xidived

    xidived

    Joined:
    Aug 5, 2018
    Posts:
    3
    I have the same problem, and my prefabs look very different(with same light settings) in Unity Editor and in Android device. Maybe it is a bug of current version Unity?
     
  3. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12
    Same here, this really bothers me. I need to keep opening/closing prefab mode to see the changes because lighting looks completly different in prefab mode.
     
    Last edited: Dec 16, 2018
  4. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    We currently have an issue with Ambient lighting in Prefab Mode.
    Please make a bug report and paste the issue number in this thread so we have your use-cases to test with. Please note if you are using Scriptable Render Pipeline or not.

    It will be fixed in an upcoming patch.
     
    Joe-Censored and impulse9 like this.
  5. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12
    I've reported this and got assigned case number 1112259
     
  6. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Can confirm I have the exact same issue. Created a Stage Scene for Prefabs that only has a Direct Light and Ambient Light settings and the ambient light does not work.

    In addition, sometimes the Direct Light does not work either.
     
  7. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Any news on this, there has been 2 releases since this was reported, seems like a glaring oversight for a flagship feature of the new Prefab system.
     
  8. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    We have a lot of issues to fix and can't do everything at once.

    For the specific issue here, case 1112259 just got into QA verification today (where they try to reproduce the bug before it's sent to developers). I guess they have a lot on their plate in QA as well.

    I wish we could make everything happen faster, but the reality is that some patience is needed.
     
    noethis likes this.
  9. CliffCawley

    CliffCawley

    Joined:
    Mar 30, 2009
    Posts:
    22
    I just encountered this one too, looking forward to the fix :)
     
  10. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    Can confirm this issue as well. Makes prefab mode unusable. Could we get an option to have "no light" in prefab mode?
     
  11. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Use the SceneView lighting toggle as a workaround until this is fixed. The lighting toggle state is stored per Prefab opened in Prefab Mode.

     
  12. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    @Mads-Nyholm Thanks, first thing I tried :), doesn't work.

    Cannot confirm in general, but we use custom lights for Unto, the default lights are way way too expensive for 2D, and we can't bake our lighting for reasons I cannot fully recall... 2D sprites + our DoF shader stuff... something like that :).

    A thot, can I detect when the editor is in "prefab edit mode"? And, is the prefab edit mode located in world space relative to other scenes or in some new view space? Can I move a light to it?

    I'm asking b/c maybe I could turn on a full white light at the location of prefab only when editing. Thots?
     
  13. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    You have a couple of options.
    1) First try to add a light to the Environment scene (make sure the scene is assigned in Editor Settings)
    2) Or use
    PrefabStage.prefabStageOpened
    . Here you get passed the PrefabStage that has just been opened and can dynamically add environment objects by creating your GameObjects and moving them to
    prefabStage.scene
     
  14. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
  15. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    Excellent, thanks. I'll have a look as soon as I get a free window. Cheers!
     
  16. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    @Mads-Nyholm giving this a go today...

    1, Adding a light to the Environment scene doesn't seem to work, nor does a ground or anything else -- is this scene truly getting loaded on prefab edit? For clarification when you say 'Editor Settings' you mean Project Settings > Editor (tab), yes? Just want to make sure I'm not missing another place to set the Prefab scene.

    2, How do I wire up
    OnPrefabStageOpened
    ? I hung it off a MonoBehavior that is set to execute in edit mode and added it to a loaded GameObject but it never gets called... :|.
     
    Last edited: Apr 9, 2019
  17. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    318
    In your ExecuteInEditMode script, you need to assign your function to the prefabStageOpened event, like this:

    Code (CSharp):
    1. void Start()
    2. {
    3.     PrefabStage.prefabStageOpened += OnPrefabStageOpened;
    4. }
    5.  
    6. void OnPrefabStageOpened(PrefabStage prefabStage)
    7. {
    8.     // Do stuff here
    9.  
    10.     // Unsubscribe when done so you dont get multiple callbacks when re-entering prefab mode
    11.     PrefabStage.prefabStageOpened -= OnPrefabStageOpened;
    12. }
     
  18. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    Ahh... :)... thanks, will give it a go!

    I now get the event, and the prefab scene that I created and put a light in, appears to be loaded, but it is totally dark, no light at all.
     
  19. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    318
    I played around with it a little and found that I had to toggle the scene lighting *on* in prefab mode to see the added light (the little sun looking button at the top of the scene window). Also, make sure you are moving the light into the prefab scene.

    edit:
    Here is a complete working script that I added onto my prefab:
    Code (CSharp):
    1. using UnityEditor.Experimental.SceneManagement;
    2. using UnityEngine;
    3. using UnityEngine.SceneManagement;
    4. [ExecuteInEditMode]
    5. public class PrefabModeLight : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.         PrefabStage.prefabStageOpened += OnPrefabStageOpened;
    10.     }
    11.  
    12.     void OnPrefabStageOpened(PrefabStage prefabStage)
    13.     {
    14.         // Do stuff here
    15.         GameObject go = new GameObject();
    16.         Light directionalLight = go.AddComponent<Light>();
    17.         directionalLight.type = LightType.Directional;
    18.         directionalLight.intensity = 10;
    19.  
    20.         SceneManager.MoveGameObjectToScene(go, prefabStage.scene);
    21.  
    22.         // Unsubscribe when done so you dont get multiple callbacks when re-entering prefab mode
    23.         PrefabStage.prefabStageOpened -= OnPrefabStageOpened;
    24.     }
    25. }
    26.  
     
    Last edited: Apr 10, 2019
  20. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    Thanks for digging into this... I think it's something to do with my custom 2D lights (see context early in thread)... I had everything working early, but this simply doesn't work for me :|.

    I'll keep hacking at it, and post back if I get anywhere.

    @UnityDesign As general feedback to any Unity UI designers that might come across this thread. The new prefab workflow indeed enables nesting prefabs, but at the expense of the more common in-line and bulk editing of prefabs. To me this feels like the wrong prioritization. I find the current prefab workflow so cumbersome that I'd greatly appreciate a way to turn it off and use the old system :|.
     
    Lars-Steenhoff likes this.
  21. unity_v6RHUHoRNjSj-Q

    unity_v6RHUHoRNjSj-Q

    Joined:
    Jun 2, 2019
    Posts:
    1
    I had the same problem. I created a scene with a few directional lights and used it as Prefab Editin Environment (Project Settings -> Editor)
     
    _slash_ and GlitchCrew like this.
  22. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    It's been about 8 months now and the ambient lighting issue in prefab mode still exists. Did I miss something or has it not been patched yet?

    EDIT: May have found the fix in the 2019.1.6 release notes (I'm on 2019.1.0). It seems that release notes are split between 2 different pages--the Download Archive (https://unity3d.com/get-unity/download/archive) and Patch Releases(https://unity3d.com/unity/qa/patch-releases)?
     
  23. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
  24. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Is this fix coming to 2018.4 LTS ?
     
    Rich_A likes this.
  25. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    It has been in 2018.4 since 2018.4.4f1.
    Note, I believe it doesn't work if the environment scene is set to Auto in the lighting settings. If you set it to Baked and bake it, it should work.
     
  26. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    As far as I can tell, even with 2019.3.12f1, their are no environment reflections (eg. from the Skybox). It's exactly as if the "Intensity Multiplier" is set to 0, which, as the Tooltip even says, produces physically incorrect results.

    This is an ancient problem, surely there must be something I'm doing wrong, this can't have been "sitting in QA" for 2 years.
     
  27. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    It was fixed around a year ago as you can see from the replies above. I just tested myself here and I do see reflections. If you don't, there must be specific circumstances in your project that is the cause, and we'd need a bug report to be able to investigate.

    But first, when you open the scene that you've set as environment scene, do you see proper reflections in that scene itself? And has the lighting been baked in the Lighting window? If it's set to "Auto" it won't work.
     
  28. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    Ah, it's the Auto thing. Is the reason that's not also fixed that Enlighten is being deprecated? I don't fully understand how dynamic scenes will be realtime-lit after that deprecation, but for now at least my Prefab env is reasonably lit.
     
    Marc-Saubion likes this.
  29. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    650
    With raytracing - I guess thats why they put no effort in providing any realtime GI solution right now.
     
  30. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Apparently, this problem is still there... after 3 years...

    Toggled off (no scene lights):
    upload_2021-9-5_16-17-57.png

    Toggled on (scene lights... there are no lights in the scene):
    upload_2021-9-5_16-18-46.png

    This happens if you edit a prefab that is NOT in the scene.
    Annoying to have to put the prefab in the scene so to have a decent visual, and wondering how hard can it be to fix this.
     
  31. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Hi PolyMad,
    What version is this? Do you have an Environment scene set for Prefab Mode?
    Do you mind creating a bug with a small repro project?
     
  32. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Oh no, I don't have an environment scene for the prefab mode.
    Didn't even know this is possible.
    I'll set up one then!
    Thank you for assistance!
     
  33. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Hello, using Unity 2020.3.18f1, I have a similar problem:
    Normal setup is like so:
    upload_2021-11-3_19-45-18.png

    And when opening the prefab:
    upload_2021-11-3_19-45-52.png

    I tried to set the scene as prefab environment in project settings but did not help.
    The prefab is empty at the moment as you can see, this is normal I was just about to edit it when I saw that issue.

    This is my lighting environment if it can help:
    upload_2021-11-3_19-48-57.png

    The camera is set to use a solid color:
    upload_2021-11-3_19-52-26.png

    I created another scene to set as a prefab scene.
    If I set a skybox material, any skybox material (like a yellow one as you can see in the picture), then I have a black background. I suppose this is due to the error.
    upload_2021-11-3_19-58-15.png
     
    Last edited: Nov 3, 2021
  34. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    76
    Same here in 2021.2.14f1, all prefab mode are dark without any light
     
  35. J1wan

    J1wan

    Joined:
    Jun 4, 2020
    Posts:
    15
    I'm having the opposite problem, lighting inside prefabs shows only in prefab mode. When I go back to the editor, all lighting inside the prefab does not show.
     
    Genebris likes this.
  36. howardmealor

    howardmealor

    Unity Technologies

    Joined:
    May 21, 2021
    Posts:
    18
    Hi @J1wan. Can you please submit a bug report with a small repro project?
     
  37. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    144
    Have you managed to solve this? I have this issue as well.
     
    Last edited: Sep 10, 2022
  38. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    144
    Just figure out my mistake: single point light casts 6 shadows so limit of 128 shadows in HDRP asset wasn't as much as it seemed. Maybe this was your issue as well.