Making Depth For Water Shader In Godot 4 ( Depth Texture )

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

КОМЕНТАРІ • 33

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

    Hey guys, I just made a new Discord server, feel free to join:
    discord.gg/AGt8u2RABE

    • @3darts598
      @3darts598 3 місяці тому +1

      Can you make a totrial in underwater breathing and swimming, and also adding it in random generation world

  • @amazingmation97
    @amazingmation97 6 місяців тому +2

    Great video. I've just recently started learning about shader materials. This series is a great help to understand how they work. :D

  • @edouardwinder661
    @edouardwinder661 4 дні тому

    Awesome video keep up the good work. You are very talented to make clear explanation I must say. I would like also your opinion about movement of object on water like boat trail. No good tutorial updated works/ or explain it well like you do

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

    keep it up! these are great. I like that you focused on just depth. hoping to see you revisit refraction & reacting to objects in water in separate videos respectively.

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

    This is the first time I subscribe to a channel that fast... The video content is ✨❤️❤️❤️✨ ... Hard to see good content like this in yt anymore, pls keep it up, I want more content like these 😊.

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

      Thanks for the feedback, Glad you liked the videos !

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

    Very valuable content. Well explained and easy to follow for intermediate hobbyist coders like me. Thank you very much! Liked and subscribed.

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

    Extremely Cool and you can teach really nicely! You just gained a new subscriber ❤️. Keep it up 💪🏽

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

    I didnt understand anything of the things you said because shaders are magic to me, but i reallllyy liked it

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

    Thank you! Been waiting for this. Your videos have been very informative. After moving from Unity to Godot they gave me a kickstart. Would you mind posting the full code in the description in later videos? So as not to scroll through what was missed. And yes: please make a followup video on all the other details that were not included in this video. This is too interesting

    • @Code_It_All
      @Code_It_All  6 місяців тому +1

      I'm super glad you find my videos helpful, There will be a github repo for projects in the future hopefuly...

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

    Very nice. Very helpful. Thank you very much for this tutorial..

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

    well explained. great tutorial. thanks❤

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

    awesome tutorial, thank you!

  • @MikeMcRoberts
    @MikeMcRoberts 4 місяці тому

    Great but now make it react to objects such as a moving boat.

  • @jethdaflip7741
    @jethdaflip7741 3 місяці тому

    Is it possible to use c# for the shader textures?

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

    Another great video. Thank you for doing this. I do have a question, how do you handle a player that walks into the water and can see underneath because the water has no depth it looks like normal instead of looking like water… Do you understand?

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

      You would probably need to apply another shader to the viewport when ever the player in under water and switch it off when it's not, the shader would be different than this one

  • @meccanizer
    @meccanizer 6 місяців тому +1

    Did you ever figure out how to stop the screen_uv from refracting things not under water? Still haven't figured out a solution.

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

      I used your solution which was better than the original one, however it seemed like there was still a bit visible, The method I came up with was to use the depth texture to find the "wavy" part which would be white, all I had to do was to not sample from _suv in those parts, but there would be a thin outline around it which I tried to fix, since there is no way lerp between 0 and 1 in shader I had no idea what was the solution.

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

      ​@@Code_It_All Do you have code for it. Also doesn't the mix() function act as a lerp? I checked the documentation and it says it acts the same as a lerp with the third value in the function being the weight. The solution I posted has an issue with distortion on the top of the screen, you can fix it by adding 0.010 to the screen_uv.y if you go too far it will start distorting on the bottom or sides. Only issue I found with the solution I posted is the screen uv is brought down the further away it is from the camera(which seems to also cause the distortion on the top problem). This seems realistic but I can't confirm. I don't know how to disable this effect without also removing the water distortion part of it.

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

      My depth code has the "wavy" parts in white and good parts in black, so how would you transition smoothly from 0 to 1 with mix ? The third argument of mix needs to change, where as third argumaent of Lerp can be the same.
      The code is similar to the one in this video, but depth texture is sampled using the _suv from the prev video, distance is very very low and then put the raw depth_blend ( without any beers law ) in the albedo.

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

      ​@@Code_It_All I've managed to figure out how to cull the parts above the water using this code
      if(world.z > VERTEX.z){
      ALBEDO = color * normal_screen* normal_depth_blend;
      }else{

      ALBEDO = color * distorted_screen* distorted_depth_blend;
      }
      I see what you were talking about when you said there is a weird outline, there is like a thin whispy bit on the edge. I think I fixed it by setting the depth texture and or the screen texture to filter_nearest instead of filter_linear. See if that works.

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

      @@Code_It_All I've managed to figure out it using this code
      if(world.z >= VERTEX.z){
      ALBEDO = color * normalScreen * normalDepthBlend;
      }else{

      ALBEDO = color * distortedScreen* distortedDepthBlend;
      }
      I can see what you mean when there is a weird outline. I think I fixed it by setting the filter to filter_nearest to the depth texture, try that. If not, try playing around with the filters in the screen texture and depth to see which works better.

  • @darklord8793
    @darklord8793 29 днів тому

    how can you see trought the mesh if there is no alpha???

    • @Code_It_All
      @Code_It_All  26 днів тому

      We are not actually seeing through it, it's an illusion using the screen texture which is taken before the mesh itself was rendered

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

    You should provide a link in the description to the code so we can just copy-paste without watching the video 😛

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

    Can the water surface reflect object above surface if view at low angle?