[RELEASED] Corgi Fog Gradient - Distance Gradient Fog For URP

Link!
Asset store url: Corgi Fog Gradient - Unity Asset Store
Documentation: Corgi Fog Gradient - Documentation

What’s this?!
Distance color gradient fog for URP!

Features!!
Quickly and easily drop in replace URP’s linear fog with a color gradient.

  • Very simple drop in. Add RenderFeature and add Post Process Volume Component and BAM, immediately have fog you can edit in real time.
  • Supports a quick and easy to use post processing render mode AND a much more optimized shader macro that can be easily dropped into any HLSL shader.
  • Highly optimized fog system, with some options for making it even faster if necessary.
  • Supports both HSV blending for better visuals, and typical RGB lerps for slower devices.

Documentation here: Corgi Fog Gradient Documentation - Google Docs

Pics:


Need help?
Just email me: coty@wanderingcorgi.com

It is now released!

Pushing an update!

Another small update coming in hot:

Another update on it’s way:

Hi, is there a possibility to apply the gradient fog to a standard shader like the “Simple Lit” shader? As far as a saw/tried it, you need a custom shadergraph where the “CorgiFogGradient” node needs to process the texture color to apply the fog.
Cheers,
Quegg

Are you referring to the Unity Built In Render Pipeline’s Standard shader, or are you referring to URP’s ‘Standard’ (Lit) shader?

This plugin doesn’t support the old built in pipeline, but if you need it to, let me know and I’ll see if I can do something about that.

If you mean the URP Lit shader, you have a few options (which are outlined in the documentation):

  • You can simply put the plugin in ‘post process’ mode, and you will not need to modify any shaders and the plugin will “just work” everywhere. The downside to this is the plugin is slightly slower, as it now requires an actual post processing pass which will touch every pixel. (adds a blit for a custom grabpass, then adds a blit to apply to screen).
  • OR
  • You can put the plugin in ‘per material’ mode. This mode requires all shaders in the project to include the shader macros that come with the plugin. You can do this with normal HLSL editing tools. I’ve also provided ShaderGraph tools, but URP’s ShaderGraph does not have a ‘final color’ block so it’s not possible to do any sort of per-material post processing with ShaderGraph yet. It’s just included to future proof for when they do. The upside to this mode is there is no extra post processing required, so its as fast as you could possibley render.

Hi thanks for answering!
I mean the default URP shader. I added render feature and set to post process mode, but the fog does not show up. It appears only if i use a material with a custom shadergraph applying the fog. Here a screenshot of a minimal test project:

1 is the Forward Renderer with the Render Feature,
2 is the Post Process Volume
3 the material and shader the objects use.
The camera has post processing enabled and the build-in post processing effects work(forgot to include that in the screenshot).

When i change the shader to a shadergraph which includes applying the fog inside the shader it works. Then i see the following

I guess i have something misconfigured somewhere but i cannot get it working as post process effect.
Maybe you have an idea what could be wrong.
Regards,
Quegg

The post process mode requires depth to be on, but it should be requesting URP to enable that for you. Maybe you need to enable it manually? It’s in the URP Renderer settings, next to opaque texture, toggle on depth texture.

It does not work even after enabling. I also tried it in an empty project and cannot make it work as post process.
Can you provide a minimal project/example where the fog as post process is working so i can compare to mine to figure out the problem? In the asset itself there is only an example where the material handle the fog.

Some things to check, for the post process mode. The renderer quality settings need depth texture enabled:
7996884--1027929--upload_2022-3-26_13-10-8.png

With the quality renderer settings updating volumes:
7996884--1027941--upload_2022-3-26_13-12-26.png

With the renderer’s post processing ticked on.

For scene view, you need to enable fog here in the scene view material settings:
7996884--1027932--upload_2022-3-26_13-11-2.png

Make sure the RenderFeature is on the renderer you’re actually using:
7996884--1027935--upload_2022-3-26_13-11-28.png

You’ll also want to make sure you have a Volume in the scene, probably marked as Global as a test.

Oh another thing, I’m not sure why but this seems to be necessary. I’m going to dig into why soon.

7998567--1028310--upload_2022-3-27_9-45-36.png

That did the trick!
The other things were configured correctly but setting the intermediate texture to always made it work.
Thank You!

By the way, do you know a possibility to make the fog run faster? Adding the render feature halves the fps in every scenario i tested.

The fastest way to run the fog is thru the per-material render mode. This bypasses any need for post processing. However, the setup is a lot more complicated. I highly recommend it, if you have experience with or want to study shader programming. There’s a guide on how to do this in the ReadMe.pdf file included with the plugin, although it assumes you have some shader knowledge already.

Even in the slower post-process mode, this seems very slow, it definitely should not be affecting your framerate in this way. What device are you using, what’s the hardware? And can you get me a profiler sample? Is it slow in the editor on your pc or just in builds on some mobile device? I need all the info you can give me to help you figure out what’s going wrong.

Update incoming!

This update has a big performance improvement for anyone using per-frame volume updates. Here’s a before and after of the cpu profiler for updating the fog gradient texture (used internally to blend gradient values between volumes).

Compatibility update:

Another small update:

Hey there! Just saw the package and looks great, however I am not currently able to use it because of a small error.

I don’t know what might be causing it… can you help me please? Thanks!

Hey there. What version of unity are you on? This seems to be an issue caused by unity changing APIs in some version.

I’m using 2020.1.11f1 but I already figured out it was a unity version issue. Thanks a lot!

1 Like