2D Colored Fog Shader with URP

Hi all,

I am trying to get this tutorial to work:

http://blog.moondrop.no/2016/08/creating-colored-fog-in-a-2d-game-with-unity/

I managed to run this in a new project just fine, but in my main project where i want to use this,
i am using the URP. unfortunately the shader and materials do not work in URP.

It seems like i would need to adapt the scripts, but I cant figure out how.
any help would be much apprechated.

regards
KM

I would suggest reading through the URP documentation and ebook. Perhaps what that shader does is already readily available, or it may be easy to replicate with Shader Graph (seems like it but I have no exp with SG).

Generally speaking, consider tutorials that don’t explicitly mention the render pipeline as outdated because they use the built-in renderer, but none of these shaders will work with URP/HDRP.

A quick look at that article, it looks like they’re basically just tinting the colors based on the position.

Front ↔ Back [z]
Top ↔ Bottom [y]

Their scene is laid out with xy having the same plane as the camera, and z going farther back away from the camera.

This wouldn’t be too hard to make with Shader Graph, though I don’t think you could have Dynamic Batching on since that’ll fuse the position together for batchable objects. I would work through a couple “learn shader graph” videos on youtube for 2D, then see how to turn off Dynamic Batching (use SRP Batching instead), then see about making this yourself.

Get top/bottom working first, then front/back. You can see in the script that the author defines some arbitrary cutoff values for what constitutes “very far back” and “near the front.” Then he just linearly interpolates over those ranges.

For additional help, make a thread on the Shader Graph forum.

Hi,

thanks i reposted this in the shader graph forum, thanks for the suggestion.
you are right about the top bottom and front back tinting, it seems achivable if i know the right procedure,

but i do not know which nodes to use in shader graph yet.
I already watched some youtube tutorials, but most of them use “sprite lit master” or some kind of master node, and i only have “vertex” and “fragment” which have different inputs.

also it is unclear which shader graph i should use to start with. I have a lightings system set up with urp, so i suppose this should be a lit shader graph. all assets are 2D btw

did you solved it? same problem lol

UPD
connect out to color and alpha
preview doesnt work, but in game its ok

Hi, Yes you can see the answer thread here:
https://forum.unity.com/threads/2d-colored-fog-shader-with-urp.1550942/#post-9670325