Light Functions

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.

Hi, Correct me but you can do similar thing with an animated cookie created with a Custom render texture: (except it required hand coding, no shader graph version yet)

1 Like

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).

Just want to add that they used this technique in this demo:
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:)

1 Like

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 :(

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).

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

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 ?

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