PostProcessing icon indicating copy to clipboard operation
PostProcessing copied to clipboard

Fog effect is now configured through profile

Open OndrejPetrzilka opened this issue 6 years ago • 2 comments

Added Fog effect which modifies RenderSettings before rendering and restores after rendering

Related to #512

Implementation consists of three parts

  1. Loading base fog values from RenderSettings in PostProcessEffectSettings.Reset.
  2. Applying fog to RenderSettings in OnPreCull
  3. Restoring original RenderSettings fog values in OnPostRender

Loading base values is necessary for overrides to work properly. We want overrides to work 'on top' of settings which are in RenderSettings.

What works

  • Fog settings
  • Overrides
  • Consistent fog on transparent and opaque materials
  • Different fog on multiple cameras
  • Fog blending between volumes
  • Preview in scene view (image effects/fog)

Possible issues

  • Baking lights?
  • GI (Enlighten)?

Not sure how light baking and Enlighten GI works, it might use fog from global RenderSettings for some calculations.

OndrejPetrzilka avatar Apr 02 '18 20:04 OndrejPetrzilka

Hi, thanks for the PR.

It shouldn't cause any issue wrt baking & GI.

We used to have something similar internally but we eventually had to remove it due to UX concerns because once you start tweaking values in PPSv2 the settings in the Lighting panel are still active but don't do anything which is confusing until you disable all Fog overrides in volumes and then the global one "pops on". The optimal solution would be to actually hide/remove these from the Lighting panel but we don't have any API to do that right now.

It also probably won't work properly on SRPs. That + the need to constantly load/store RenderSettings per frame or it'll break fog & transparent materials as you probably found out... This is not ideal :/

Also for what it's worth, Fog shouldn't be in post-processing as it's a lighting effect (but in this case the frontier is a bit blurry as we already have SSR and AO in there). In case you missed it, we're currently working on a full volumetric framework in HDRP that allows fog volumes with proper shadowing and other cool features.

So right now I can't merge this PR in v2 as-is but I'm keeping it opened until I get a chance to get to it more seriously (and there might be side-effects I haven't thought about yet so it needs a QA pass).

Chman avatar Apr 03 '18 11:04 Chman

Fog volume is what we need for our project. We have some fog settings on surface and different in underground caves (we also animate them).

Since there are no local fog settings, there's just no other way than modifying global settings. Doing it through post processing allows us to take advantage of profiles and blending, which is very useful for artists.

We treat the fog exactly how you described it, default settings are in RenderSettings, post processing volumes can 'override' it.

Fog volumes with shadowing and other features sounds really cool!

OndrejPetrzilka avatar Apr 04 '18 19:04 OndrejPetrzilka