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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to access probe occlusion of main light in custom shader?

Discussion in 'Shaders' started by Potaski, Apr 6, 2017.

  1. Potaski

    Potaski

    Joined:
    Aug 21, 2013
    Posts:
    52
    Hi,

    I our project we use all custom shaders and encountered a problem after upgrade to 5.6. In 5.5 and earlier versions, light probes are used to light all dynamic objects in our game with cubemap for fake specular. Thus, no dynamic light is calculated and it still casts shadow from mixed mode lights (only 1 for each scene).

    Before 5.6, Unity already had the ability to only bake indirect light into probes and receive direct light from a occlusion mask stored in probes. It causes our shader to lose the main light source, but I could simply turn on "Add Direct Light" in the lighting window to include direct light into the probes.

    But it seems that this option is removed in 5.6. I tried to add occlusion value from probes to our custom shader, but didn't find the right entrance after searching the built-in shader codes. unity_ProbeOcclusions returns all black. Is there anything I missed?

    Thanks,
     
  2. Potaski

    Potaski

    Joined:
    Aug 21, 2013
    Posts:
    52
    OK, I found it. The occlusion is actually included in the main light color of forward base pass. And it fades automatically to full direct light based on shadow distance, which led to a problem: you can't have dynamic object receive probe shadow and cast realtime shadow at the same time. I think there should be individual control for probe shadow fade as dynamic objects receive probe shadow and cast real shadow is the best solution for most mobile games.

    Currently I'm setting all lights to baked before baking and change them back after baking is finished to get over this problem. Hope there will be a fix soon.