Uploaded February 2021 | Updated September 2026, 6 days ago
As I interrupted my last stream I decided to do an extra one. In this stream we build our on A* implementation to figure out how our character should move to a selected cell. While the movement logic itself still needs to be added we got to a point the A* logic all works.
Follow me on twitter for updates: twitter.com/mux213
Consider supporting me on Patreon: patreon.com/mux213
Please consider subscribing to my channel if you enjoyed the content.
As I interrupted my last stream I decided to do an extra one. In this stream we build our on A* implementation to figure out how our character should move to a selected cell. While the movement logic itself still needs to be added we got to a point the A* logic all works.
Follow me on twitter for updates: twitter.com/mux213
Consider supporting me on Patreon: patreon.com/mux213
Please consider subscribing to my channel if you enjoyed the content.
![Godot 3D Shader Tutorial (2) : Using the depth buffer
In this video well have a look at how we can use the depth buffer to find out how much distance there is between the surface of the water and the walls of the pool behind it. Then we use that to darken the water the higher that distance is.
Info about reconstructing positions from depth buffer:
http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer/
Beers law:
https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law
Just for completeness (note Im leaving z as negative):
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
depth = depth * 2.0 - 1.0;
float z = -PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
float x = (SCREEN_UV.x * 2.0 - 1.0) * z / PROJECTION_MATRIX[0][0];
float y = (SCREEN_UV.y * 2.0 - 1.0) * z / PROJECTION_MATRIX[1][1];
or alternatively:
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
vec4 unproject = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
vec3 view_vertex = unproject.xyz / unproject.w;
Source code on github:
https://github.com/BastiaanOlij/shader_tutorial
Playlist:
https://www.youtube.com/watch?v=xoyk_A0RSpI&list=PLhqJJNjsQ7KHqNMYmTwtsYTeTrqrRP_fP
Follow me on twitter:
https://twitter.com/mux213 Godot 3D Shader Tutorial (2) : Using the depth buffer](https://i.ytimg.com/vi/Jq3he9Lbj7M/mqdefault.jpg)









