Search Unity

Question Specular Lighting with Baked GI?

Discussion in 'Global Illumination' started by PenProd, Mar 14, 2023.

  1. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Unity 2021.3.19f1
    URP 12.1.10


    Targeting a VR headset (Oculus Quest/Quest 2).

    I have a wall with a painting and a single (Mixed) Point Light.The wall's shader is set to URP/Baked Lit. The painting is a static object. What I would like is specular lighting on the frame and shadows of the painting on the wall. Apparently, this is a lot harder than it seems.

    The only way I have been able to accomplish this, is by setting the painting as a Static object, and setting the scene's lighting mode to Baked Indirect. Problem is that performance takes a huge hit. If I use Subtractive for the scene's lighting mode, Performance is good, but I either get no shadows, or no specular lighting:

    upload_2023-3-14_22-21-51.png
    Scene lighting: Baked Indirect. Painting: Static. FPS: 22. Result: Shadows & Specular


    upload_2023-3-14_22-25-30.png

    Scene Lighting: Subtractive. Painting: Static. FPS: 35. Result: Shadows but no Specular


    upload_2023-3-14_22-31-10.png
    Scene Lighting: Subtractive. Painting: Dynamic. FPS: 35. Result: Specular but no Shadows


    Is there a way to achieve what I want without it taking a huge performance hit?
     
  2. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Ok, found it. Just set the object as Static, then set Scale In Lightmap to 0.

    upload_2023-3-15_7-43-44.png
     
  3. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Well, I spoke too soon. Even though I now get specular lighting and shadows, the rest of the object has become much darker.

    problem.gif
     
  4. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
  5. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I'm already using mixed lights.
     
  6. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    In Subtractive lighting mode, only mixed directional lights provide realtime specular response. All other light types are baked. You can read more about it in the Unity Manual.
     
  7. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    If that's the case, something weird is happening because I'm (only) using mixed point lights and I'm getting specular response on all dynamic objects, and all static objects with Scale In Lightmap set to 0.

    There are no directional lights in the scene.
     
  8. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    It's correct, since if an object is dynamic it's not using lightmaps so it's receiving realtime light from point lights in your case. This is probably the same if you set Lightmap scale to 0, but it makes little sense to do that (just mark the objct as static but use probes instead of lightmaps).