Depth Texture explained - Godot

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024
  • At first when you open godot shader and get the value for depth texture it is hard to understand how to use the data which godot provide to us in shader, In this video I tried to clear everything about depth texture or depth buffer in godot
    depth buffer is useful in many cases like for water shader

Комментарии • 26

  • @mohsenzare2511
    @mohsenzare2511  Год назад +3

    I noticed that in Matrix indices I made a mistake I wrote M33, instead I should write M22, But the math and the rest is correct

  • @Chevifier
    @Chevifier Год назад +5

    This is amazing, I knew about depth textures but never had someone explained the math behind it.👏

  • @cha8802
    @cha8802 11 месяцев назад +3

    After struggling to understand how depth textures worked in godot all day this video finally made it click for me. Great explanation! Thanks for sharing :)

  • @williamgodwin5582
    @williamgodwin5582 Год назад +5

    What interests me most is how much depth sampling affects performance. Some people write that this is not significant today, while others, on the contrary, believe that it significantly reduces performance.

    • @mohsenzare2511
      @mohsenzare2511  Год назад +2

      Yeah William, I think as it should grab the depth behind the plane it render the plane in a separate render like a transparent object, I am not sure maybe it the plane will behave like a transparent object
      But for making the a realistic water you have to use it
      And you are right if you make a mobile game it is better to not use this stuff

    • @williamgodwin5582
      @williamgodwin5582 Год назад +1

      @@mohsenzare2511 I was thinking more about objects color and normals blending

  • @melpeslier
    @melpeslier 11 месяцев назад +2

    You are a BOSS, good explanations and it is the godot doc's missing content.
    Won't you contribute and give more explanations right in the doc ?

    • @mohsenzare2511
      @mohsenzare2511  11 месяцев назад +1

      Thanks for your comment, I never participate in Docs, But if I have time and I can help why not, I will look forward to it

  • @spectrecular9721
    @spectrecular9721 2 месяца назад

    Been struggling to grab the depth of a 3D scene in Godot 4.2 to be used in a fullscreen post-processing 'canvas_item' shader, as depth information is only available in 'spatial' shaders and unless I'm missing something, it seems depth information isn't stored in textures made via a SubViewport. Any tips?

  • @huraqan3761
    @huraqan3761 13 дней назад

    Cool video :)
    Say, what if you have a depth value from a raymarching shader and want to write it to DEPTH? I understand that the value should be made non linear and mapped between 0 and 1 (with 1 for closest and 0 for furthest)

    • @huraqan3761
      @huraqan3761 13 дней назад

      I found an approximation:
      DEPTH = 1.0 - (atan(d * multiplier) / (PI*0.5));
      Where multiplier is some constant around 12.0 in my case.
      It's not precise enough to properly intersect with other geometry though... But it looks OK in some cases.

  • @chienbanane3168
    @chienbanane3168 8 месяцев назад +1

    This helped a lot, thanks!

  • @BeyCuber
    @BeyCuber 11 месяцев назад

    Hi Mohsen, thank you for the great video! I had a very basic question. When you do depth = texture(depth_tex, SCREEN_UV).r, what is the meaning of the ".r"? And what would it mean if I did ".x" instead or something?

    • @mohsenzare2511
      @mohsenzare2511  11 месяцев назад +1

      texture(depth_tex,SCREEN_UV) always return a vec4 with 4 component even if you sample a black and white texture with one channel, Depth Texture has also one channel and by .r or .x (Both work the same) means I just want to grab the red component, if you put .rb for example it means i want to grab red and blue channel in the format of vect2, You should read more about the concept of the shader I recommend to read "the book of shader", Search that on google

    • @BeyCuber
      @BeyCuber 11 месяцев назад

      @@mohsenzare2511 Thanks so much!

  • @DoubledEthan
    @DoubledEthan Год назад +1

    Hi, i am learning c++ but for godot 4.1 (latest) i can't find a normal tutorial for beginners. Can you do it?

    • @mohsenzare2511
      @mohsenzare2511  Год назад

      I have a Gd Extension video series on my channel, Which explain how to start programming with c++ in Godot

  • @roquestral
    @roquestral 6 месяцев назад

    did not work for me on 4.1.3 :(

  • @artisanpixel
    @artisanpixel Год назад

    How come the depth texture doesn't include the plane?
    Nice video by the way :)

    • @mohsenzare2511
      @mohsenzare2511  Год назад +1

      This is how it work, if it include the plane it has not use to us
      it shows everything behind the plane
      Thanks man

  • @catafest
    @catafest 11 месяцев назад +1

    you don't have an discord account ?

    • @mohsenzare2511
      @mohsenzare2511  11 месяцев назад

      Yeah, you can join with this link: discord.gg/2HuPFZksxd

  • @Boildroid
    @Boildroid 6 месяцев назад

    what kind of books you suggest to learn shaders?