Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to get the standard shader to emit light?

Discussion in 'Unity 5 Pre-order Beta' started by msgamedev, Mar 2, 2015.

  1. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491


    I have a spaceship model. It is one mesh. Part of that mesh is the engine section with some thrusters. These thrusters have an emissive map (illumination map) that is assigned in Unitys 5 standard shader.

    To my understanding it is possible in Unity 5 that the illuminated parts of a texture (in this case the thrusters) do emit light that will illuminate the nearby geometry.

    I’m obviously too dumb because I can’t get it to work. I’ve read through countless forum posts and all the bit of information that I can get but it is more confusing than it helps. And all the tests so far have failed.

    - Emissive lights have to be baked first? Or not?
    - It only works for static level geometry?

    In a space scene there is usually no level geometry. The spaceship hull itself isn’t animated, although some moving parts are attached to it (e.g. turrets). The spaceship isn’t s a static mesh because it can move.

    Is it possible at all to make the thrusters emit light (preferably in realtime)? If yes how is that realized. I’m looking for a specific step-by step description like first you open that menu and enable this and that, then you go there and do that, etc. because as said above it seems I’m too dumb to get it working otherwise.


    Some information about my settings:

    - I use DX9
    - Deferred rendering
    - Linear color space
    - HDR on camera is enabled


    Any help is appreciated. Thx.
     

    Attached Files:

  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I may not be much help, but have you tried adding light probes near the emission source?
     
  3. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    How to do that? Have never worked with light probes before. I find only Light probe groups under "Game Object" and "Component".
     
  4. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    Yes, it is possible, even in realtime, but the object which emits light has to be static though and emission baked.
    That is done by increasing emission value from 0 to desired intensity and setting GI to either Realtime or Baked.
    Screen Shot 2015-03-02 at 17.25.06.png
    This doesn't fit you, because space ship isn't static.

    You would just create light probe group, when add to it as many probes as you need.
    Light probes lets you capture light in those points (where you placed probes) and when dynamic objects which are close to those points would use that saved lighting, but this solution wouldn't help in this situation as the source itself is also dynamic.

    So how can you workaround it:
    1. Marking whole ship as static, baking lightmaps and when making it dynamic again. This way you would get your desired result, but you won't be able to change emission intensity in runtime (without hacks at least). Also it would require this process to be repeated every time you bake (editor script would be handy)
    2. Using point or spot lights instead. As you are already using deferred mode anyway that wouldn't be that expensive. This way you would get completely dynamic light sources that can be changed in runtime
     
    Devil_Inside likes this.
  5. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Am I being daft here or wouldn't it be enough to simply set the spaceship to Lightmap Static (assuming it's not dynamically generated). You'd do that by clicking on the dropdown arrow next to "Static" and selecting Lightmap Static.
     
  6. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    Thx for the reply.

    I tested hack number one. Marked the ship hull as static and baked a lightmap. Have tried baking it in the object, scene and lightmap tab in case this makes any difference. The result was always the same - There are sparkled black dots all over the lightmap and the thrusters still aren't emitting light.

    Well it seems the best (and easiest) solution for now is using point lights.

     

    Attached Files:

  7. SpiriTx

    SpiriTx

    Graphics QA

    Joined:
    Apr 12, 2012
    Posts:
    252
    No, it's me here who was daft. Completely forgot about it

    Please check if mesh has lightmap uv generated. Also compression might be causing this.

    Could you post a screenshot of your material and lighting window?
     
  8. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    Ok, the black dots problem was solved with enabling generate lightmap UV'S in the import settings.

    This time the bake was succesful, though I think its still not the perfect solution. To get a visible illumination I have to increase the emission to 8. That kills the details in the thruster texture. The thrusters now look like pure white (edit: After demarking the mesh as static I could reduce the emission value back to 1.3. So it looks good and the surrounding is illuminated.

    But the bad news is that the rest of the model now also has backed shadows, e.g. the bottom. In a game the ship would move and these backed shadows will remain even if the bottom of the model is rotated towards the sun.

    Anyways, thx for the help. At least I know now how to bake emission from textures. Although it seems it can really only be used for static scenery.

     

    Attached Files:

  9. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    You could try making the emission part a separate object and setting that to lightmap static.
     
  10. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    Yeah but also the surrounding geomerty that is affected by the emission must be separate then. Thats too much of a workaround just for that minor detail. In that case using a simple point light is the easier solution.
     
  11. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    If you don't need this to be dynamic, why don't you paint that engine-area-highlight into the same emission map where your thrusters are?
     
  12. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    I don't use the model myself. It is a product for the asset store. And it is thinkable that people want it to be dynamic, e.g. ship doesn't move = engine lights are out.
     
  13. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    How are you going to change the color of the thrusters?
     
  14. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Anyway, if you add the highlight into the same map as the thrusters, then whatever you do to the thrusters, will affect the highlights.
     
  15. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    Problem in this case is that painted illumination will always be there. Maybe some people don't like this for whatever reasons. I'll go the way that offers maximum flexibility.
     
  16. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    It will be there because thrusters lights will still be there. And I haven't checked it, but will it still be visible if you turn emission down to 0?
     
  17. msgamedev

    msgamedev

    Joined:
    Dec 24, 2011
    Posts:
    491
    no it will go away then. The problem is that some people will maybe only want illuminated thrusters and no illuminated surrounding.