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
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
This is amazing, I knew about depth textures but never had someone explained the math behind it.👏
Thanks Chevifier
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 :)
Glad it helped!
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.
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
@@mohsenzare2511 I was thinking more about objects color and normals blending
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 ?
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
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?
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)
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.
This helped a lot, thanks!
Glad it helped!
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?
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
@@mohsenzare2511 Thanks so much!
Hi, i am learning c++ but for godot 4.1 (latest) i can't find a normal tutorial for beginners. Can you do it?
I have a Gd Extension video series on my channel, Which explain how to start programming with c++ in Godot
did not work for me on 4.1.3 :(
How come the depth texture doesn't include the plane?
Nice video by the way :)
This is how it work, if it include the plane it has not use to us
it shows everything behind the plane
Thanks man
you don't have an discord account ?
Yeah, you can join with this link: discord.gg/2HuPFZksxd
what kind of books you suggest to learn shaders?