Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How can you make unlit scene view actually unlit?

Discussion in 'Editor & General Support' started by Janeator, Oct 17, 2023.

  1. Janeator

    Janeator

    Joined:
    Jan 14, 2017
    Posts:
    8
    Perhaps "unshaded" would be the better term, though in my opinion it's just Unity that's using "unlit" wrong. Tick off the lightbulb, but instead of the scene looking flat as an unlit material would ingame - unshaded - the scene takes on a lightsource that casts no shadows emanating from the camera, which causes very annoying (for my workflow usecase) "countour shadows" for round objects and such.
    As an example, here's a picture of a default unity sphere, clearly lit better in the direction of the camera view, and some of my very low poly objects on the left having this dark area where the light is >90º perpendicular or so.
    Captura.PNG
    So besides lights being disabled, I think what's happening here is the lighting pass for the materials is being replaced - but not to an unlit/full bright one. I would like to do exactly just that, so please let me know if I missed this being a thing somehow or anyone can offer some asset to do so. I'm a bit in shock this is somehow not a base feature in this engine unless I missed it. But only a bit, Unity is known to be lacking in all ways.
    I know you can SceneView.lastActiveSceneView.SetSceneViewShaderReplace() but this is not useful as my custom shaders aren't structured like a normal one and it would remove any shaders that handle transparency or such in a different way.

    Thanks
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,961
    Is that a complaint from the same people who complain that Unity is bloated and contains wayyyyy too many features? :p

    It may be shocking to you but if you were to disable all lights, the scene objects would be entirely pitch black with the exception of the skybox. Thus Unity puts a light on the scene view camera when lighting is disabled, this is documented in the manual. Unfortunately you cannot change this scene view light, at least not through built-in means.

    The contours you see is light dropoff due to distance. You‘ll see light fading out linearly with distance on a perfectly flat surface.

    If you need unlit you‘d have to use an unlit shader. As you said, that would look different than expected. Now if you can‘t do it manually, how is Unity supposed to alter the used shaders to make them appear unlit (for both realtime and baked lights) yet retain some of their properties? This is no easy feat and the result would be next to useless.

    If you want to view an object unlit look at it in isolation (prefab mode or blender). But if the scene view had everything unlit, it would look as if everything were flat-colored shapes that change in unexpected ways because the scene would be missing any discernible depth information for the human eye. Imagine the right part of this image, but in colors (uhm .. what colors? where does the color come from? you‘d have to assign it or use a weighted color of the texture(s) or … like I said, this isn‘t trivial):
    upload_2023-10-17_9-7-51.png

    Which brings me to the question: what do you need this for? Perhaps there are other ways to do what you want. You could temporarily assign an unlit shader with an editor script for instance, if necessary by temporarily duplicating the object to a dummy that just has the renderer and mesh. Or you could write custom shaders that allows toggling light / disabling textures. Or view the object in blender, and you could have an editor script that lets you one-click open it in blender if you need to do that often. There is also a wireframe scene viewmode, with and without shading.
     
    Last edited: Oct 17, 2023
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,482
    If you add a ton of mediocre ingredients that don’t play well together into a stew, I’m sure even you would find the results lacking.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,961
    Or not.Let‘s not forget this is what billions of people eat every day. It‘s called fast food or convenience food. ;)

    Anyway, if you want to complain then be specific. I know a few things I would call mediocre, like JsonUtility. Or UI Builder which is decent but clearly not as integrated as it should be (eg rename-refactoring is a pain). Other features like Cinemachine and Shader Graph are clearly way beyond mediocre.
     
  5. Janeator

    Janeator

    Joined:
    Jan 14, 2017
    Posts:
    8
    Of course, I am aware. I fail to see how my desired result is unachievable by unity though... considering most other engines and 3d software manage to do this from their very first releases.
    This is not true true, though trying to show this off does show how there's some degree of smoothness to the lighting method the "unlit" toggle uses as well (also undesireable):
    Captura.PNG
    I am not able to do it manually because whole-shader replacement seems to be the only (easily accessible?) option provided and that would ruin shaders structured differently or using transparencies. But Unity's unlit is already doing better than this by just replacing the lighting model, I just wish to set the lighting model replacement to a different one. When you hit the unlit toggle, my custom shaders aren't suddenly jumbling the textures up, they're simply lit a different way.
    This is literally what I want. Of course texture information (as well as everything else in the material) would be retained. What I need is to check textures in my models in the scene, and having the scene be lit or... weirdly-lit-definitely-not-unlit is proving to be an annoyance.
    Showcased here from the only other thread on this I could find (apparently everyone's cool with how it is), an Unreal picture: https://i.imgur.com/AdCDwhX.jpg

    I guess my best bet would be a script that just disables all lights in the scene and sets ambient to a full white (with skybox lights off, this gives the desired result), but I'm not too knowledgeable in regards to this kind of scripting so I've no clue how you'd keep track of lights' state before hitting this custom toggle. Guess I'll look around.

    Please do not derail the thread into unity defending/bashing, it's an endless discussion (for good reason) and I'm still looking for a solution!
     
  6. Janeator

    Janeator

    Joined:
    Jan 14, 2017
    Posts:
    8
    The smoothness was ticking me off so I kept running tests and I've realised that you were correct, Unity is in fact just slapping a light to the camera and calling it a day, no lighting model replacement is occurring. This is more disappointing than expected and really cuts off any possible solutions in that direction. Script it is, I guess.