Search Unity

Feature Request Light Functions

Discussion in 'High Definition Render Pipeline' started by Gooren, Oct 7, 2020.

  1. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    That would mean a HUGE difference for our underwater set game.
    Sun -> sea floor turbidity simulation is next to impossible without it. Specially if one would want other light sources correctly simulated as well.

    This features already exists in UE4.

    For completion sake, there is my question thread as well.
     
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Gooren likes this.
  3. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    Hi, I can do some basic shader programming. I actually never used Shader Graph yet.
    I can see where you are going with the cookies. Interesting.

    But how can I get light info (light color and intensity per pixel) into the custom render texture init shader? Not only that, I will also need data for inverse projection to be able to figure out each texture pixel's resulting world space position (to figure out the water depth at that pixels XZ plane position).
     
  4. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    168
    Just want to add that they used this technique in this demo: https://github.com/Unity-Technologies/FontainebleauDemo
    It was on directional light to imitate shadows from clouds.

    Be aware, that baking with dynamic cookie by rendertexture caused my Unity to crash. So, everytime I rebaked I disabled it, baked and enabled again. Maybe they fixed it already:)
     
    Gooren likes this.
  5. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    Thanks for more information. I understand how that might work.
    But I have no idea how to capture the directional light data (first without cookie) to change the cookie texture based on that data right after (and render the directional light with that cookie).

    Without the directional light data (lit pixels colors, intensities and world space positions) I'm lost :(
     
  6. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    I got some prototype of suggested solution *sort of* working. I used an orthographic camera with position and rotation synced with the directional light. Then I capture depth from that camera using a custom pass (based on this approach). Then I use that depth to calculate world Y (water depth) and populate the cookie (custom render texture) from it. I use that cookie on the directional light.

    But since this is a texture based approach, my worst fears manifested:
    1) When observing ocean floor with some shadow from a ship for example (something with much lower depth than floor itself), the shadow always has bright outline (due to the large depth difference between the floor and the shadow caster).
    upload_2020-10-11_22-39-21.png

    2) Conversely, similar issue appears (for same reasons - all this being a texture based approach) on the shadow caster itself, as seen here.
    upload_2020-10-11_22-41-30.png

    I was unable to get rid of these issues by changing texture color depths in HDRP settings, texture resolutions, cookie size, orthographic camera size etc.

    Also, while using Custom Render Texture as a Directional Light cookie, the option to use all Directional Light supported cookie modes (Directional Light or Spotlight) is not available.

    I like the ability to change the light color (thanks to colored cookies support; this allows not only for sun -> water floor light intensity simulation but also for proper light color absorption) - that is the only upside of this solution compared to UE4's light functions that I know of however.

    I mean... it works, but it has these annoying artifacts. We can't have these :(

    Any ideas @SebLagarde @antoinel_unity?
     
    Last edited: Oct 12, 2020
  7. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    Please forgive me for bumping like this @SebLagarde
    I'm just really desperate here :( This thing I'm trying to achieve here is the last thing that stands in the way to our underwater experience perfection.

    You told me to try a specific approach in order to solve my problem. I implemented it but there are some unpleasant artifacts that are, AFAIK, not really possible to eliminate (see the post above)

    Please help oh great HDRP master <3