Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Tweaking shperical harmonics code for non-photorealistic lighting

Discussion in 'Global Illumination' started by MMeyers23, Oct 15, 2022.

  1. MMeyers23

    MMeyers23

    Joined:
    Dec 29, 2019
    Posts:
    101
    Hello,

    I have a project that uses stylized lighting that is non-photorealistic, and has features to adjust the colors of shadows including ambient occlusion contribution color. In illustration, artists often depict lighting and shadowing with shifts in hue that are not photo-realistic. However, Unity's global illumination system (URPs progressive one or Enlighten) calculated lightmaps in a photorealistic manner. I would like to adjust the code that controls how lightmaps are created if this is possible???

    For example, lets say there is a red sphere in a room where each wall is a different color. On one wall, the ambient lighting on the wall picks up the red light bouncing off the red sphere and colors the wall slightly red where it is close to the ball. On another nearby wall, I would like the ambient lighting to appear more orange, even though currently the lightmap would add a red color, since the sphere is red. I want to tweak how lightmaps are created for specific objects. Perhaps at the point where radiosity is calculated, I want to choose the color that is bounced off the red sphere to a DIFFERENT color for a specific object's lightmap.

    I believe lightmaps are already created per object. I am trying to find out how a specific object's lightmap might receive different color information based on user-controlled presets when the lightmaps are generated (i.e. one wall receives ORANGE light from red ball while another wall receives RED light from red ball). One person suggested tweaking the meta pass, but this would affect an object's CONTRIBUTION to global illumination, so in the above example it would change how the red ball contributes to GI thus changing how ALL the walls receive ambient lighting due to the red sphere. I want to change a specific object's RECEIVING color of ambient light, if that makes sense.

    How do I found the source code that needs adjusting? Is this possible?

    Thank you!
     
    Last edited: Oct 15, 2022
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Unfortunately, what you are trying to achieve is not possible at the moment. We do have a task in our backlog to expose lightmapping outputs to Shader Graph, but there's no ETA for that yet...
     
  3. unity_9F3218D57095C74D39E8

    unity_9F3218D57095C74D39E8

    Joined:
    Mar 17, 2022
    Posts:
    1
    You can try modifying the lightmaps directly in photoshop or your favourite image editor. You can even do separate passes for each light, modify them one by one and then blend them together to have the whole lightmap.

    Maybe this solution makes not sense for your specific problem or is something you cannot do.
     
    MMeyers23 likes this.
  4. MMeyers23

    MMeyers23

    Joined:
    Dec 29, 2019
    Posts:
    101
    Do you know I would replace the lightmaps in the engine with the ones I edited in photoshop?
     
  5. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    You should be able to. Just make sure that you've finalized your lightmap settings before making edits. Any changes might cause change in UV layout, rendering your edits in PS useless
     
    MMeyers23 likes this.
  6. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    254
    You should be able to just replace the
    .exr
    file on disk with your own image. Make sure to keep the the
    .exr.meta
    intact, though.

    You can also set currently used lightmaps both in editor and at runtime using
    LightmapSettings.lightmaps
     
    MMeyers23 likes this.