Simple Fog In Unity

Поділитися
Вставка
  • Опубліковано 6 вер 2024

КОМЕНТАРІ • 71

  • @KevinDrongowskiSmart
    @KevinDrongowskiSmart 2 роки тому +204

    Your channel is a hidden gem.

  • @KingBobXVI
    @KingBobXVI 2 роки тому +70

    The animations on the cardboard cutout were absolutely top-notch, lol.

  • @luna010
    @luna010 2 роки тому +61

    3:47 slight error, exponential squared fog doesn’t actually reach zero, it just approaches zero faster than non-squared exponential fog.

  • @spore124
    @spore124 2 роки тому +80

    Math sticklers will point out that neither the exponential nor exponential square methods actually reach zero. They approach zero at different rates which, for the case of rounding from floating point numbers, allows the squared function to reach the smallest possible value much more rapidly. The exponential version will also eventually reach that point. Mathematically they're both forever above zero though. From these methods, only linear actually makes it.

    • @Cyberfishofant
      @Cyberfishofant 2 роки тому +3

      you are probably right, but you could just define a very small cutoff

    • @LtPulsar
      @LtPulsar Рік тому +5

      @@Cyberfishofant The mathematician in me says that step functions are for cowards. The physicist in me says things like "the Dirac delta function is the derivative of the Heaviside step function".

    • @immortaldev1489
      @immortaldev1489 5 місяців тому

      if (fogFactor < 0.00000000001f) {fogFactor = 0.0f;}

  • @xanderlinhares
    @xanderlinhares 10 місяців тому +5

    After learning about what gets drawn to the camera depth texture problem you describe, I thought “why not just get access to the actual depth buffer”. Serious rabbit hole but it turns out that it is possible. You just have to set the render target data with your own buffers (and maybe blit a copy before it gets cleared). That should give you access to your grass depth.

    • @Acerola_t
      @Acerola_t  10 місяців тому +5

      Yeah I figured this out about a year later it was nearly impossible to figure out how to properly generate your own depth tex with Unity's API since no one has ever asked the question and whoever does never gets a response lol
      But yes you're right! It's possible and it's pretty great.

  • @obanxMolly1991
    @obanxMolly1991 2 роки тому +14

    Just found this bc I couldnt figure out how to implement some decent looking fog- Really love your video/editing style, have my sub.
    Also: Nice choice of music, I see you are a man of culture

  • @MarcosPS8
    @MarcosPS8 2 роки тому +17

    Greetings Acerola! I'm game artist and I wanted to let you know that I really find so so interesting your videos. They are totally amazing and helped me understand some mistakes I've been seeing during my career. I just wanted to ask you if you plan to make soon more complex videos about art/optimization in Unity/Unreal. Also, if possible, I'll like to learn (if you know some titles/webpages) from some free/paid mid/advanced tutorials/resources about art in games, optimization, engines, shaders... Thank you in advance, you are awesome! 🌻

    • @Acerola_t
      @Acerola_t  2 роки тому +11

      Yeah! As time goes on I'll make more complex videos, got to talk about the simple stuff first.
      The only tutorial series I really recommend is catlikecoding, which ranges from beginner to advanced.

  • @candygonemad
    @candygonemad 2 роки тому +6

    For people who are using URP and struggling
    I was following along with the source code provided, however I realized after I made it all, that this doesn't work in URP. I finally got it working, and I used these sources to get there:
    Ned Makes Games's "Intro to Render Features Unity URP" tutorial on how to make a desaturate effect
    SamDriver's blog on Scriptable Render Features
    CyanGameDev's blog on shader terminology because this was my first shader
    I also converted the shader code into a shader graph myself.
    URP is very different in its architecture for shaders and rendering compared to whats shown in this video. In fact I believe that render features are not a thing in the standard render pipeline? Might be wrong about that.
    Hope this helps people.

    • @candygonemad
      @candygonemad 2 роки тому +2

      For example the OnRenderImage is not used, I set the materials properties (for the shader) in the Execute method of the render pass
      Also Graphics Blit is not used, rather the Blit method can be called and you pass in a CommandBuffer.
      From the Ned Makes Games video, he has a line thats like m_ScriptablePass renderPassEvent = RenderPassEvent something.
      To make it appear on the skybox set it equal to RenderPassEvent AfterRenderingSkybox.
      (cant add dots because scam protection)

    • @Acerola_t
      @Acerola_t  2 роки тому +4

      Yeah this is why I use the built in pipeline, URP doesnt feel production ready lol

    • @candygonemad
      @candygonemad 2 роки тому +3

      @@Acerola_t it's tough because there are some very useful things that come with URP that I would hate to live without, especially on the 2d side, such as the 2d lights. But when documentation for some stuff sparse it really hurts to use URP

    • @wasdMash
      @wasdMash 5 місяців тому

      I've got everything else but the shader graph working now. Which nodes do I need to use to get the distance of objects to the camera?

    • @candygonemad
      @candygonemad 5 місяців тому

      @@wasdMash you can use the scene south node if you are just wanting the depth pass, or if you want like actual positions, your can get the world position of the object and then create a vector 3 variable that you can set to be the camera position in a script. Then use the distance node with those two

  • @RetroMMO
    @RetroMMO 2 роки тому +8

    nice grass at 4:03 you should make a video about grass some time

    • @Acerola_t
      @Acerola_t  2 роки тому +3

      That's a great idea ty

  • @bartholemumk1437
    @bartholemumk1437 2 роки тому +9

    thicc fog incoming in 2022

  • @ObviousDev
    @ObviousDev 2 роки тому +3

    Just discovered your channel and it's been a blast watching through all your tech art related videos so far. Really good stuff! I love educational but also entertaining content. Keep it up

  • @rafertysullivan6085
    @rafertysullivan6085 Рік тому +2

    in unity go to window> rendering> environment and turn on fog

    • @Acerola_t
      @Acerola_t  Рік тому +3

      that's crazy man this is about how that fog actually works tho

    • @rafertysullivan6085
      @rafertysullivan6085 Рік тому

      @@Acerola_t yeah i know I was just kidding

  • @efenty6235
    @efenty6235 2 роки тому +8

    "not computationally feasible"
    ⠀⠀⠀⠀⠀⠀⠀⣠⡀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠤⠤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⢀⣾⣟⠳⢦⡀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠉⠉⠉⠉⠉⠒⣲⡄
    ⠀⠀⠀⠀⠀⣿⣿⣿⡇⡇⡱⠲⢤⣀⠀⠀⠀⢸⠀⠀⠀1984⠀⣠⠴⠊⢹⠁
    ⠀⠀⠀⠀⠀⠘⢻⠓⠀⠉⣥⣀⣠⠞⠀⠀⠀⢸⠀⠀⠀⠀⢀⡴⠋⠀⠀⠀⢸⠀
    ⠀⠀⠀⠀⢀⣀⡾⣄⠀⠀⢳⠀⠀⠀⠀⠀⠀⢸⢠⡄⢀⡴⠁⠀⠀⠀⠀⠀⡞⠀
    ⠀⠀⠀⣠⢎⡉⢦⡀⠀⠀⡸⠀⠀⠀⠀⠀⢀⡼⣣⠧⡼⠀⠀⠀⠀⠀⠀⢠⠇⠀
    ⠀⢀⡔⠁⠀⠙⠢⢭⣢⡚⢣⠀⠀⠀⠀⠀⢀⣇⠁⢸⠁⠀⠀⠀⠀⠀⠀⢸⠀⠀
    ⠀⡞⠀⠀⠀⠀⠀⠀⠈⢫⡉⠀⠀⠀⠀⢠⢮⠈⡦⠋⠀⠀⠀⠀⠀⠀⠀⣸⠀⠀
    ⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⣀⡴⠃⠀⡷⡇⢀⡴⠋⠉⠉⠙⠓⠒⠃⠀⠀
    ⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⡼⠀⣷⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
    ⡞⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
    ⢧⠀⠀⠀⠀⠀⠀⠀⠈⠣⣀⠀⠀⡰⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

    • @Acerola_t
      @Acerola_t  2 роки тому +4

      This is the funniest comment I've received thanks

  • @Soundy777
    @Soundy777 2 роки тому +6

    Loving this content! More please

    • @Acerola_t
      @Acerola_t  2 роки тому +4

      Thanks! new vids every 2 weeks :)

  • @vylax836
    @vylax836 Рік тому +3

    this is gold, Great video !

  • @Luiz-iy5ci
    @Luiz-iy5ci 2 роки тому +1

    I'm a computer science student and thanks to your videos I'm now understanding why I've to study so much math, thx man 🤯🤯

  • @felixisntmyname
    @felixisntmyname Рік тому +1

    It's the best video about fog out there

  • @t0xangames207
    @t0xangames207 Рік тому +1

    Thanks for shader and code❤

  • @csxcatgirl9896
    @csxcatgirl9896 2 роки тому +4

    1. grass
    2. fog
    3. ???
    4. PROFIT

  • @puntangerslx2772
    @puntangerslx2772 5 місяців тому +1

    fog cannot convert from shader to UnityEngine.shader

  • @Aragubas
    @Aragubas 2 роки тому +4

    I wonder if that's applicable for Godot Game Engine

    • @Acerola_t
      @Acerola_t  2 роки тому +5

      The theory is universal

  • @TheBreadPirate
    @TheBreadPirate 8 місяців тому

    Grass and fog are cool.

  • @flurinjenal374
    @flurinjenal374 6 місяців тому

    How much does the standard Unity fog impact performance for mobile games?

  • @user-cu4zj4pr4f
    @user-cu4zj4pr4f 2 місяці тому

    What "volumetric fog" means?

  • @xXBlackWorkXx
    @xXBlackWorkXx 2 роки тому +4

    Dude, I just found your Video and it’s literally the exact fog like fog I need for my project. Is it possible that you could upload your project / fog files for download? I tried to understand your video and copy it but I am just not talented enough for „coding“ this kind of stuff…

    • @Acerola_t
      @Acerola_t  2 роки тому +3

      The reference code is in the description! It's for Unity's built in pipeline though unfortunately.

    • @xXBlackWorkXx
      @xXBlackWorkXx 2 роки тому +2

      @@Acerola_t yes I saw that! But yesterday the link was another one, or am I getting crazy?😂 now there are the files, thank you very much! I like your editing style for such videos. But what did you mean exactly by saying „it’s for unitys built in pipeline“, is that a bad thing?

    • @PotatosDispenser
      @PotatosDispenser 2 роки тому +3

      @@xXBlackWorkXx If you don't know about it, it should not be a problem. Unity allows devs to specify how the graphics should be rendered. There are 4 modes : Built-in, URP, HDRP and Custom. It changes how lights and shaders work (among other stuff). So a shader written for built-in pipeline will not work if your project is setup with URP or others.
      By default, Unity Projects use built-in pipeline, so if you did not modify the graphics settings, this fog shader should work for you.

    • @Acerola_t
      @Acerola_t  2 роки тому +4

      @@xXBlackWorkXx The fog shader files were in the old link but I changed it to the exact link after you commented lol
      Unity has several rendering pipelines, I like to use the built-in pipeline while others like to use URP or HDRP. It's not a bad thing, writing shaders for URP/HDRP is a bit different though but the concepts remain the same.

  • @Sky-iv8zm
    @Sky-iv8zm 2 роки тому +1

    would absolutely love this video but for HDRP/URP using shadergraph or Amplify shader editor.
    Built-in has been on bug-fixes only for a few years now

    • @Acerola_t
      @Acerola_t  2 роки тому +3

      The same concepts apply, I enjoy writing shader code over node based shader authoring so my videos will continue to be focused on that.

  • @nguyenhoangminhtrung2779
    @nguyenhoangminhtrung2779 2 роки тому

    Thank you, I slowly knows more now!

  • @surdno5796
    @surdno5796 6 місяців тому

    Is there any good reason to not use unity’s built in fog system though?

    • @Acerola_t
      @Acerola_t  6 місяців тому

      there is plenty of value in having your own extendable system, also if you write any of your own shaders they are incompatible with unity's fog system unless you use their fog shader functions which good luck finding info for

  • @CaveJohnson376
    @CaveJohnson376 Рік тому +2

    welp, the way unity does depth processing is indeed cringe. for comparison, godot does shadowcasting passes only if they are actually needed and, furthermore, you can make it so certain selected objects don't cast shadows at all. oh, and all the opaque objects are rendered in same pass, and all of them write depth values to depth texture, without requiring to write separate shader function for shadowcasting pass. all simple, nice and easy.

    • @Acerola_t
      @Acerola_t  Рік тому

      That's cool, Unity also does all of those things!

  • @RatchetEden
    @RatchetEden Рік тому

    So Ive been working on this fog problem for a while, which rendering pipeline did you use for this, i couldnt get your script and shader working in urp

    • @Acerola_t
      @Acerola_t  Рік тому

      it's for built in so not compatible with urp

  • @davidj_bergman
    @davidj_bergman Рік тому

    I love the vibe in this video! But unfortunately I still have no clue how to use this new knowledge...

  • @ShwetaSharma-su3il
    @ShwetaSharma-su3il Рік тому

    Hi I want to apply blit fog effects to a specific object not on the whole screen how can i do that?

    • @Acerola_t
      @Acerola_t  Рік тому

      do it in the fragment shader as i demonstrated

    • @ShwetaSharma-su3il
      @ShwetaSharma-su3il Рік тому

      @@Acerola_t I want to apply fog on object only.

  • @kirillbrodski
    @kirillbrodski Рік тому

    Heya bud, just dropping in to say great vid and channel. Hope you can take a break and focus on your mental health. Looking forward to crediting you and your content when my megahit game releases!

  • @rudyramadhana4127
    @rudyramadhana4127 Рік тому

    persona 3 dorm vibes lets gooooo

  • @Tenzordk
    @Tenzordk Рік тому

    Was wanting to add this to my small VR project, but sadly cannot be used without some fiddeling.. And I am not up to the task :D

    • @Acerola_t
      @Acerola_t  Рік тому +1

      I mean, this is about as simple as post processing shaders get, but I understand!

    • @Tenzordk
      @Tenzordk Рік тому

      @@Acerola_t I just have not looked at shader.. As in at all 😊

  • @Jamesfart123
    @Jamesfart123 Рік тому

    acerola are you ok?

  • @JustSomeGameDev
    @JustSomeGameDev Рік тому

    my depression 😭💀

  • @Lam0rak
    @Lam0rak Рік тому

    As an Unreal dev this video is archaic

    • @Acerola_t
      @Acerola_t  Рік тому +4

      unity has fog built in, this isn't really a video about engine specific implementations rather how a simple distance fog shader would work regardless of engine.